Issue 81 in dpkt: PCAP paser error

717 views
Skip to first unread message

dp...@googlecode.com

unread,
Nov 3, 2011, 1:13:29 PM11/3/11
to dp...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 81 by rrpo...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

What steps will reproduce the problem?
1. running pcap parser
2.
#!/usr/bin/env python2

import dpkt # Framework for parsing packets, use python 2.6
import sys

try:
file = open(sys.argv[1], 'rb')
#print sys.argv[1]
pcap = dpkt.pcap.Reader(file)
#print pcap
lines = 0
for ts, buf in pcap:
#print pkts, len(buf)
eth = dpkt.ethernet.Ethernet(buf)
ip = eth.data
tcp = ip.data
lines = lines +1
print lines
if tcp.dport == 80 and len(tcp.data) > 0:
http = dpkt.http.Request(tcp.data)
print http.uri

file.close()

except ValueError:
print "Could not open file!"


What is the expected output? What do you see instead?
Traceback (most recent call last):
File "pcapParser.py", line 17, in <module>
tcp = ip.data
AttributeError: 'str' object has no attribute 'data'

What version of the product are you using? On what operating system?
1.7

Please provide any additional information below.
n/a


dp...@googlecode.com

unread,
Nov 3, 2011, 3:27:17 PM11/3/11
to dp...@googlegroups.com

Comment #1 on issue 81 by rrpo...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

Ok, figures this one out. Now I'm just trying to print all known
attributes of tcp or udp. It keeps failing because it finds a none IP
based packet. I need a one liner that prints everything except arp.

dp...@googlecode.com

unread,
Jul 2, 2012, 10:30:33 AM7/2/12
to dp...@googlegroups.com

Comment #3 on issue 81 by engn...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

i have a same error. how can i fix this ?
i m using python 2.7
my operating system , windows7 64bit


dp...@googlecode.com

unread,
Jul 2, 2012, 10:32:23 AM7/2/12
to dp...@googlegroups.com

Comment #4 on issue 81 by engn...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

my error message is :

if tcp.dport == 80 and len(tcp.data)> 0 :
AttributeError : 'ICMP' object has no attribute 'dport'

dp...@googlecode.com

unread,
Jul 28, 2013, 9:11:45 PM7/28/13
to dp...@googlegroups.com

Comment #5 on issue 81 by agruns...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

I have a similar problem running the dpkt tutorial, but the error I get
involves tcp.dport and str object not having an attribute...

if tcp.dport == 80 and len(tcp.data) > 0:
AttributeError: 'str' object has no attribute 'dport'


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

dp...@googlecode.com

unread,
May 2, 2014, 1:50:26 PM5/2/14
to dp...@googlegroups.com

Comment #6 on issue 81 by amanroya...@gmail.com: PCAP paser error
http://code.google.com/p/dpkt/issues/detail?id=81

SAMPLE outputfor same issue:
62492
41325
42921
22
62493
41325
42922
22
42923
22
42924
22
Traceback (most recent call last):
File "C:\Users\aman\parse.py", line 8, in <mod
ule>
tcp = ip.data
AttributeError: 'str' object has no attribute 'data'

CODE:

import dpkt
import sys
f = open('cap1.pcap','rb')
pcap = dpkt.pcap.Reader(f)
for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
ip = eth.data
tcp = ip.data
print ip.id
print tcp.sport
Reply all
Reply to author
Forward
0 new messages