[Twisted-Python] sending out RAW IP packets using sockets

Lars Reimann lars.reimann at googlemail.com
Mon May 4 14:00:33 EDT 2009


this question may be a bit off-topic, but nevertheless I am stuck atm.

I'm trying to send out RAW IP packets (incl. full header) which i
obtained previously using packet capture.

It has to be RAW IP packets because I want the kernel to do ARP lookup
stuff, etc for me . So an obtained packet should go through the normal
lookup process.

I've tried to use RAW sockets in python for this, but it constantly
tells me, that the "Protocol (is) not supported" using this code:


self.rawserver = socket.socket(socket.AF_INET, socket.SOCK_RAW, self.proto)
      self.rawserver.bind((self.interface, self.proto))


I would then simply 'send' the packets over that raw socket.

I've tried to specify IPPROTO_RAW, and others for 'self.proto' but my
python 2.5 won't accept this because they are unknown.

My question is why that error occurs and how I can enable my program to
send out RAW IP packets. Maybe the twisted framework could be helpful.
As I am new to network programming I ask for your help.

links to examples would also be greatly appreciated.


More information about the Twisted-Python mailing list