Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 96 by
daw...@un0wn.org: dpkt.dpkt.UnpackError: invalid request: ''
http://code.google.com/p/dpkt/issues/detail?id=96
What steps will reproduce the problem?
1. When I type in this line: http = dpkt.http.Request(tcp.data)
What is the expected output? What do you see instead?
I expect the script to run without any errors.
What version of the product are you using? On what operating system?
Python 2.7. The python script is meant to be cross-platform
Please provide any additional information below.
This is my code:
import dpkt, glob, pcap, socket, time
def delay():
time.sleep(0.6) # delay execution of python script
print "\n"
fileName = glob.glob("*.pcap") # finds all matching pathnames specified
for .pcap files (hardcode for now)
print "Files present:",fileName
print ""
for files in fileName:
f = open(files)
print f
delay()
pcap = dpkt.pcap.Reader(f) #@UndefinedVariable
pkt_counter = 0
pkt_counter_relevant = 0
pkt_counter_non_relevant = 0
for ts, buf in pcap:
pkt_counter += 1
eth = dpkt.ethernet.Ethernet(buf)
# check if frame type is an IP packet
if type(eth.data) == dpkt.ip.IP:
if pkt_counter > 0:
pkt_counter_relevant += 1
last_time = ts
ip = eth.data
tcp = ip.data
src = socket.inet_ntoa(ip.src)
dst = socket.inet_ntoa(ip.dst)
srcPort = tcp.sport
dstPort = tcp.dport
print "---------------"
print "- Packet #%d -" % (pkt_counter)
print "---------------"
print "Timestamp:",ts
print "Bytes:",len(buf)
print "Source IP/Port:",src,"/",srcPort
print "Destination IP/Port:",dst,"/",dstPort
# check if it's a TCP/HTTP protocol
if dstPort == 80:
delay()
print "Protocol: TCP/HTTP"
delay()
http = dpkt.http.Request(tcp.data)