I am running the following test script to try to read packets from a sample .pcap
file I have downloaded. It won't seem to run. I have all of the modules, but no examples seem to be running.
import socket
import dpkt
import sys
pcapReader = dpkt.pcap.Reader(file("test1.pcap", "rb"))
for ts, data in pcapReader:
ether = dpkt.ethernet.Ethernet(data)
if ether.type != dpkt.ethernet.ETH_TYPE_IP: raise
ip = ether.data
src = socket.inet_ntoa(ip.src)
dst = socket.inet_ntoa(ip.dst)
print "%s -> %s" % (src, dst)
For some reason, this is not being interpreted properly. When running it, I get
KeyError: 138
module body in test.py at line 4
function __init__ in pcap.py at line 105
Program exited.
Why is this? What's wrong? Is there an issue with my installation? I'm using Python 2.6 on a mac