Generate RFC-style ASCII packet diagrams from field definitions
Project description
pktfmt
Generate RFC-style ASCII packet diagrams from field definitions.
A modern, pip-installable alternative to protocol that works on Windows and modern Python.
Installation
pip install pktfmt
Features
- 20+ built-in protocols - TCP, UDP, IP, DNS, and more
- Custom packet definitions - inline format or JSON files
- Unicode box drawing - pretty output for modern terminals
- Variable-length fields - with distinct visual styling
- Cross-platform - works on Windows, macOS, and Linux
- Modern Python - supports Python 3.8+
Quick Start
# Show a built-in protocol
pktfmt tcp
# List all available protocols
pktfmt --list
# Custom inline format
pktfmt "Type:16,Length:16,Payload:*"
# Pretty Unicode output
pktfmt udp --unicode
Usage
Built-in Protocols
$ pktfmt tcp
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Data Of|Reser| Flags | Window Size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: Options :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Custom Inline Format
$ pktfmt "Type:16,Length:16,Payload:*"
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: Payload :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
JSON File Format
pktfmt packet.json
{
"name": "MyPacket",
"fields": [
{"name": "Type", "bits": 16},
{"name": "Length", "bits": 16},
{"name": "Payload", "bits": "*"}
]
}
Unicode Output
$ pktfmt udp --unicode
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
│ Source Port │ Destination Port │
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
│ Length │ Checksum │
├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤
┊ Data ┊
└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘
Options
pktfmt <input> [options]
Options:
-l, --list List all built-in protocols
-b, --bits-per-row N Bits per row (default: 32)
-s, --style STYLE Output style: ascii, unicode, bold
-u, --unicode Shortcut for --style unicode
--no-ruler Omit the bit number header
-v, --version Show version
Field Syntax
Name:N- Fixed-width field of N bitsName:*- Variable-length field (rendered with:or┊borders)
Built-in Protocols
| Layer | Protocols |
|---|---|
| Layer 2 | ethernet, 8021q, arp |
| Layer 3 | ipv4, ipv6, icmp, icmpv6 |
| Layer 4 | tcp, udp, sctp |
| Application | dns, dhcp, ntp, tls |
| Tunneling | gre, vxlan, quic |
| Industrial | modbus, dnp3 |
Why pktfmt?
- Actually installs via pip -
protocolrequires manual setup.py installation - Works on modern Python -
protocoluses deprecateddistutils - Works on Windows - proper UTF-8 handling
- Actively maintained - PRs get merged
- Unicode support - pretty box drawing characters
- More protocols - 20+ built-in, vs ~10 in protocol
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pktfmt-0.3.1.tar.gz.
File metadata
- Download URL: pktfmt-0.3.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcecbd789a1e9c444a3ad346bdd4b79724f19720600b1471adfd53bf48162968
|
|
| MD5 |
cebf187ed1ba7eca0340ab09415344f7
|
|
| BLAKE2b-256 |
528eb2fe72b09a6cdc9709459fceb03136ed6121065f7e5aa9bb9a291c88ac24
|
Provenance
The following attestation bundles were made for pktfmt-0.3.1.tar.gz:
Publisher:
publish.yml on jordanallred/pktfmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pktfmt-0.3.1.tar.gz -
Subject digest:
fcecbd789a1e9c444a3ad346bdd4b79724f19720600b1471adfd53bf48162968 - Sigstore transparency entry: 946837984
- Sigstore integration time:
-
Permalink:
jordanallred/pktfmt@3fe9d1c9beb1d2d29c60ede26f1883a94db5e9b0 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/jordanallred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3fe9d1c9beb1d2d29c60ede26f1883a94db5e9b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pktfmt-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pktfmt-0.3.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5e04d6d1f542a5e44bdc8d1efa334fe320be5561b0f59719bb11c8a79833f84
|
|
| MD5 |
53894993b050f80c3fa33d1c3eb085d4
|
|
| BLAKE2b-256 |
d6124895d01d43cd3fb99bdedba6bb8ba492bde1818b5e6d80805f96c6f433d5
|
Provenance
The following attestation bundles were made for pktfmt-0.3.1-py3-none-any.whl:
Publisher:
publish.yml on jordanallred/pktfmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pktfmt-0.3.1-py3-none-any.whl -
Subject digest:
f5e04d6d1f542a5e44bdc8d1efa334fe320be5561b0f59719bb11c8a79833f84 - Sigstore transparency entry: 946837987
- Sigstore integration time:
-
Permalink:
jordanallred/pktfmt@3fe9d1c9beb1d2d29c60ede26f1883a94db5e9b0 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/jordanallred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3fe9d1c9beb1d2d29c60ede26f1883a94db5e9b0 -
Trigger Event:
push
-
Statement type: