read packets

rdpcap(filename, count=-1 )

reads a pcap file and returns the list of read packets. If count is positive, only the first count packets are read.

rdpcap("ike.cap")
<ike.cap: UDP:45 TCP:0 ICMP:0 Other:0>
rdpcap("ike.cap", count=10)
<ike.cap: UDP:10 TCP:0 ICMP:0 Other:0>

write packets

wrpcap(filename, pkt, linktype=None)

Write a packet or list of packets to a pcap file. linktype can be used to force the link type value written into the file.

wrpcap("my.pcap", packet-list)

Quelle