Time-wait State

Source: Internet
Author: User
Tags ack

Reprint: http://blog.csdn.net/chensichensi/article/details/5263132


Regarding the time-wait state only the party initiating the active shutdown enters this state. The exception is that both sides are closed at the same time, and then all go into this state in this state is 2MSL,MSL defined as 30 seconds to 2 minutes, the Linux definition is 30 seconds, so stay 1 minutes if there is data reached in this state, reset the timer.

Time-wait State under the power of the other side closed the connection, there will be no data coming.

Here is the need for the existence of time-wait: for the active shutdown side, the last to send an ACK to the other side to confirm the closure. And this ACK packet is likely to be lost, so set a wait time, if the other side retransmission fin packet can also be sent ACK packet confirmation; Due to the existence of network delay, it is possible for packets to arrive after they have been retransmission packets. At this point, if the connection is closed and the two sides have established a connection with the same address, the packet may be considered as the packet of the connection. With the time-wait, the old connection in this kind of packet disappears in the network predecessor, so it does not occur before the disturbance of the new connection is described.

Time-wait accident (not until the time is forced to end)

RFC793 when the connection is in the Time-wait state, TCP should immediately close the connection if the RST message is accepted.

RFC1337 describes the problem, and the Linux solution is to ignore the RST if you set the Enable rfc1337.

Otherwise, close the connection.

if (Th->rst) {
/* This is time_wait assassination two flavors.
* Oh ... nobody has a sufficient solution to this
* Protocol bug yet.
*/
if (sysctl_tcp_rfc1337 = = 0) {
Kill
Inet_twsk_deschedule (TW, &tcp_death_row);
Inet_twsk_put (TW);
return tcp_tw_success;
}
}

Another occurrence of the scene is man-made, for the so_linger socket option, if set to open linger, and set

Linger time is 0, the RST will occur to time-wait state. Therefore, you must not set this option when you use it.

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.