Loopback interface on Windows: duplicate packets (inbound + outbound) captured

17 views
Skip to first unread message

Berkay Turan

unread,
Jul 29, 2025, 8:32:40 AMJul 29
to PcapPlusPlus support
When capturing traffic on the Windows using PcapPlusPlus, each localhost packet appears twice: once on the send path (outbound) and once on the receive path (inbound).
Wireshark shows only one copy, but with PcapPlusPlus I see duplicates sometimes.
However, strangely, sometimes the same code shows only one copy.
So behavior is inconsistent: sometimes duplicates, sometimes single packet.

Steps to reproduce the behavior:
1. Install Npcap (latest version)
2. Run a simple program using PcapLiveDevice to capture on `\Device\NPF_Loopback`
3. Send UDP/TCP traffic to 127.0.0.1 between two local ports
4. Observe that `onPacketArrives` is triggered twice for each logical packet

Ideally, when capturing on loopback, PcapPlusPlus should behave like Wireshark:
- Show only one copy of the packet (either inbound or outbound)
- Or provide a flag/option to suppress duplicate packets

Additionally, from my debug logs I can confirm that the **same packet arrives twice**.  
Both copies have the same src/dst IP and ports, same length, and same payload,  
but their **timestamps are slightly different**.  
The timestamp value is taken from the function provided by the PcapPlusPlus library itself.

Environment:
- OS: Windows 11
- Npcap version: 1.79 (loopback adapter installed)
- PcapPlusPlus version: 25.05 (built with MinGW)
- Compiler: MinGW-w64 GCC 15.1.0

2.png
1.png

PcapPlusPlus Support

unread,
Jul 30, 2025, 4:26:20 AMJul 30
to Berkay Turan, PcapPlusPlus support
Hi Berkay,

I'm not sure how Wireshark deduplicates the packets. PcapPlusPlus is basically a wrapper around Npcap/libpcap and exposes all packets captured by these engines.
Maybe you know how Wireshark does it?

Thanks,
PcapPlusPlus maintainer


--
You received this message because you are subscribed to the Google Groups "PcapPlusPlus support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-sup...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pcapplusplus-support/4dde0c1f-1558-4f50-bd1d-3b846ee4ab6fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages