-
Notifications
You must be signed in to change notification settings - Fork 524
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
pcap_next_ex still have timeout even when pcap_set_immediate_mode #748
Comments
The NPF driver documentation says
which seems to suggest that a small value will cause packets to be delivered as soon as they're received, which is what immediate mode means. If that's not sufficient to cause the NPF driver to wakeup userland as soon as a single packet arrives, whatever else is required needs to be done at activate time as well. If 0 isn't an appropriate "small value", it needs to use another value - 1? |
How to change its value? I have tried this by replacing pcap_set_immediate_mode(1) with pcap_setmintocopy(0 or -1 or 23333), but it seems not work, just like it's never been called. |
By changing libpcap. My comment isn't "this is how to fix the problem by changing your program", this is "how to fix the problem by changing Npcap", which probably means "by changing Npcap's libpcap component".
That indicates that setting the minimum-to-copy isn't sufficient to make immediate mode work, as I suggested, in my earlier comment, might be the case. |
Describe the bug
In my test program, I opened a TAP adapter using pcap_create(), and pcap_set_timeout() to set timeout which should have no effect due to the following immediate mode, and pcap_set_immediate_mode(), then pcap_activate().
But when I use pcap_next_ex() to poll a received packet, there is still a timeout waitting in immediate mode. I expect it should return immediately, even if no packets are available.
When I set timeout to
-1
which is not allowed in the document, the pcap_next_ex() become immediate. But the side effect is pcap_loop() thread takes too much CPU.I didn't mixed pcap_next_ex() and pcap_loop() in one program, just init two ways with same configuration.
Diagnostic information
The text was updated successfully, but these errors were encountered: