In Linux, setting the tcp ip protocol stack can be divided into two parts. The first is the TCP protocol stack command writing, and the other is the IP protocol stack command settings. Today we will explain the two parts separately.
Analyze tcp_v4_init, which is in net/ipv4/tcp_ipv4.c:
The function is in net/ipv4/tcp_ipv4.c.
Tcp_inode is of course an inode node, and tcp_socket is equal to tcp_inode.u.socket_ I. They point to the same memory through a pointer. Tcp_socket is used for communication. It can be called TCP controlsocket or communication in the tcp ip protocol stack.
When no socket exists for TCP communication in the socket or TCP/IP protocol stack, the socket acts as the socket. For example, if an RST is sent when SYN is received on a closed port, or the SYN is sent when the three-way handshake is sent, no accept is generated to generate a new socket)
It is worth noting that the ops-> create function is called. We have previously seen that for AF_INET, this callback function is the inet_create function of net/ipv4/af_inet.c, this function is used to create a socket. Because the function is relatively long, the analysis is skipped here. The first analysis is just a rough process.