Skip to main content

Network packet-creator and packet-capturer module

Project description

netpacket, a Python module written in CPython

Build Status

netpacket is a packet-creator module that supports ethernet, ARP, IPv4, IPv6, ICMPv4, TCP, UDP and DHCPv4. It also contains a packet-capturer called ppcap (Python pcap). The project contains the raw CPython bindings, and a wrapper library written in Python, which can be found in the directory “netpacket”.

The module tries to be as user-friendly as it can be, leaving tasks like big-endian and little-endian fields to the module itself, the programmer only has to fill in the fields without concerning himself about it.

Note concerning IPv4 and IPv6

IPv4 and IPv6 is the same class, but the programmer will be jailed into IPv4 or IPv6 usage based on an argument passed to the IP class or protocol classes above. IPv4: 0x0800, IPv6: 0x86dd. IPv4 is already default, and no argument needs to be passed.


obj = _netpacket.udp()
obj = _netpacket.udp(0x86dd)

<_netpacket.udpv4 object at 0x7fbff03e3510> <_netpacket.udpv6 object at 0x7fbff03e3570>


# Install libpcap dependency (using gentoo@portage-tree)
emerge --ask net-libs/libpcap --quiet-build
# Install libpcap dependency (using archlinux)
pacman --sync core/libpcap
# Build
python build
# Build and install
python install


All examples can be found in the directory “examples”. Docstrings is also available for very protocol class and the ppcap class.

Platforms supported

netpacket for now only supports Linux, but will support the Unix variants and Mac OS X once the BPF (Berkeley Packet Filter) device implementation is coded in.

Python versions supported

netpacket only supports Python3, and will never have any support for Python2.

Things that will be present in later stages

  • IPv4 options.
  • IPv6 options.
  • TCP options.
  • Application-layer classes:
    • DNS.
    • HTTP.

Project details

Download files

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

Files for netpacket, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size netpacket-0.1.2.tar.gz (35.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page