CalPack: Packets in Python Simplified

CalPack is a module that makes creating and parsing packets easy to do. This module wraps the ctypes module into an easier to use interface and enabling more features specific to working with Packets. Think of it as a way to “Transmogrify” your byte data into Packets and vice versa:

Calvin and Hobbes - Transmorgrifier


Creating a new packet is as simple as creating a python class:

>>> from calpack import models

>>> class UDP(models.Packet):
>>>     source_port = models.IntField()
>>>     dest_port = models.IntField()
>>>     length = models.IntField()
>>>     checksum = models.IntField()

Since calpak is a wrapper to ctypes, the above class is equivalent to the following ctypes.Structure:

>>> import ctypes

>>> class UDP(ctypes.Structure):
>>>     _fields_ = [
>>>         ('source_port', ctypes.c_uint),
>>>         ('dest_port', ctypes.c_uint),
>>>         ('length', ctypes.c_uint),
>>>         ('checksum', ctypes.c_uint),
>>>     ]

Interacting with the packet and it’s field is also simple:

>>> p = UDP()
>>> p.source_port = 80
>>> p.dest_port = 80
>>> p.length = 8

User Guide

If you’ve found yourself to be in a bind while using CalPack here is where you want to start. This is a set of guides on how to get and use CalPack.

CalPack User Guide

CalPack Module Docs

If you’re looking for detailed documenation for CalPack’s classes and modules then look no further! You found it!

CalPack Documentation


If you’re interested in contributing to CalPack here is where you can learn how

Contributing to CalPack

Indices and tables