Raw sockets

Ben Ainsworth ed_play at yahoo.co.uk
Thu Dec 20 15:44:34 EST 2001


> [1] If you're going to use tcp, then why do you need raw sockets?

I've got the impression that you need the tighter control over TCP
that raw
sockets allows, as you only send a SYN packet (and an RST) and don't
complete the three way handshake. 

> [2] Since traceroute relies on the icmp messages returned when the
>    TTL goes to zero, I'm not sure how you could write a traceroute
>    without icmp.

Well apparently it's been done:
http://michael.toren.net/code/tcptraceroute/
, but not for python / windows.

Obviously the replies are in icmp (except the last), but from what
little I know of network security, tcp is the least blocked protocol,
particularly via port 80.


> [3] Raw sockets using Python are pretty much the same as raw sockets
>   using C or any other language -- you need to manually wrap your
>   data up in the headers that the tcp/ip layers normally wrap for
>   you (including checksums). I think there's a 'ping' in python
>   floating around that uses raw sockets to make icmp packets.
>   You might search the archives.

Thanks, I've found a C tutorial on raw sockets, and a python version
of ping. Does anyone have a copy of Jeremy Hylton's code? The link at
http://www.python.org/~jeremy/python.html is dead.

Ben Ainsworth



More information about the Python-list mailing list