# libpcap

> A portable C/C++ library for network traffic capture

Source: https://talira.ai/catalog/libpcap-qt4dvtby
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / packet capture](https://talira.ai/categories/libraries/packet-capture), [networking / packet analysis](https://talira.ai/categories/networking/packet-analysis), [languages / c cpp](https://talira.ai/categories/languages/c-cpp)
- Platforms: linux, macos, windows[^1][^2]
- Licence: BSD-3-Clause[^4][^5]
- Pricing: Free and open source[^4]
- Free tier: yes[^4]
- Self-hostable: yes[^1]
- Backed by: [The Tcpdump Group](https://talira.ai/orgs/tcpdump-group.md)
- Sponsors: Sovereign Tech Agency

libpcap is The Tcpdump Group's portable C/C++ library for capturing network traffic: one API (`pcap_*`) over each operating system's own capture mechanism, so the same program captures packets on Linux, [macOS](https://talira.ai/catalog/macos-8swyggxb.md), the BSDs, Solaris, AIX and others. Programs compile filter expressions into BSD Packet Filter programs, which run in the kernel where the platform supports it, read and write pcap savefiles (and read most pcapng files), send raw packets, put Wi-Fi adapters in monitor mode, and capture on other machines through the `rpcapd` daemon. It sits under [tcpdump](https://talira.ai/catalog/tcpdump-1mt2hf7k.md), [Wireshark](https://talira.ai/catalog/wireshark-h4r9pgqd.md) and many other capture tools, whose filter syntax and file format come from it. On Windows the capture driver comes from [Npcap](https://talira.ai/catalog/npcap-y4hznwg1.md) (or the unmaintained WinPcap), which ship their own builds of libpcap. It started at Lawrence Berkeley National Laboratory's Network Research Group and is BSD-licensed.

## Links

- Website: https://www.tcpdump.org/
- GitHub: https://github.com/the-tcpdump-group/libpcap
- Docs: https://www.tcpdump.org/manpages/pcap.3pcap.html

## Problems it solves

- capture network packets from my own C program on Linux, macOS and the BSDs with one API
- only receive the packets my program cares about by applying a filter expression in the kernel
- read and write pcap capture files from my own code
- open a pcapng capture file in a C or C++ program
- capture packets on a remote machine and process them in a program on my workstation
- send raw Ethernet frames out of a network interface from a C program
- put a Wi-Fi adapter into monitor mode from code to capture 802.11 frames
- build my own network monitoring or intrusion detection tool on a standard packet capture library
- use the same packet capture library that tcpdump and Wireshark are built on

## Features

- one capture API across Linux, macOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, Solaris, AIX, QNX and GNU/Hurd
- filter expressions compiled to BPF, run in the kernel on BPF, Linux packet socket and GNU/Hurd, otherwise in user space
- reads pcap savefiles and most pcapng files; writes and appends pcap savefiles
- sends packets with pcap_inject and pcap_sendpacket
- monitor (rfmon) mode, immediate mode, non-blocking mode and timestamp type and precision selection
- rpcapd daemon for capture on a remote machine, with TLS
- memory-mapped receive on Linux
- stable ABI: binary compatibility kept across releases (libpcap.so.1)

## Limitations

- Doesn't use Linux's eBPF mechanisms yet: on Linux it uses the packet socket's memory-mapped receive with classic BPF filters[^1]
- Can't capture on Windows by itself: Windows needs the Npcap (or unmaintained WinPcap) driver, which ships its own build of libpcap[^2]
- Doesn't read every pcapng file: it reads pcap files and most pcapng files[^3]

## Capabilities

- Has official SDKs: plan not known

## Trust

Overall: 0.33 out of 1.
Signals: backing 0.45, extensibility 0.00.

- backed by The Tcpdump Group
- sponsored by Sovereign Tech Agency

Warnings:

- GitHub activity not fetched yet

## Related

- Works with [tcpdump](https://talira.ai/catalog/tcpdump-1mt2hf7k.md)
- Works with [Wireshark](https://talira.ai/catalog/wireshark-h4r9pgqd.md)

## Alternatives

- [Npcap](https://talira.ai/catalog/npcap-y4hznwg1.md): Packet capture library for Windows

## Sources

[^1]: https://github.com/the-tcpdump-group/libpcap/blob/master/README.md (checked 20 Nov 2026)
[^2]: https://github.com/the-tcpdump-group/libpcap/blob/master/doc/README.windows.md (checked 20 Nov 2026)
[^3]: https://www.tcpdump.org/manpages/pcap_open_offline.3pcap.html (checked 20 Nov 2026)
[^4]: https://www.tcpdump.org/ (checked 20 Nov 2026)
[^5]: https://github.com/the-tcpdump-group/libpcap/blob/master/LICENSE (checked 20 Nov 2026)
