Skip to main content

Fast zero-copy packet creating and parsing module

Project description

A fast and simple packet creation and parsing lib for Python, currently nothing more then a proof of concept. Inspired by both the python pypacker library and Rust’s pnet,

Design

Built around trying to minimize copying data by taking advantage of memoryviews for fast slicing and zero copy memory operations.

This library takes either a bytes or bytearray object and parses out various protocols in a similar fashion to the Rust library. The resulting packet objects can be inspected, or, in the case its backed by a bytearray, also written to. In this case, the backing memory is immediately updated.

Instead of mapping packet fields to attributes, I expose them instead with a collection-like API. This is my personal taste, as I don’t like how autogenerated attributes end up with akward names that can overlap with Python keywords.

Performance

Initial testing on my machine has shown that this library is about twice as fast at parsing packets, but I haven’t determined yet if this can be attributed to design differences, or if I’m just simply doing less.

TODO

This is one part of a slew of network inspecting code I’m releasing.

  • rich BPF support and mini-language
  • asyncio support for raw sockets and packet capturing
  • asyncio based dhcp server and client library

Project details


Release history Release notifications

This version
History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pnet-0.0.1.tar.gz (9.6 kB) Copy SHA256 hash SHA256 Source None Aug 8, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page