This project is read-only.

NoCaptureLocal not working

Sep 16, 2013 at 2:30 PM

I have a problem with receiving my own generated traffic. When I send for example an ICMP packet the function ReceivePacket() receives two packets, one is the echo (it is the packet I sent) and an ICMP reply. The problem is why do I receive the echo request packet, which I sent.

Here is the source code from the example (a bit modified):
// Open the device
            using (PacketCommunicator communicator = selectedDevice.Open(100, PacketDeviceOpenAttributes.NoCaptureLocal, 100))                                  // read timeout
                Console.WriteLine("Listening on " + selectedDevice.Description + "...");

                BerkeleyPacketFilter filter = communicator.CreateFilter("icmp");

                bool send = true;
                communicator.Mode = PacketCommunicatorMode.Capture;
                // start the capture
                Packet packet;


                    PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out packet);
                    switch (result)
                        case PacketCommunicatorReceiveResult.Timeout:
                            // Timeout elapsed
                            if (send)
                                send = false;

                        case PacketCommunicatorReceiveResult.Ok:                            
                            Console.WriteLine(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + " length:" +
                            throw new InvalidOperationException("The result " + result + " shoudl never be reached here");
                } while (true);
I used the flag "NoCaptureLocal" but it seems that it is ingoring that flag. I do not know what can be wrong, I am working on a switch, and even one ping results in a packet loop.

Win 8 Pro 32-bit
Visual Studio 2012
Target framework : .NET Framework 4.5
pcapdotnet version

Sep 17, 2013 at 3:23 PM
Problem solved, it is a known bug in win 8, i found this in winpcap changelog:
Transmitted packets are looped back on Windows 8 even when using the flag PCAP_OPENFLAGS_NOCAPTURE_LOCAL for pcap_open.
I installed win 7, and it is working now.