Brief Analysis of normal end of Connection

Source: Internet
Author: User

After a connection is established, processes at both ends of the connection can use the connection for communication. When the connected party feels "I have finished speaking", it can end the communication sent to the other party in the connection. The connection is finally terminated by four handshakes (four-way handshaking). The connection ends with a Special Fragment FIN (a fragment with a FIN bit of 1 ). We can see that during the end of the connection, the two sides exchanged four pieces of information (two FIN and two ACK ). In the process of terminating the connection, TCP does not merge FIN and ACK fragments. The reason is that the TCP connection allows one-way close (half-close ). That is to say, the TCP connection closes the transmission in one direction and becomes a one-way connection (half-duplex ). The second arrow and the third arrow must be separated to continue transmission in the open direction. If the second and third arrows are combined, the other party will be forced to close as one party closes. Between the second and third handshakes, the server can send one-way fragments to the client, but the client cannot send data fragments to the server. (The above termination is initiated first from the client, and the TCP connection can also be initiated first from the server .) The Client sends the final ACK reply, but the ACK may be lost. If the Server does not receive the ACK, it will repeatedly send the FIN fragment. Therefore, the Client cannot be immediately closed. It must confirm that the Server has received the ACK. The Client enters the TIME_WAIT status after sending the ACK. The Client sets a timer to wait for 2MSL. If you receive the FIN again within this time period, the Client resends the ACK and waits for 2MSL again. The so-called 2MSL is twice the MSL (Maximum Segment Lifetime ). MSL indicates the maximum survival time of a clip in the network. 2MSL indicates the maximum time required for sending and replying. If the Client does not receive the FIN again until 2MSL, the Client assumes that the ACK has been successfully received and ends the TCP connection.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.