This article covers a fundamental concept: how data packets are transmitted and exchanged within a router. Once you understand this, it will greatly assist you in configuring a well-optimized network environment.
1. Input Issues
1. Raw sockets can receive any TCP or UDP packet.
2. To be received by a raw socket, the incoming packet must first have a complete and correct IP header; otherwise, it cannot pass the header check and checksum verification in ip_rcv().
3. During the process of receiving packets on a raw socket, the kernel performs checksum verification on the received IP packet, but it does not check or verify any fields beyond the IP header. For example, if we specify the protocol parameter as IPPROTO_TCP when creating the raw socket, the kernel will not perform TCP checksum verification. Instead, it directly copies all packets whose protocol field in the IP header is TCP and delivers them to the raw socket.
4. TCP packets received via a raw socket are those that have undergone IP reassembly but precede TCP sequencing.
5. If the protocol parameter specified when creating the raw socket is non-zero (the third parameter of socket), the protocol field of the received datagram must match it. Otherwise, the datagram will not be delivered to that socket.
6. If a local IP address is bound to this raw socket, the destination IP address of the received datagram must match that bound IP address; otherwise, the packet will not be delivered to the socket.
7. If this raw socket has specified a remote IP address via connect, the source IP address of the received packet must match that connected address; otherwise, the packet will not be delivered to the socket.
8. If a raw socket is created with a protocol parameter of 0 and neither connect nor bind is called, then for every raw datagram the kernel delivers to raw sockets, this socket will receive a copy.
<