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 snoop module reads and writes snoop capture files the way dpkt 1.9.8 does. The H.225.0 module parses and packs H.323 call signaling the way dpkt 1.9.8 does. The ASN.1 module decodes BER the way dpkt 1.9.8 does. The BGP module parses and packs BGP-4 messages the way dpkt 1.9.8 does. The MRT module parses and packs MRT routing records 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.7.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.7.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.7.2
File Size Uploaded Provenance Actions
octetrail-0.7.2.tar.gz 455.0 kB With provenance Details for octetrail-0.7.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for octetrail 0.7.2
File Actions
octetrail-0.7.2-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for octetrail-0.7.2-cp310-abi3-win_arm64.whl
octetrail-0.7.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for octetrail-0.7.2-cp310-abi3-win_amd64.whl
octetrail-0.7.2-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for octetrail-0.7.2-cp310-abi3-musllinux_1_2_x86_64.whl
octetrail-0.7.2-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for octetrail-0.7.2-cp310-abi3-musllinux_1_2_aarch64.whl
octetrail-0.7.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.7.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
octetrail-0.7.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for octetrail-0.7.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
octetrail-0.7.2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for octetrail-0.7.2-cp310-abi3-macosx_11_0_arm64.whl
octetrail-0.7.2-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for octetrail-0.7.2-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 4.1 MB

Release files / octetrail-0.7.2.tar.gz

Download URL octetrail-0.7.2.tar.gz
Size 455.0 kB
Tags Source
SHA-256 checksum
How to use checksums
32d0c88a37359b7607d3de8b29e6be23a6c941e37d3e6514dd8c82c751fe64c4
BLAKE2b-256 checksum
How to use checksums
025346f80bc3e0dc58f2fe85e7166c20a5804b451d86fa267993c81da25fbb9e
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.7.2-cp310-abi3-win_arm64.whl

Download URL octetrail-0.7.2-cp310-abi3-win_arm64.whl
Size 392.0 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
dc4f3986858faf4beb76615a000236efc6dca183db3b14d4392c3bad8cef148d
BLAKE2b-256 checksum
How to use checksums
70dc2b37f1a68a72bcf1d9a410f4895206ff59595c2af93bc45d615819836a38
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.7.2-cp310-abi3-win_amd64.whl

Download URL octetrail-0.7.2-cp310-abi3-win_amd64.whl
Size 398.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
75d1dc8378a00873b0d7e532f6559d7af2321bcd2ea2a0087265762cc34cf765
BLAKE2b-256 checksum
How to use checksums
cd45f22a9557dd6f30c8a5a28f96846bd56bc2e04f5d6dec43952f8b991082e7
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.7.2-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL octetrail-0.7.2-cp310-abi3-musllinux_1_2_x86_64.whl
Size 499.2 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
1f5ed8f5f812ef0a9f2e491c583377ce92a4b17420fef0b561865cb90a673dbb
BLAKE2b-256 checksum
How to use checksums
4e147d143c8f0a23d0da0e3528e3387ed5fc807c5a77e7035b726d3163cc82a7
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.7.2-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL octetrail-0.7.2-cp310-abi3-musllinux_1_2_aarch64.whl
Size 479.7 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
69e02d9b6089079fda8fb9a6c04dce7c98bdaa74512d88410124becb2cbd7ab2
BLAKE2b-256 checksum
How to use checksums
b46c1304d60ba76b57f7cdedfc2a82225a722612afa6c907e48a6206dc17b73d
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.7.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL octetrail-0.7.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9009c80b30ddf79e55eb8ed3a420f5f473a933ea115f3318bac630f361d7b9a7
BLAKE2b-256 checksum
How to use checksums
c998774dab9b45aa349baea494be47f0a6514481a761260671da6390c78f0b7c
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.7.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL octetrail-0.7.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 482.6 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
27295cddb0dd8d0b916aa50ef312a01bfa968350e8d3b8cc5ab748b5d538bbf1
BLAKE2b-256 checksum
How to use checksums
6bc279f06c1e31c04f424132277ce111f019f0736fd58284231328ede3de97d9
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.7.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL octetrail-0.7.2-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
f69047f14b84e92419166320eb3053bf1b83aa86048a2e56034c379d0c88ff77
BLAKE2b-256 checksum
How to use checksums
5b1d82e7c2ff04384d809a49446488c40ec8e97c4ac30b152fe277e6f8b8fbab
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.7.2-cp310-abi3-macosx_10_12_x86_64.whl

Download URL octetrail-0.7.2-cp310-abi3-macosx_10_12_x86_64.whl
Size 455.4 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bd5b3a1c4d7847144a1152b00aff5db380573cedc4aea644d43514c0d3a6718e
BLAKE2b-256 checksum
How to use checksums
60ff7b760e9758e927d33c3c171d776bbce09bae6d0f78da0fc4c05acecbca0d
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.7.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.7.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