Similar to the ARQ protocol on the data link layer,TCP uses the retransmission mechanism of timeout retransmission. That is:Each time TCP sends a packet segment, a timeout retransmission timer is set for this packet segment.. Timeout retransmission time set by this timerRTO(Retransmission time-out) should be slightly greater than the average round-trip delay RTT of the TCP packet segment.RTO= 2rtt. However, you can also manuallyAdjustmentRTOFor example, you can set this timeout retransmission time.RTO= 90 seconds.When the TCP packet segment has not received the expected confirmation information after the specified Timeout retransmission time, the TCP packet segment must be re-transmitted.. Note: When using a sliding window, TCP can be equivalent to the continuous ARQ discussed at the data link layer. Therefore, if a TCP packet segment times out, only the packet segment is retransmitted. The packets that have been successfully transmitted afterwards are not in this retransmission range.
TCP uses the following four Timers: retransmission timer, persistence timer, retention timer, and time Wait timer. . The main features of these timers are as follows:
1. retransmission Timer
When a TCP packet segment is sent, a retransmission timer is created for the specific packet segment. . There may be two situations:
(1) If the timer end time is ( Usually 60 seconds ) If you have received confirmation for this specific packet segment, cancel this timer.
(2) If the timer deadline is reached before receiving confirmation for this specific packet segment, the packet segment will be re-transmitted and the timer will be reset.
2. Stick to the timer
TCP needs another timer to handle zero-window notifications. It is assumed that the received TCP has declared that the window size is zero. When TCP is sent, the transmission packet segment is stopped until a non-zero window size is announced. However, this confirmation may be lost. We know that in TCP, confirmation is not required. If it is confirmed that the packet is lost, the receiving TCP does not know, but will think that it has completed the task, and wait for the TCP to send more packets. However, because TCP does not receive the confirmation, it will wait for the recipient to send the confirmation to notify the window size. Both sides of TCP are always waiting for the other side.
To enable this deadlock, TCP uses a persistence timer for each connection.When sending TCP receives a confirmation that the window size is zero, it starts to stick to the timer. . When the timer period is reached, send TCP to send a special packet segment, Called Detection packet segment . This packet segment contains only one byte of data. It has a sequence number, but its sequence number never needs to be confirmed. This sequence number is ignored even when the data of other parts is confirmed. Detection message segment reminder peer: Check that the packet has been lost and must be re-transmitted.
Set the timer value to the retransmission time value. However, if you do not receive a response from the receiving end, you need to send another detection packet segment and add and reset the timer value. The sender continues to send the detection packet segment, and will add and reset the value set by the timer until this value is increased to the threshold value ( Usually 60 seconds . After that, the sender sends a detection packet segment every 60 seconds until the window is reopened.
3. Active Timer
The active timer is used in some implementations to prevent the idle time between two TCP connections. . Assume that the customer opens the connection to the server, transmits some data, and then remains silent. Maybe this customer is faulty. In this case, the connection will always process the open state.
To solve this problem, in most implementations, the server is configured with a life-saving timer. The timer is reset whenever the server receives a message from the customer. Active TimerUsually set to 2 hours . If the server has not received the customer's information after two hours, it will send the detection packet segment. If 10 detection packet segments (75 seconds each time) have not responded, the connection is terminated if the customer fails.
4. Time wait Timer
The time Wait timer is used during connection termination. . When TCP closes a connection, it does not think that the connection is actually closed immediately. During the wait time period, the connection is still in an intermediate transitional state. This allows duplicate fin segments (if any) to reach the destination site and discard them. Value of this timer It is usually set to twice the lifetime of a packet segment .