Skip to main content

OctetRail

OctetRail is a Rust rewrite of dpkt, working toward a compatible Python API. It currently provides native offline pcap and PCAPNG readers, bounded output subsets and an experimental octetrail Python wheel. It is not a drop-in dpkt replacement.

The classic reader supports ordinary pcap 2.4, both byte orders and microsecond or nanosecond timestamps. It preserves raw packet bytes, original lengths, capture metadata and exact integer timestamp components. It has no runtime dependencies and forbids unsafe Rust.

The separate PCAPNG reader supports a measured Enhanced Packet Block subset, section-local interface clocks and explicit resource limits. The classic-PCAP writer emits validated offline records, with explicit rounding and I/O behavior. The PCAPNG writer supports one section, one interface and Enhanced Packet Blocks with bounded metadata options. Modified pcap, broad protocol decoding and a dpkt import layer are not implemented. The compatibility contract tracks these separately from import names, distribution metadata and downstream behavior. The explicit capture provider supplies the covered Python reader/writer subset without changing normal dpkt imports. The UniversalReader guide describes measured 1.9.8-style format selection over the native readers.

Ethernet, IPv4/IPv6 and opaque TCP/UDP objects can be composed and decoded offline. See the composition guide for dispatch, options, checksum update rules, resource bounds and measured compatibility limits. The IPv6 module parses and packs IPv6 and its extension headers the way dpkt 1.9.8 does, and adds explicit raw-IP version selection. The DNS module parses and packs messages and common record fields the way dpkt 1.9.8 does, without changing transport payloads or performing lookups. The HTTP module parses and packs HTTP/1.x requests and responses the way dpkt 1.9.8 does, without stream reassembly. The SIP module parses and packs SIP requests and responses the way dpkt 1.9.8 does, on the HTTP classes. The Packet base class is dpkt's, for writing your own header classes, with the checksum and hexdump helpers. The Ethernet module parses and packs Ethernet II, 802.3 LLC, Novell, 802.1Q, MPLS and ISL frames the way dpkt 1.9.8 does, with LLC, STP and IPX. The ICMP and ICMPv6 modules parse and pack those messages the way dpkt 1.9.8 does, and IPv6 decodes them. The GRE and PIM modules parse and pack those packets the way dpkt 1.9.8 does, and IPv6 decodes them. The IGMP and VRRP modules parse and pack those messages the way dpkt 1.9.8 does, and IPv6 decodes them. The Telnet module strips option negotiation the way dpkt 1.9.8 does. The ATA over Ethernet modules parse and pack AoE and its ATA and configuration commands the way dpkt 1.9.8 does, and Ethernet decodes them. The Portmap, Rx, TNS, Yahoo Messenger, SMB and RFB modules parse and pack those headers the way dpkt 1.9.8 does. The NetBIOS module parses and packs the name, session and datagram services the way dpkt 1.9.8 does. The RADIUS, RTP, STUN and TPKT modules parse and pack those messages the way dpkt 1.9.8 does. The NTP, RIP, TFTP and HSRP modules parse and pack those messages the way dpkt 1.9.8 does. The CDP, DTP and EDP modules parse and pack those packets the way dpkt 1.9.8 does, and Ethernet decodes them. The PPP and PPPoE modules parse and pack those frames the way dpkt 1.9.8 does, and Ethernet decodes them. The AH and ESP modules parse and pack those headers the way dpkt 1.9.8 does, and IPv4 decodes them. The OSPF and SCTP modules parse and pack those packets the way dpkt 1.9.8 does, and IPv4 and IPv6 decode them. The ARP module parses and packs ARP the way dpkt 1.9.8 does, and Ethernet decodes it. The HTTP/2 module parses and packs HTTP/2 frames the way dpkt 1.9.8 does. The gzip module parses and packs gzip member headers the way dpkt 1.9.8 does. The NetFlow module parses and packs NetFlow version 1, 5, 6 and 7 exports the way dpkt 1.9.8 does. The Diameter module parses and packs Diameter messages and AVPs the way dpkt 1.9.8 does. The QQ module parses and packs QQ messenger headers the way dpkt 1.9.8 does. The SCCP module parses and packs Cisco Skinny messages the way dpkt 1.9.8 does. The AIM module parses and packs OSCAR FLAP and SNAC frames and TLVs the way dpkt 1.9.8 does. The IEEE 802.11 and radiotap modules parse and pack wireless frames and radiotap headers the way dpkt 1.9.8 does. The RPC module parses and packs ONC RPC calls and replies the way dpkt 1.9.8 does. The DHCP module parses and packs DHCP messages and their options the way dpkt 1.9.8 does. The SLL, SLL2 and loopback modules parse and pack the link-layer headers of Linux cooked and null/loopback captures the way dpkt 1.9.8 does. The SSL and TLS module parses and packs records, handshakes, hellos and certificate lists the way dpkt 1.9.8 does, with dpkt's cipher suite table.

See the 0.6.2 release notes for the changes and their compatibility limits.

Use the classic-pcap reader

Install Rust with rustup. rust-toolchain.toml pins Rust 1.85.1 and its formatting and lint components. The crate declares a Rust 1.85 floor; only the pinned toolchain has been tested. Run commands from this directory.

cargo build --locked
cargo run --locked --bin pcap-read -- /path/to/synthetic.pcap
cargo run --locked --bin pcap-read -- --max-packet-bytes 1048576 /path/to/synthetic.pcap

The CLI writes JSON lines: one metadata object, then one object per packet with seconds, fraction, original_len and hex fields. Check its exit status. Output before a read error describes only the prefix processed successfully. Payload hex is for inspection and differential testing, not a performance API. The command reads a local file and does no live collection or protocol work.

