What is Time_wait? HTTP connection

Source: Internet
Author: User

The HTTP connection is divided into: Establish a connection, that is, TCP three-time handshake

Send request Information

Send response information

Close the connection (TCP four-time handshake), following this procedure:

There are four state changes during TCP disconnection, as shown in: During the connection revocation process, there are the following procedures:1. The application on HOST1 shuts down its own connection causing TCP to send a fin message to HOST2. 2. HOST2 sends a confirmation message to HOST1, and HOST2 submits the fin as EOF to the HOST2 application. 3after some time, the application on HOST2 closes its side of the connection, triggering a fin message to HOST1. 4. HOST1 sends a confirmation message to HOST2, and then HOST2 closes the connection and frees the resource, however, HOST1 does not close the connection, but instead enters the time_wait state and remains in this state for the two maximum segment Lifetime (2MSL). Why do I need time_wait?1because at the fourth step, the ACK sent by HOST1 may be lost and cause HOST2 to resend the fin message, time_wait maintain the connection status. What happens if a party that performs an active shutdown HOST1 does not enter the TIME_WAIT state to close the connection? When the retransmission fin message arrives, because TCP no longer has the connected information, it is answered with the RST (restart) message, causing the HOST2 to enter the wrong state instead of the ordered terminating state, if the party sending the last ACK message is in the TIME_WAIT state and still records the connected information , it can correctly respond to the fin message of the peer HOST2.2.  Time_wait provides the time to disappear from the network for "segments of outliers" in the connection. Consider what happens if the delay or retransmission segment arrives after the connection is closed. Typically, this does not cause any problems because TCP simply discards the data and responds to the RST message. When the RST message arrives at the host that issued the delay period, it also discards the segment because the host does not have any information to record the connection. However, if a new connection with the same port number is established between the two identical hosts, then the segment of the outlier may be considered a new connection, and if any sequence number of the data in the segment of the outlier is in the current receive window of the new connection, the data is re-received, and the result is breaking the new connection. 

What is Time_wait? HTTP 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.