Search code examples
socketsunixnetwork-programming

'SOCK_RAW' option in 'socket' system call


I am new to socket programming and trying my hand on it on Linux machine (ubuntu) I am unable to understand the option 'SOCK_RAW' and want to learn about it. What is the significance of the 'SOCK_RAW' option in 'socket' system call ?


Solution

  • Raw mode (by socket type SOCK_RAW) is basically there to allow you to bypass some of the way that your computer handles TCP/IP. Rather than going through the normal layers of encapsulation/decapsulation that the TCP/IP stack on the kernel does, you just pass the packet to the application that needs it. No TCP/IP processing -- so it's not a processed packet, it's a raw packet. The application that's using the packet is now responsible for stripping off the headers, analyzing the packet, all the stuff that the TCP/IP stack in the kernel normally does for you.

    For more information see the following links:

    • here for raw socket man page
    • you can fine a good example here
    • here there is a tutorial