Reputation: 4690
I have this python code:
import sys
import dpkt
f = file("pcaop.Pcap")
pcap = dpkt.pcap.Reader(f)
i = 0
for ts, buf in pcap:
print "Ya"
dpkt throws NeedData on the 52nd packet. The same one every time - I've checked packet 52 and it is the same as everyone else on wireshark.
What causes this?
Upvotes: 2
Views: 6443
Reputation: 2216
Solution is provided here: Python stops reading file using read
I had the same problem when dpkt.pcap was working fine under Linux but failed instantly when run in Windows.
The problem is that when a file is opened in text mode open("filename", "r")
the file is read until EOF is encountered. Thus, open("filename", "rb")
Upvotes: 5