Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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 ?

like image 454
Pradeep Avatar asked Jun 11 '15 11:06

Pradeep


People also ask

What is Sock_raw?

Send and Receive Operations. Once an application creates a socket of type SOCK_RAW, this socket may be used to send and receive data. All packets sent or received on a socket of type SOCK_RAW are treated as datagrams on an unconnected socket.

What are socket options?

In addition to binding a socket to a local address or connecting it to a destination address, application programs need a method to control the socket. For example, when using protocols that use time out and retransmission, the application program may want to obtain or set the time-out parameters.

What are raw packets?

Raw packet is used when you dont have any, the first bytes captured are directly the IPv6 or IPv4 header. Raw IP; the packet begins with an IPv4 or IPv6 header, with the "version" field of the header indicating whether it's an IPv4 or IPv6 header.

What is Sock_stream in socket programming?

SOCK_STREAM. Provides sequenced, two-way byte streams with a transmission mechanism for stream data. This socket type transmits data on a reliable basis, in order, and with out-of-band capabilities. In the UNIX domain, the SOCK_STREAM socket type works like a pipe.


1 Answers

Raw mode 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

Click here raw socket man page

you can fine a good example Click here

and a tutorial Click here

like image 164
SHASHI BHUSAN Avatar answered Sep 19 '22 23:09

SHASHI BHUSAN