Skip to main content

OctetRail

Fast packet parsing and pcap I/O for Python, written in Rust.

OctetRail started as a rewrite of dpkt and keeps dpkt's API: module names, Packet classes, fields and exceptions.

Rust handles the parts where malformed input does damage: reading and writing capture files, and loops over variable-length data such as DNS names, options and extension headers. Those run with fixed size limits, so a crafted packet cannot make them allocate or recurse without bound. The crate has no unsafe code and its parsers are fuzzed. The packet classes themselves are Python.

Versions follow semantic versioning: breaking changes come only with a new major version.

Install

pip install octetrail
from octetrail import ethernet, pcap

with pcap.open("capture.pcap") as reader:
    for timestamp, buf in reader:
        eth = ethernet.Ethernet(buf)
        print(timestamp, type(eth.data).__name__)

Capture files

Format Read Write Not supported
pcap yes yes Modified (Kuznetzov) pcap
PCAPNG Enhanced Packet Blocks One section, one interface Simple and obsolete Packet Blocks
snoop yes yes

See docs/pcapng-reader.md and docs/python-reader.md for details.

Protocols

Layer Modules
Link ethernet, llc, stp, ipx, arp, ppp, pppoe, sll, sll2, loopback, ieee80211, radiotap, cdp, dtp, edp, aoe
Network ip, ip6, icmp, icmp6, igmp, vrrp, gre, pim, ah, esp, ospf
Transport tcp, udp, sctp
Application dns, http, http2, sip, ssl, dhcp, bgp, mrt, netflow, diameter, radius, rtp, stun, tpkt, ntp, rip, tftp, hsrp, netbios, rpc, h225, asn1, telnet, gzip
Legacy aim, qq, sccp, pmap, rx, tns, yahoo, smb, rfb

Each page lists where the module behaves differently from dpkt. To write your own header classes, see docs/packet.md.

Rust

The crate can be used as a git dependency. Its supported API is capture file I/O. The protocol parsers are behind the protocols feature, which exists for the Python bindings and can change at any time.

use octetrail::{Limits, Reader};
use std::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let reader = Reader::new(File::open("capture.pcap")?, Limits::default())?;
    for packet in reader {
        println!("{} bytes", packet?.data.len());
    }
    Ok(())
}

AI-Assisted Development

OctetRail is written with help from AI coding tools. Every change is reviewed before it is merged, and protocol modules are tested against dpkt on dpkt's own test vectors and on generated and mutated inputs. The less common protocols have seen less real traffic than the core ones, so report anything that looks wrong.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md, and SECURITY.md for reporting vulnerabilities.

Sponsors

Appliku    SpeedPy

Appliku and SpeedPy support this project.

License

Original work is under the BSD 3-Clause license. dpkt attribution and its applicable upstream license are retained in NOTICE and licenses/dpkt.txt. The synthetic fixtures are original test data.

Metadata

Release files for octetrail 1.0.0

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

Source distribution (sdist)

Source distribution for octetrail 1.0.0
File Size Uploaded Provenance Actions
octetrail-1.0.0.tar.gz 481.4 kB With provenance Details for octetrail-1.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for octetrail 1.0.0
File Actions
octetrail-1.0.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for octetrail-1.0.0-cp310-abi3-win_arm64.whl
octetrail-1.0.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for octetrail-1.0.0-cp310-abi3-win_amd64.whl
octetrail-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for octetrail-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
octetrail-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for octetrail-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
octetrail-1.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for octetrail-1.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
octetrail-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for octetrail-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
octetrail-1.0.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for octetrail-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
octetrail-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for octetrail-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 4.1 MB

Release files / octetrail-1.0.0.tar.gz

Download URL octetrail-1.0.0.tar.gz
Size 481.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d7d75eb13dae60cdfb3d4e7e110f5b04c28dc726124d3d73605c6a8736be28c9
BLAKE2b-256 checksum
How to use checksums
b3c09caf446f4eaf3f5cb21470a18bb1f66a6bdfab50296123fc21d4479d2bae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-win_arm64.whl

Download URL octetrail-1.0.0-cp310-abi3-win_arm64.whl
Size 391.9 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
1ddf024d19310d44e950c4fb1838196890134004100e92b814f652df3bbd15f1
BLAKE2b-256 checksum
How to use checksums
c2805893fe124109c39f2d0005bcb509d329d29ccb215043d4dfb9863f2edb9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-win_amd64.whl

Download URL octetrail-1.0.0-cp310-abi3-win_amd64.whl
Size 399.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
25e4f81cbd1341ef7db0e861f6f84ff3b228039aa3221d4d8c9958bed4a4e586
BLAKE2b-256 checksum
How to use checksums
f0102256cf54e5857fac3c44f6cae784371caf091fabad2e8d93fada8f768e68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL octetrail-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 498.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
eca0a9a2371c57c1fc828ce7fb49f1ec47d6f4c5ed59dd52c7e6868046b35ea1
BLAKE2b-256 checksum
How to use checksums
1e8dae7707fd34039a350bd0a2c2e614e40c0be69ad4c157724d63653a07c855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL octetrail-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 479.0 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
bd3b506d600fee87e657dd6c936e56bb27b371205e13f209506c016dd08269d3
BLAKE2b-256 checksum
How to use checksums
8cc28f4b1a178b78b18b257af9371036e4c90d0f3c4f20c53697d61d3ca8c019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL octetrail-1.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3cae02322456176bb942967c077e741e8374af36bbfbed7f993960f630595434
BLAKE2b-256 checksum
How to use checksums
145a93e98d8cd9ae8e0085888cafb96156c7ffc4a9ec91ef7304d6d35b6d9d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL octetrail-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 481.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0fca57aeabcfbac0e05275e8359651bc8e23cb419410fadf0fd65267476184ed
BLAKE2b-256 checksum
How to use checksums
3ed213f056a651fb392b5e08e91eeeeca99b33e3b9f254572780e0e1ae5ecbfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL octetrail-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 453.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
845686bd419448d2fa84dca7f4d097efc2c437fef16a9a49af4e008bec9ce2aa
BLAKE2b-256 checksum
How to use checksums
e2b9ac3f69655437769ac7d1ab61e56872ed6c6381ac4071b31a874c62137c4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / octetrail-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL octetrail-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 455.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
67318167d921b61242da097408389cdf98f3b8b5dcc7e6c7f0a25ec72becfd3b
BLAKE2b-256 checksum
How to use checksums
166bce16d5a06491ddca7a3263d46ce02cc0c04cd6d974b36154d1244b140a99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for octetrail 1.0.0

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.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for octetrail-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

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.

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