npcap icon indicating copy to clipboard operation
npcap copied to clipboard

Sometimes pcap_sendpacket takes longer in some situations

Open s5suzuki opened this issue 3 years ago • 4 comments

I have noticed that pcap_sendpacket sometimes takes a long time while playing a video in Windows Media Player or any other video player. Usually, this function finishes in about 20us, but it frequently takes up to 1000us while playing video. The same problem occurs when opening sites such as YouTube with Chrome, while normal browsing does not cause the problem. I just executed the "Examples-pcap/sendpack" example included in the Npcap SDK.

Interestingly, this problem occurs with "Realtek PCIe GBE Family Controller" and "Intel(R) Gigabit CT Desktop Adapter," but not with "ASIX AX88179 USB 3.0 to Gigabit Ethernet Adapter".

Does anyone have any idea what might be causing this problem?

Diagnostic information

  • Windows version: Windows 11 Version 21H2, OS Build 22000.832)
    • I have confirmed that the same problems occur on other Windows 10 and Windows 11 machines.
  • npcap version: 1.70
  • npcap SDK version: 1.13

s5suzuki avatar Jul 29 '22 06:07 s5suzuki

We have a similar issue, using pcap_sendqueue_transmit. Sending a paquet will sometimes (randomly) take more than 20 seconds instead of a few milliseconds. The circonstances of this bug are not really clear. One thing we did that seemed to help is to stop using the last milliseconds of the current second when we use the transmit function, like in the following code:

//avoid pcap end second bug
ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
if (ts % 1000 > 900)
	std::this_thread::sleep_for(std::chrono::milliseconds(1000 - (ts % 1000)));
unsigned int res = pcap_sendqueue_transmit(mp_adapter, squeue, TRUE);

It helps, but doesn't really solve the issue. Has anyone else encountered this?

Diagnostic information

  • Windows version: Windows 10 Version 21H2 / Windows 10 Version 22H1
  • npcap version: 1.60

SylvainSalle avatar Jul 29 '22 10:07 SylvainSalle

As @kayoub5 mentioned, I've also a latency issue with pcap_sendpacket, mine is called by sharppcap. Tried different NIC and different PC but things does not change.

lk-davidegironi avatar Jan 02 '23 16:01 lk-davidegironi

FYI, I have noticed that this problem also occurs when playing a local video and when Microsoft Teams is running (even in the background).

s5suzuki avatar Jan 03 '23 06:01 s5suzuki

FYI, I have noticed that this problem also occurs when playing a local video and when Microsoft Teams is running (even in the background).

Thanks you! Not my case unluckily

lk-davidegironi avatar Jan 03 '23 11:01 lk-davidegironi