user189750
user189750

Reputation: 21

Whether UDP packets received will pass to raw sockets and whether we can print UDP header using raw sockets

This Question is about RAW SOCKETS. In the book it is given that received UDP and TCP packets are never passed to a raw socket and we cannot read the UDP and TCP headers in RAW SOCKETS and to read UDP and TCP header we should read it at "DATA LINK LAYER" .

I created a raw socket using "sfd=socket(AF_INET,SOCK_RAW,IPPROTO_UDP)" to test whether it will receive UDP packets are not and tried to print source port and destination port which are members of udp header. Program printing out the both ports i.e it's receiving UDP Packets and can read udp header.

I didn't understand what book really say's and what program is printing out . plzz help me where i am wrong.

I am working on ubuntu os.

Upvotes: 1

Views: 271

Answers (1)

SuB
SuB

Reputation: 2547

Socket created by socket(AF_INET,SOCK_RAW,IPPROTO_UDP) will receive incoming UDP packets. I should notify that some packets will not be received by this method (See here).

Upvotes: 0

Related Questions