The library accepts any synchronous std::io::Read:

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

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

Construction consumes the 24-byte global header. Each iterator step consumes one record. EOF and record errors are terminal; no resynchronization is tried. No seek is required. into_inner() returns the owned input at its current logical position. An input adapter such as BufReader may buffer bytes internally. Stopping early leaves subsequent records unread by the parser. Dropping the reader drops its owned input. Borrow an input with &mut to keep ownership.

The default maximum captured packet length is 16 MiB. A limit of zero permits only empty packets. Captured length must not exceed snap length or original length. Versions other than 2.4, zero snap length, out-of-range fractions and incomplete headers or payloads are errors. Unknown link types and nonzero reserved header fields are retained without interpretation. These checks deliberately differ from dpkt on some inputs. The core does not map errors to Python classes.

The parser holds at most one packet buffer and fixed headers. Memory also depends on input buffering and any outputs the caller retains. There is no process-wide memory cap, total capture-size cap, packet-count cap or wall-clock timeout. A caller-provided Read can block; the host must supply its own I/O policy.

Verify

cargo fmt --check
cargo clippy --locked --workspace --all-targets -- -D warnings
cargo test --locked --workspace
cargo test --locked --doc
cargo build --locked
python3 -m compileall -q tools python tests/python

Use separate environments for the two published reference versions. The test harness runs the reference interpreter in isolated mode and verifies its import origin and installed distribution version. Install only the hash-pinned wheels:

python3 -m venv .venv-oracle-198
.venv-oracle-198/bin/python -m pip install --require-hashes --only-binary=:all: -r tools/oracle-1.9.8.txt
python3 tools/differential.py --python "$PWD/.venv-oracle-198/bin/python"

python3 -m venv .venv-oracle-196
.venv-oracle-196/bin/python -m pip install --require-hashes --only-binary=:all: -r tools/oracle-1.9.6.txt
python3 tools/differential.py --python "$PWD/.venv-oracle-196/bin/python" --version 1.9.6

After wheel installation the harness is offline. For an offline installation, first download the pinned wheels to a local wheelhouse and add --no-index --find-links /path/to/wheelhouse to the installation commands.

The Python reader guide covers local wheel builds, isolated installation and verification commands. The capture API reference lists supported behavior and exclusions. The reader and writer guides describe streaming, timestamp, ownership and resource-limit semantics. No performance, whole-library parity or package resolver substitution is claimed.

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 0.6.2

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 0.6.2
File Size Uploaded Provenance Actions
octetrail-0.6.2.tar.gz 410.5 kB With provenance Details for octetrail-0.6.2.tar.gz

Built distributions (wheels)

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

Total release size: 3.9 MB

Release files / octetrail-0.6.2.tar.gz

Download URL octetrail-0.6.2.tar.gz
Size 410.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e2ad8d0cc7f9942c31cf53f6bfaee89c22a6bb706e2cc519ed7e8f23aabc1a59
BLAKE2b-256 checksum
How to use checksums
c014f414bb38e7d06d7e0b04f195a3d598302ed7b99341e98b033f787f660a66
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-win_arm64.whl
Size 372.8 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
5239b38f1919232b82a536d556d58a6d4b73f88a5b948b8682be187b51516f73
BLAKE2b-256 checksum
How to use checksums
5f7d327a67a0a567956d2ca63dff6d0652e3b444b90942a6ebc578a156e465c4
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-win_amd64.whl
Size 379.6 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1772c57f8ab4b1bc2350fa5d88d6b171dae9491345d42a38f1db6512ba4f808d
BLAKE2b-256 checksum
How to use checksums
e8029f6225b33e6779a792f424f86997d8cc456da262668d85a2f86969ab85f0
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-musllinux_1_2_x86_64.whl
Size 481.7 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7df185be88159665a2c84727fb06e8f5f89e255187913f66631db5e03baf5044
BLAKE2b-256 checksum
How to use checksums
208c10b77f0c3b500f1729ac9e9eec88562d7be46fdc474447556d6a366238ca
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-musllinux_1_2_aarch64.whl
Size 461.8 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
33389fd70498ca68858ed1258c32221fe83c3dfb318927157e9af841e968f00e
BLAKE2b-256 checksum
How to use checksums
32d05a87b985746946b7866fcdc2b5afe09b235f804237c9913167b067d75fd2
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 483.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
bc4dc95266f79547c7f94bd365becdf7ad5e0d40734dbd0ac6776a3c8b7a8c63
BLAKE2b-256 checksum
How to use checksums
59a6a222e52e7441055e3734162f7a0363fcc6e4fef25c44e8f23ad298c37202
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 464.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e090ed17ab77c6fe92c17c56fe9be700939e4baea9a76aba57d0d07cffa85be1
BLAKE2b-256 checksum
How to use checksums
d14313503441f2f9e7ea2ec8f74ba10c858ea5eeb6b7f3df58607bc8aaec0ea4
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-macosx_11_0_arm64.whl
Size 435.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0a47e66aec879462071381586978e6a76b019a4edb2fd7c45e2a73ce08cb5357
BLAKE2b-256 checksum
How to use checksums
03de2f3888625abae62418bfceebe337caccacd2b7ed458566579e21e3377d6e
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 18, 2026.

Transparency log

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

Download URL octetrail-0.6.2-cp310-abi3-macosx_10_12_x86_64.whl
Size 437.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4ff6a43c71296e92c51d021dab42d9a51b8fb2b06bcf0c0efff158a92054b27c
BLAKE2b-256 checksum
How to use checksums
01ad2ed24a7ca5b185c2cea6f85c9273b4ce33421a2404c8f49b95afc58b7685
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 18, 2026.

Transparency log

Security for octetrail 0.6.2

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-0.6.2.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 18, 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