Issue reading packets from a pcap file. dpkt
Posted
by Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-03-22T00:09:10Z
Indexed on
2010/03/22
0:11 UTC
Read the original article
Hit count: 917
I am running the following test script to try to read packets from a sample .pcap file I have downloaded.
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?
© Stack Overflow or respective owner