nmap / nmap/npcap

pcap_next_ex still have timeout even when pcap_set_immediate_mode

Open
#748 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.6k
Forks
592
PR merge metrics
No merged PRs in 30d

Description

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

  • Windows 11 Version 23H2, OS Build 22631.4037)
  • Npcap 1.79
  • TAP-Windows 9.9.2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report on Windows 11 with Npcap 1.79 using pcap_create(), pcap_set_timeout(), pcap_set_immediate_mode(), pcap_activate(), and pcap_next_ex(). Trace how immediate mode and timeout settings are handled for TAP adapters, comparing pcap_next_ex() with pcap_loop(). Done means the documented configuration returns promptly when no packet is available without causing excessive CPU use in the loop case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.