Skip to main content

The packet module is a front-end to the struct module. It allows the user to define a packet format, and to create a Python class to represent those packets with named attributes for each packet field:

# demo: make an IP packet packer/unpacker

# IP Prototype
ipp = Prototype()
ipp.add_uint8('vhl')
ipp.add_uint8('tos')
ipp.add_uint16('len')
ipp.add_uint16('id')
ipp.add_uint16('off')
ipp.add_uint8('ttl')
ipp.add_uint8('p')
ipp.add_uint16('sum')
ipp.add_uint32('src')
ipp.add_uint32('dst')
IP = ipp.klass('IP', NETWORK)
del ipp

# ....

# create an IP packet instance from bytes
packet = IP(bytes)

# create an empty packet
packet = IP()

# access fields
print(packet.len)

# pack fields into bytes
bytes = packet.pack()

Metadata

Release files for packet 0.5

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

Source distribution (sdist)

Source distribution for packet 0.5
File Size Uploaded Provenance
packet-0.5.tar.gz 4.0 kB Without provenance Details

Release files / packet-0.5.tar.gz

Download URL packet-0.5.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
09a2d8e70b6860548a7c558f7fff7d2ab4b52275a7d0a488b3e93e876740cf6e
BLAKE2b-256 checksum
How to use checksums
d636b8c30cf6e41c9f9419e13271879b4aa6602799741a3e9de71e6331643cad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Security for packet 0.5

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

0.5 This release

1 release file 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