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 […]
Analysis of Raw socket code with connect and Bind API
The code examples and setup are provided at the links below Raw socket code setup Raw socket code example with connect and bind API – TCP Raw socket code example with connect and bind API – UDP The TCP/UDP headers are added by the application. The output of the TCP and UDP code is provided […]
Raw Socket Example with Connect and Bind API – (UDP example)
The below code provides an example UDP code for a raw socket. The code setup and raw socket basics for the the sample code can be found at the links below Raw Socket Example with Connect and Bind API – setup Using Connect and Bind API with a Raw socket The UDP header is added […]
Raw Socket Example with Connect and Bind API
For the below code, to understand the setup requirements, once can check the link below Raw Socket Example with Connect and Bind API – setup The below code creates the TCP header and basically resends the same TCP packet over and over again in a “while 1” loop. Run the server side code first and […]
Raw Socket Example with Connect and Bind API – setup
For the current example, we will try and create two virtual interfaces for the client and server end of the TCP connection. To create the Virtual interfaces, check the output of the “ifconfig” command on the terminal and create the virtual interfaces based on the base network interface of your system. In my system, the […]
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 […]
Raw Socket Code with IPPROTO_UDP protocol
This article deals with a RAW socket example for the IPPROTO_UDP protocol. The interested reader can get an understanding of TCP/UDP headers at this link. The code is shown below Analysis of Raw Socket IPPROTO_UDP Socket code
Analysis of Raw Socket Code for IPPROTO_TCP
The Raw socket code can be viewed at this location. It is seen that the Raw socket does not bind or connect to the destination location. We use “sendto” API to send data to the destination IP address and use “recvfrom” API to receive data on the destination IP address. The socket is opened with […]
Raw Socket code with IPPROTO_TCP Protocol
The following code opens a raw socket with the IPPROTO_TCP L4 protocol. By opening such a socket connection, The TCP header now needs to be filled in by the application. The IPv4 header will still be filled by the Kernel on the packet send if IP_HDRINCL flag is not set via setsockopt API. The code […]