I wrote a TCP/IPv4 network stack sniffing/mangling library in Python3. It overloads python dicts to work, which makes parsing and editing packets very elegant. Check it out here, it's GPL'd:
https://github.com/securitymouse/moops-public