python-pcapng
Library to read/write the pcap-ng format used by various packet sniffers.
What it is and what it does
Python-pcapng is a pure-Python library for reading and writing pcap-ng packet capture files—the modern format used by Wireshark, dumpcap, and similar network analysis tools. It fills a gap where tcpdump and other tools struggle with pcap-ng files, and where few Python bindings existed for the format. The library parses binary pcap-ng data into block objects that represent packets, interfaces, and metadata, and can also generate valid pcap-ng files from scratch.
The library includes a strictness mode (FORBID, FIX, WARN, NONE) to control how strictly it validates pcap-ng structure during writing, allowing both strict compliance and deliberate generation of edge-case files for testing. It has no external runtime dependencies and runs on modern Python versions (3.5+), making it straightforward to integrate into network analysis pipelines, packet inspection tools, or test suites.
Use it for:
- Extract packet data and metadata from pcap-ng files captured by Wireshark or dumpcap for offline analysis.
- Generate synthetic pcap-ng files for testing network analysis tools or packet processing code.
- Convert or migrate packet capture data between formats or tools that require pcap-ng input.
- Build custom packet inspection or filtering tools that need to read modern packet capture formats.
- Validate pcap-ng file structure or repair marginal/broken capture files by re-writing with adjusted strictness.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and writes pcap-ng packet capture files, the format used by modern packet sniffers like Wireshark and dumpcap.
Yes, if you need to work with pcap-ng files in Python and have no better alternative. The library is stable (Production/Stable status), has no known vulnerabilities, and installs with zero friction. However, maintenance is aging (last release 2022-08-23, no active development), so expect no new features or bug fixes—suitable for stable, read-heavy workloads but risky for projects requiring ongoing support.
Install
python-pcapng on PyPI
pip
pip install python-pcapnguv
uv add python-pcapngpoetry
poetry add python-pcapngInstalling python-pcapng
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 2022-08-23 and the repository shows no recent activity, though it remains archived=false and the last commit is recent (2026-01-25), suggesting minimal ongoing development.
License in practice
Apache-2.0 is permissive; you can use, modify, and distribute this library freely in commercial and open-source projects, provided you include the license notice.
Quickstart
from pcapng import FileScanner
with open('/tmp/mycapture.pcap', 'rb') as fp:
scanner = FileScanner(fp)
for block in scanner:
pass # do something with the block
Verify before relying
- Performance characteristics compared to C-based alternatives or Cython ports mentioned in the description.
- Completeness of pcap-ng format support relative to the full specification.
- Whether the library handles all edge cases in real-world captures from different packet sniffers.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (~=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,452 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 483,480/month — #6,412 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_pcapng-2.1.1-py3-none-any.whl
Tags
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
psutilpsutil retrieves real-time information about…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
uvloopuvloop is a drop-in replacement for Python's…
permissive · top 1,000 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
pyzmqPyZMQ provides Python bindings for ZeroMQ…
permissive · top 1,000 on PyPI
pysharkPyshark wraps tshark (Wireshark's command-line…
permissive · top 5,000 on PyPI
pypcapPython wrapper around libpcap that lets you…
unclear · top 15,000 on PyPI
pure-pcapy3Pure-Python implementation of the pcapy API for…
permissive · top 15,000 on PyPI
scapyScapy is a Python library for forging,…
copyleft · top 5,000 on PyPI
pydivertPyDivert is a Python binding for the WinDivert…
copyleft · top 15,000 on PyPI
dpktdpkt parses and creates TCP/IP protocol packets…
permissive · top 5,000 on PyPI
rtpDecodes, encodes, and manipulates RTP…
permissive · top 15,000 on PyPI
pmd-net-protoParses, assembles, and validates network…
copyleft · top 15,000 on PyPI
dnslibEncodes and decodes DNS wire-format packets,…
permissive · top 5,000 on PyPI
arParses and reads ar archive files (.a),…
permissive · top 15,000 on PyPI