afghanistanyn / pypcap

Automatically exported from code.google.com/p/pypcap
Other
0 stars 0 forks source link

Problems with timeout_ms at least on Windows 7 #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I captures packets in iteration mode (for ts, pkt in pc:) or through loop 
I have long delays before recieving packets. This is particularly evident when 
computer gets small amount of packets (if you set filter or network contains 
small amount of computers).

I did some research. I think problem is related to timeout_ms (to_ms for 
winpcap pcap_open_live). As far as I understand a value of 0 means no time out; 
on at least some platforms, this means that you may wait until a sufficient 
number of packets arrive before seeing any packets, so you should use a 
non-zero timeout (http://www.tcpdump.org/pcap.htm). Winpcap documentation is 
not very clear at this point.

I tried to delete lines
  elif n == 0:
    break
for loop and __next__ functions.
And all works fine.

I think this is the right approach - not break loop if timeout is reached. 
Otherwise, you can get problems with timeout_ms values different from 0.

My OS - Windows 7. I uses lastes code from svn.

Original issue reported on code.google.com by andreev....@gmail.com on 5 Oct 2010 at 4:25