Linux writing tcp packets
Results 1 to 4 of 4

Thread: Linux writing tcp packets

  1. #1
    Banned
    Join Date
    Jun 2002
    Posts
    458

    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.

  2. #2
    Banned
    Join Date
    Jun 2002
    Posts
    458
    Can't anybody help me out? Or at least point me in the right direction?

  3. #3
    Senior Member
    Join Date
    Oct 2001
    Posts
    638
    Well I got red hat 7.2 recently.
    Good stuff. Another user turns from the dark side .

    And one of the main reasons I wanted linux was because of the raw socket support.
    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.

    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.
    http://www26.brinkster.com/smirc/project/sim.html#links
    OpenBSD - The proactively secure operating system.

  4. #4
    Banned
    Join Date
    Jun 2002
    Posts
    458
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •