Skip to main content

PyPCAPKit -- Comprehensive Network Packet Analysis Library

For technical and maintenance information, see the Official Documentation.

PyPCAPKit is an open-source Python library for parsing, constructing and analysing network packets and PCAP files, with DictDumper as its formatted output dumper.

Unlike popular PCAP extractors such as Scapy, DPKT and PyShark, pcapkit reports more detail about each packet through a more Pythonic interface. Where that depth is not needed, the same interface also drives third-party extraction engines.

The whole project requires Python 3.8 or later. CI supports 3.11 to 3.15, and still tests the end-of-life 3.8 to 3.10 without letting a failure block anything.

Installation

pip install pypcapkit

Or from a clone, for the latest version and for development:

git clone https://github.com/JarryShaw/PyPCAPKit.git
cd PyPCAPKit
pip install -e .

The extraction engines and plug-ins are optional extras:

pip install pypcapkit[DPKT]         # or Scapy, PyShark, PyPCAPFile, PyPCAP, PCAP_CT
pip install pypcapkit[crypto]       # ESP payload decryption
pip install pypcapkit[cli]          # command line interface
pip install pypcapkit[all]          # core addons only: cli + crypto + NGAP (pycrate)

Engines are on demand; all bundles only the core addons the library needs for full functionality. Some engines also need something beyond pip install -- a tshark binary, a C compiler, libpcap headers, or an older interpreter -- and pypcap/pcap-ct must never be installed together. The engine prerequisites give each constraint and its reason. pcapkit enforces them in code: asking for an engine that cannot run in the current environment warns with the cause and falls back to its own parser.

Usage

>>> import pcapkit
>>> extraction = pcapkit.extract('in.pcap', nofile=True)
>>> len(extraction.frame)
6
>>> frame = extraction.frame[0]
>>> str(frame.protochain)
'Ethernet:IPv6:IPv6_ICMP'
>>> frame.info.time
datetime.datetime(2017, 11, 19, 15, 49, 5, 471719, tzinfo=datetime.timezone.utc)
>>> frame.payload.payload.src
IPv6Address('fe80::a6:87f9:2793:16ee')

The output is from the committed examples/captures/in.pcap, so it is reproducible from a clone.

Reassembly, TCP flow tracing and the engine are keyword arguments to the same call:

>>> scapy = pcapkit.extract('in.pcap', nofile=True, engine='scapy')
>>> reasm = pcapkit.extract('in.pcap', nofile=True, reassembly=True, ipv6=True)
>>> flows = pcapkit.extract('in.pcap', nofile=True, trace=True, tcp=True)
>>> len(flows.trace.tcp)
2

More examples, including the command line interface, are in How to ....

Documentation

The official documentation is the reference. Pages worth knowing by name:

Page What is in it
API reference Every module, protocol and constant
Module structure What each subpackage is for
Engine comparison Which engines exist, which Python versions they run on, what each needs installed, and measured speed per packet
Engine support What each engine does not support, and how the gap is surfaced
Installation Extras and the local development setup
Testing Running the suite, and the sample captures it needs
How to ... Worked examples, library and CLI
Extensions Registering your own protocols, engines and dumpers

The newest changelog entry is in CHANGELOG.md, which links to the full history, and contribution guidelines are in CONTRIBUTING.md.

Metadata

Release files for pypcapkit 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypcapkit 1.5.1
File Size Uploaded Provenance Actions
pypcapkit-1.5.1.tar.gz 4.7 MB Without provenance Details for pypcapkit-1.5.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pypcapkit 1.5.1
File Actions
pypcapkit-1.5.1-pp311-none-any.whl PyPy 3.11 none any Details for pypcapkit-1.5.1-pp311-none-any.whl
pypcapkit-1.5.1-pp310-none-any.whl PyPy 3.10 none any Details for pypcapkit-1.5.1-pp310-none-any.whl
pypcapkit-1.5.1-cp315-none-any.whl CPython 3.15 none any Details for pypcapkit-1.5.1-cp315-none-any.whl
pypcapkit-1.5.1-cp314-none-any.whl CPython 3.14 none any Details for pypcapkit-1.5.1-cp314-none-any.whl
pypcapkit-1.5.1-cp313-none-any.whl CPython 3.13 none any Details for pypcapkit-1.5.1-cp313-none-any.whl
pypcapkit-1.5.1-cp310-none-any.whl CPython 3.10 none any Details for pypcapkit-1.5.1-cp310-none-any.whl

Total release size: 16.3 MB

Release files / pypcapkit-1.5.1.tar.gz

Download URL pypcapkit-1.5.1.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
acfa38c28a89ee917d6267fc4794b0430f640902be2362692c4947cd0d7c2615
BLAKE2b-256 checksum
How to use checksums
22dfff582159378e28977cbe5f44be689778ee76d5c39f43bbc8e7d562a55676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-pp311-none-any.whl

Download URL pypcapkit-1.5.1-pp311-none-any.whl
Size 1.9 MB
Tags PyPy 3.11
SHA-256 checksum
How to use checksums
6884a2b016294e0a77c71890b8a92b94c2a6d9966d4bceab198242a3c012dd17
BLAKE2b-256 checksum
How to use checksums
032858bac93bf61b16274280d8c3fd862be131e302e1456dd79bba86d77043a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-pp310-none-any.whl

Download URL pypcapkit-1.5.1-pp310-none-any.whl
Size 1.9 MB
Tags PyPy 3.10
SHA-256 checksum
How to use checksums
829b31ce385a0916c885a96d303ebd58d1dd3f286de6f0ca15c4fc197529f499
BLAKE2b-256 checksum
How to use checksums
afa166e29e645e6af7e37ca2855145d8de0626108140f0d074cb638ec28ccf07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-cp315-none-any.whl

Download URL pypcapkit-1.5.1-cp315-none-any.whl
Size 1.9 MB
Tags CPython 3.15
SHA-256 checksum
How to use checksums
cd3f7b490adfba6331c64cc04f4142eae566260c2b3d7a77edc49459f1315e9a
BLAKE2b-256 checksum
How to use checksums
3bf6283e51f06b4c2a8e3690bbb75df344798574f3c929295a95acf5db197772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-cp314-none-any.whl

Download URL pypcapkit-1.5.1-cp314-none-any.whl
Size 1.9 MB
Tags CPython 3.14
SHA-256 checksum
How to use checksums
1aff824d7f4b7a0f3e23e69efbb556b588490cd1d099dcb059dd814298bf8cdc
BLAKE2b-256 checksum
How to use checksums
a15f1c1bff727e2255ac1b050f073b098605570a0fd9d5f83b743b5b1fe16639
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-cp313-none-any.whl

Download URL pypcapkit-1.5.1-cp313-none-any.whl
Size 1.9 MB
Tags CPython 3.13
SHA-256 checksum
How to use checksums
1cc8acf1414e5b124c4b14d552e8542426e9c51db5efa38c653d1fbefcbc7aa8
BLAKE2b-256 checksum
How to use checksums
a69eb412dc3c618a7ec21ed74a6ee4b3cb82411472197a80cbfb5820b9ff320d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pypcapkit-1.5.1-cp310-none-any.whl

Download URL pypcapkit-1.5.1-cp310-none-any.whl
Size 1.9 MB
Tags CPython 3.10
SHA-256 checksum
How to use checksums
4f018327f59bcb30090a5f0d543355ebdb812cd1ae3d9ceac6d3b9409be730b3
BLAKE2b-256 checksum
How to use checksums
434d501823ae1d2c7104fcc61e6c9ed8fe3289a0e5fbbf08afeeafc71253d12a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pypcapkit 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.5.1 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page