June 22nd, 2002, 06:07 AM
Linux writing tcp packets
Well I got red hat 7.2 recently. And one of the main reasons I wanted linux was because of the raw socket support. I was wondering if anybody could help me figure out how to write my own tcp sockets and how to utilize raw socket support. I know that exists I just don't know how to use it. Thanx for the help.
June 22nd, 2002, 07:26 AM
Can't anybody help me out? Or at least point me in the right direction?
June 22nd, 2002, 07:46 AM
Good stuff. Another user turns from the dark side .
Well I got red hat 7.2 recently.
What do you mean by "raw socket support"? You can create TCP/UDP apps in Linux and Windows providing that you include the right libraries. Under Windows, you have to include winsock.h and under Linux there's a few that you have to include such as sys/socket.h, sys/types.h, netinet/in.h... The good thing is that the Winsock library was modelled on the original BSD socket libraries so most of the calls have similar names and parameters. A lot of the time the Winsock types are just typedefs of the original *nix library types. So socket programming in Windows and Linux isn't very different.
And one of the main reasons I wanted linux was because of the raw socket support.
If you actually mean raw socket support by definition, then that's something slightly different. When you create a socket, you can define it as SOCK_STREAM, SOCK_DGRAM or SOCK_RAW. I think that there's another couple of types but these haven't been implemented for anything yet. Note: not all Winsock.dlls have support for SOCK_RAW sockets but most do from what I've read.
SOCK_STREAM = TCP (onnection oriented)
SOCK_DGRAM = UDP (connectionless)
SOCK_RAW = used to handle packets of a type that the kernel doesn't explicitly support (eg. ICMP)
The kernel code doesn't have functions that explicitly handle packets other than TCP/UDP. But in order to be TCP/IP compliant it has to be able to handle packets of other protocols. So anything other than TCP/UDP is handled as SOCK_RAW. If you're writing an app that uses SOCK_RAW sockets, you must been running as root. This is why the ping program is a setuid program under *nix.
I know this probably doesn't help much but you really need to do some reading on this stuff. It's a pretty broad area.
I was wondering if anybody could help me figure out how to write my own tcp sockets and how to utilize raw socket support. I know that exists I just don't know how to use it. Thanx for the help.
OpenBSD - The proactively secure operating system.
June 22nd, 2002, 07:54 AM
Sorry, it was my spelling error that was at fault. I did not mean tcp sockets, I meant tcp packets. I know that windows keeps you away from the temptation of taking total control of your tcp packets by writing in most of it for you, and I heard that in linux you can take control, and right everything in tcp packets. I wanted to experiment with things like spoofing my IP address, and changing some info in tcp packet headers and seeing what the end result it. Thanks for the help though smirc. And SOCK_RAW is what I need here.