Skip to content
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

Unit test fails since version 0.999 or windows intel driver duplicates packets #749

Open
trivalik opened this issue Aug 27, 2024 · 1 comment

Comments

@trivalik
Copy link

trivalik commented Aug 27, 2024

Describe the bug
Sending packets with pcap_sendqueue_transmit lead to that on receive these packets with pcap_dispatch the packets are duplicated (default case) or not received at all. The result depends on set value by PacketSetLoopbackBehavior. The issue starts at commit a25b79c Emulate WinPcap behavior regarding looped-back packets.

To Reproduce

Running unit test of
https://github.com/klaus0x7c4/Pcap.Net/blob/8b61736a4483a08cf88fd66c7e24826e5610bdd0/PcapDotNet/src/PcapDotNet.Core.Test/PacketSendBufferTests.cs#L19

In case the test is too big, shorten the test just to TestTransmitQueueToLive(10, 60, 0.5, false);.
In case you open wireshark on the adapter, you will see also duplicate packets.

Probably does the unit test of original Pcap.Net also work, but this project is plain C#, the original not.

Expected behavior
loopback Packets are only received once.

Diagnostic information
Windows version from winver Windows 11 Version 22H2, OS Build 22621.2715

Other infos

Just the adding of SendFlags |= NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK; from a25b79c lead to this error.

Wireshark on this PC receives the packet also twice, but checking the other end of the cable via wireshark shows just unique packets.

On a fresh installed Virtual machine Win 10 22H2 / Win 11 22H2 build 22621.1702 / Win 11 22H2 build 22621.4112/ Win11 23H2 the test passes.

After test on multiple PCs with difference network adapter from different vendors, I can say it happens only on intel network drivers, realtek is not affected.

@trivalik
Copy link
Author

trivalik commented Aug 28, 2024

A solution for my use case would be to remove in NPF_BufferedWrite the SendFlags |= NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK;, To test the NPF_Write I used the test BerkeleyPacketFilterTests.NoCommunicatorConstructorTest, the result is the same, remove the SendFlags |= NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK; . I tested this change in my HyperV virtual machine, where this bug does not appear and wireshark shows the correct packet count.

@trivalik trivalik changed the title Unit test fails since version 0.999 Unit test fails since version 0.999 or intel driver duplicate packets Sep 3, 2024
@trivalik trivalik changed the title Unit test fails since version 0.999 or intel driver duplicate packets Unit test fails since version 0.999 or windows intel driver duplicates packets Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant