refactore pcap management script.