1. TCP State MachineThe TCP protocol is too complicated. The establishment and termination of the connection have been introduced in the previous section. All the rules can be represented by a TCP state transition diagram.
Figure 1 TCP State Machine This diagram is very classic and can be found on the Internet, but I have redrawn it with colored lines here. The following are a few explanations about Figure 1: - The green thick solid line and the blue thick dashed line represent normal state transitions.
- The red thin solid line represents abnormal transitions.
- The top-level CLOSED state is an imaginary starting point and end point, not a real state.
2. Connection establishment and disconnection timing diagramHere we draw the three-way handshake and four-way handshake timing diagram again, and mark the transition status. As shown in Figure 2.
Figure 2 TCP normal connection establishment and termination corresponding status 3. State machine interpretationIn Figure 1, we can see that there are many abnormal state transitions, including simultaneous opening (two servers requesting to establish a connection with each other); and simultaneous closing (entering the CLOSING state). Not all systems can implement the simultaneous opening function. For example, early kernel versions do not support the transition from LISTEN to SYN_SENT. The transition from SYN_RCVD to LISTEN state is conditional: only when it enters the SYN_RCVD state normally (that is, the blue thick dotted line, entering SYN_RCVD from LISTEN), and then receives the RST segment, it can return to the LISTEN state. 4. Summary - Master the 11 states of TCP
|