Scapy[via LtU] is a domain specific language for manipulating network packets. Actually, it's a thin wrapper around a Python read-eval loop and all the better for it.
Also, it makes for a very neat Python packet manipulation library. Have a look at the homepage (linked to above) for a transcript demonstrating some of its neat little features.
% python scapy.py Welcome to Scapy (0.9.11.1beta) >>> net = Net ("127.0.0.0"/24) >>> list = IP (src = Net) >>> for x in list: ... print repr (x) ... <snip> <IP src=127.0.0.246 |> <IP src=127.0.0.247 |> <IP src=127.0.0.248 |> <IP src=127.0.0.249 |> <snip> >>> Ether()/IP()/TCP()/"123"