def dump(): hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535) pdumper = pcap.pcap_dump_open(hpcap, './test.pcap') data = b'11111111111111111111111111111111111111111111' pkthdr = ptypes.pcap_pkthdr() pkthdr.caplen = len(data) pkthdr.len = len(data) now = time.time() pkthdr.ts.tv_sec = int(now) pkthdr.ts.tv_usec = int(now * 1000 * 1000) % (1000 * 1000) pcap.pcap_dump(pdumper, ptypes.pcap_pkthdr_p(pkthdr), data) pcap.pcap_dump_flush(pdumper) pcap.pcap_dump_close(pdumper) pcap.pcap_close(hpcap)
def dump(): hpcap = pcap.pcap_open_dead(ptypes.LINKTYPE_ETHERNET, 65535) pdumper = pcap.pcap_dump_open(hpcap, './test.pcap') data = b'11111111111111111111111111111111111111111111' pkthdr = ptypes.pcap_pkthdr() pkthdr.caplen = len(data) pkthdr.len = len(data) now = time.time() pkthdr.ts.tv_sec = int(now) pkthdr.ts.tv_usec = int(now * 1000 * 1000)%(1000*1000) pcap.pcap_dump(pdumper, ptypes.pcap_pkthdr_p(pkthdr), data) pcap.pcap_dump_flush(pdumper) pcap.pcap_dump_close(pdumper) pcap.pcap_close(hpcap)
def tearDownClass(cls): pcap.pcap_dump_flush(cls.pdumper) pcap.pcap_dump_close(cls.pdumper) pcap.pcap_close(cls.hpcap)