Dugsong (yeah, that guy) has two python packages: dpkt and pypcap for automating packet analysis and generation.

Using the thread manager from ThreadsWithPython I hacked up a test packet spewer quicker than I expected:

#!/usr/bin/python import dpkt, sys, socket, time sys.path.append("/home/phaller/lib/") import ThreadManager, IPv4 def ping(args): sock, ip, id = args if id == None: id = 0xffff icmp = dpkt.icmp.ICMP( type=dpkt.icmp.ICMP_ECHO, data=dpkt.icmp.ICMP.Echo(id=id, seq=1, data='AAAA') ) try: start = time.time() sock.sendto( str(icmp), (ip, 1) ) sock.recv(0x100) except (socket.timeout, socket.error), e: return (ip, str(e)) return (ip, time.time() - start) def report(var_args): print var_args sock = socket.socket( socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname('icmp') ) sock.settimeout(2) m = ThreadManager.Manager(ping, report, 128) for i, ip in enumerate(IPv4.iter( sys.argv[1], sys.argv[2] ) ): m.spawn(sock, ip.rstrip(), ((i+1) & 0xffff) )

I mean really, what's the point of being root if you don't get to write some raw packets???