Raw Socket Communication with Data Link Layer

In the previous examples, we used the TCP and UDP protocols and added the TCP/UDP headers in the sample application. The IP header was added by the linux kernel since we had not set the IP_HDRINCL flag via setsockopt API or used IPPROTO_RAW for the protocol in the socket API. However, Raw Sockets can be […]

Using Connect and Bind on a Raw socket

Bind and connect API can be used on a RAW socket connection. However, it is normally not performed. The below snippets from the book “Unix Network Programming” describes the bind and connect operation as below: “bind can be called on the RAW socket, but this is rare. This function sets only the local address: There […]

Analysis of RAW socket IPPROTO_UDP code

The Raw socket code based on UDP protocol can be seen at this Link. We directly send the packet to the destination address via “sendto” API. As was seen in the TCP code for Raw sockets, we need to create the UDP header in the application and send the header alongwith the packet data. The […]