Hello everyone, I've just started using the pypcap and dpkt modules and tried the code on google code for pypcap and I get nothing.

Heres the code I used:

import dpkt, pcap
pc = pcap.pcap()
pc.setfilter('icmp')

for ts, pkt in pc:
     print `dpkt.ethernet.Ethernet(pkt)`

I think this is suposed to print all the ICMP packets that are caught on the wire, but I get nothing, even when I ping something.

Theres almost no documentation(that I can find) so I'm unsure what I'm doing wrong. Hopefully someone here can shed some light on this.

Also if someone knows of a tutorial that explains the pypcap module, I would be very happy. I've seen this one and am not getting much from it.

http://jon.oberheide.org/blog/2008/08/25/dpkt-tutorial-1-icmp-echo/

Thanks

EDIT: Also, I'm using python 2.5

Edited 6 Years Ago by shaqywacky7: n/a

Make sure you are the root! In C program I have had the same problem when I run the program as common user, but I got the right result when I sudo it.

I'm on windows, so I don't think thats the problem.

Hah, I think that might be your exact problem, especially if you're on Vista. Try a good old 'Run as Administrator.' And maybe implement something like so:

import os

if os.geteuid() != 0:
  print "You must be root to run this script."

Sorry for the late reply, I checked and I am administrator.

I tried your code just to make sure, but I get an error. Its nothing with your code just my installation, I think.

One thing though, is the administrator account that you get to by going into safe mode have the same privileges as an account that you create as an administrator.

This article has been dead for over six months. Start a new discussion instead.