Somewhat related: pcapy is a useful Python library for network packet handling. We used it recently in a project after evaluating it and a few others (not very thoroughly, though). dpkt is useful too. pcapy can read from a live stream or from a packet capture file (.pcap format).
I've found pyshark to be great too, especially for reading from a pcap. Scapy is great but has too many performance issues.
Libtins – High-level and multiplatform C++ network packet sniffing and crafting
21–23 of 23 posts
Re: Libtins – High-level and multiplatform C++ network packet sniffing and crafting
#22The linked page says "High level != inefficient" and shows an example program which will print "every TCP packet". With no "if" anywhere in the code, I wondered how it knew to print only TCP packets and not others. And the answer turns out to be that it throws a C++ exception on every non-TCP packet! If most of the packets on your network are TCP, this is sort of OK. But if you have mostly non-TCP packets, this toy p…
Re: Libtins – High-level and multiplatform C++ network packet sniffing and crafting
#23The linked page says "High level != inefficient" and shows an example program which will print "every TCP packet". With no "if" anywhere in the code, I wondered how it knew to print only TCP packets and not others. And the answer turns out to be that it throws a C++ exception on every non-TCP packet! If most of the packets on your network are TCP, this is sort of OK. But if you have mostly non-TCP packets, this toy p…
If you want to do things right, you can read the docs and use the appropriate API call (like using the non throwing PDU::find_pdu, use bpf filters, etc).