-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for immediate mode #23
Comments
The need for be able to set the immediate flag has become more urgent when using the latest libpacp library in linux. |
@csavoie You're saying this is possible now with the current code base or you're just elaborating on how it should be done? |
@brifordwylie I have reproduced this problem in sles12 sp2 which has updated the libpcap package to 1.8.1. I have a python script that snoops for vrrp packets in a closed network. If it is first system online, it will wait forever for a packet even though I set a timeout 60 seconds. I traced it down to the change in behavior of the timeout parameter for pcap_open_live(). |
@csavoie just to be explicit. Let me restate the feature request with example code :) With the pypcap module (for instance) you can set the immediate flag to true and this code will immediately begin printing packets as they arrive:
The equivalent code with pcapy will often wait a couple minutes (based on traffic volume) to start printing out packets.
So the feature request is to return as soon as you get a packet (not wait for some pcap buffer to fill up.. or whatever is causing the long delay before starting...). Version info:
|
On further inspection of the code and issue#572, it looks like pcapy is unable to implement the changes that I'm looking for. In Linux, the libpcap library in 1.8.1 has a slightly different behavior when it comes to the use of the timeout parameter in open_live() function. In the older version, the timeout would force the next() function to wait until it received a packet for the timeout value from open_live(). |
@csavoie it's clear at this point that you have a different issue/feature request, so perhaps open another issue for that. I'd like to keep this feature request focused on this particular requested feature, basically an immediate return when a packet arrives. |
If you want libpcap to deliver packets as soon as they arrive, you have to turn on immediate mode, and, in the general case, that means using So, if you want an immediate return when a packet arrives, and want to support that in a portable fashion, you'll either need to export (As for the timeout, libpcap has never guaranteed, in its API contract, that the timeout is guaranteed to trigger before any packets have arrived; whether it triggers before any packets have arrived depends on the OS (libpcap being a wrapper around the very-different capture mechanisms on different OSes) and, in the case of Linux, it also depends on the kernel version.) |
Great python module, thanks for making it available to the public. Wondering if you could add an option (defaulted to False) to set immediate mode (no buffering of packets). Several of the other python wrappers for libpcap have an immediate flag.
The text was updated successfully, but these errors were encountered: