Last time we talked about the TCP three handshake connection process, today we combine the state of the changes in terms of the TCP disconnected process: TCP four times waved.
After the data transfer is over, both sides of the communication can release the connection. Both A and B are now in a established state. A's application first sends a connection release segment to TCP and actively shuts down the TCP connection. A the first fin of the connection-free segment is set to 1, ordinal seq=u, which equals the last byte ordinal of the previously transmitted data plus 1. Then a enters the fin-wait-1 state and waits for the confirmation of B.
b After receiving the connection Release message section is issued confirmation, the confirmation number is ack=u+1, and this segment of its own serial number is V, equal to B before the last byte of the transmitted data number plus 1. Then B goes into the close-wait state. The TCP server process notifies the high-level application process at this point because the connection from A to B is released, when the TCP connection is in a semi shutdown state, that is, a has no data to send, but b if the data is sent, a is still accepted. In other words, the connection from B to a is not closed. This state can last for some time.
A after receiving the confirmation of B, it enters the fin-wait-2 state and waits for the connection released by B to release the message segment.
If B has no data to send to a, the application process notifies TCP to release the connection. At this point the B-issued connection release message segment must use Fin=1. It is assumed that the ordinal number of B is w (some data may be sent back in half off State B). b You must also repeat the confirmation number ack=u+1 that was last sent. This is B to enter the Last-ack state, waiting for a confirmation.
This must be confirmed after a has received a connection to release the message segment of B. In the confirmation message section, the ACK is set to 1, the confirmation number is ack=w+1, and its serial number is seq=u+1 (the preceding fin message consumes 1 ordinal numbers). Then enter the time-wait state. Note that the TCP connection has not been released yet. After 2MSL, A has to enter the closed state. The MSL is called the longest message segment life, typically 2 minutes.
When B receives a confirmation issued by a, it enters the closed state. This shows that B ends TCP connections earlier than a. Wait until the end of the 2MSL a also entered the closed state, this completes the TCP four times to wave the whole process of disconnection.
This article source: Network teaching Base original address: http://www.studynb1.com/wljc/404.html