使用 Boost/ASIO 监听特定网络接口的所有传入数据包

Listening for all incoming packets to a certain network interface using Boost/ASIO

我在整个互联网上寻找一种方法来捕获来自某个网​​络接口的传入数据包,然后我遇到了 PCAP、TCPDUMP,我相信最常用的网络库是 Boost/Asio ,所以我想使用这个库来捕获流量,但显然没有使用原始套接字或其他 类 来侦听某个 NI 的传入数据包的示例,我将不胜感激任何帮助或示例.

我们最终发现嗅探传入数据包的最佳选择是 Libtins

libtins is a high-level, multiplatform C++ network packet sniffing and crafting library.

Its main purpose is to provide the C++ developer an easy, efficient, platform and endianness-independent way to create tools which need to send, receive and manipulate network packets.

It uses a BSD-2 license and it's hosted at github.