TCP's retransmission timeout

  TCP protocol is a connection-oriented reliable transport protocol that ensures reliable data transmission, for some error, and packet loss issues TCP timeout retransmission timeout mechanism design, the basic principle: after sending a data, start a timer, if it does not receive acknowledgment ACK packets of data within this time, then the packet retransmission, give up and sends a reset signal when a certain number has not been successful.
 
Retransmission timeout time
  RTO (Retransmission TimeOut), a key parameter affecting the efficiency of the protocol timeout retransmission mechanism retransmission timeout RTO, RTO value is set too large too small will adversely affect the agreement. If too great RTO provided via the transmitting end will wait a long time before the discovery packet segment is lost, reducing the throughput of data transmission connection; on the other hand, when the RTO is too small, although the transmission side can quickly detect the packet missing segment, but it may delay some large segment mistaken for a loss, resulting in unnecessary retransmissions, wasting network resources.
  If the transmission characteristics of the underlying network is predictable, then the design is much retransmission mechanism is relatively simple and can be selected an appropriate transmission delay RTO according to the characteristics of the underlying network, to optimize the performance of the protocol. But the underlying TCP network environment is a completely heterogeneous interconnect structure. When to-end communication, the performance of the transmission path between different endpoints may exist a huge difference, and the same TCP connection over different periods of time, due to the different network state will have different transmission delays.
  Dimensionless, TCP protocol must accommodate the delay difference between the two aspects: one is to reach the destination of delay differences, and the other is the difference in the transmission delay is connected with uniform traffic load variation that occurs. To handle such differences and variations of the transmission characteristics of the underlying network, TCP retransmission mechanism relative to other protocols obviously also be more complex, especially in the treatment of mainly timeout interval. To this end, TCP protocol using an adaptive algorithm (Adaptive Retransmission Algorithm) to accommodate variations in the Internet packet transmission delay. The basic elements of this algorithm is to monitor performance of each TCP connection (i.e., transmission delay), whereby each TCP connection calculate the appropriate value of RTO, when the connection delay performance changes, TCP can be automatically modified accordingly RTO the setting, in order to adapt to changes in such networks.
  RTO generally set according to the RTT. If the RTO is less than the RTT, it will cause a lot of unnecessary retransmission; if RTO is much larger than RTT, will reduce overall network utilization, RTO is the key to TCP performance. RTT and different connections are not the same, with a different connection RTT time is not the same, so the RTO has been set hotspot.
 
Round-trip time connection
  RTT (Round Trip Time), for a connection, if the round trip time to understand the transmission between the endpoints may be set according to a proper RTO RTT. Obviously, at any time RTT connections are random, it can not be predicted in advance. TCP connection to obtain an estimate of the current RTT by measuring the RTT estimate and to set a reference current value RTO. The key adaptive retransmission algorithm is that an accurate estimate of the current RTT in order to adjust RTO.
  In order to gather sufficient data to accurately estimate the current RTT, TCP packets are recorded for each time in confirmation of transmitted and received in time. Each (transmission time, acknowledgment time) can be calculated for a sample of the RTT measurement value (Sample RTT). TCP is a connection each activity maintains a current estimate of RTT. This value is a weighted average of the RTT of a connection of the two time period has passed, and as a connector of the current estimate of the TCP actual RTT value. RTT estimate RTO segment is used to determine when the transmission segment. In order to ensure that it is able to more accurately reflect the current state of the network, whenever a new TCP obtained by measuring the RTT samples, all will be updated estimate of RTT. Different update algorithms or parameters may obtain different characteristics.
 
Accurate measurement of the RTT estimate algorithm --Karn
  If the data in a segment be successfully transmitted and once confirmed, the transmit end can accurately obtain RTT samples newspaper transmission segment. However, if there has been retransmitted, the situation becomes very complicated. For example, a packet transmitted after the timeout period, TCP packet to another segment retransmission. Due to these two segments contain the same data, the sender will receive confirmation profile in the end can not tell which segment against, because the two segments generated profile may be identical the confirmation message may either be for the original packet segment (which may be due to the original segment or confirmation is caused by delay in transmission), it may be confirmation of the retransmitted segment. This phenomenon is called confirmation ambiguity (Acknowledgement Ambiguiity). Confirmation of ambiguity will lead to incalculable TCP RTT accurately.
  To avoid ambiguity identify problems brought about, TCP uses the Karn algorithm to maintain the estimated value of the RTT. Karn algorithm specified, TCP can only use (neither retransmission segment, once successfully sent and acknowledged) did not confirm the ambiguity of RTT sample to adjust the estimate of the RTT.
 
Retransmission
 
Sending data size when retransmitting
  Data transfer can not be used when only one window protocol, but also a congestion window to control the flow of data so that the data will not suddenly cause the web have come "congestion." Congestion window initially used to increase the rate of exponential growth in its own window, until the occurrence of retransmission timeout, then a fine-tuning. But how to fine-tune the algorithm to avoid congestion and slow start threshold is born to do this.
  The so-called slow start threshold is to say, when the congestion window when this threshold is exceeded, use congestion avoidance algorithm, but in less than a threshold on the use of the slow start algorithm. So it is called the standard threshold, generally, do remember congestion window cwnd, slow start threshold denoted ssthresh. Let's look at congestion avoidance and slow start is how to work together.
 
Algorithms Summary
  For a given connection, initializing cwnd to one segment, ssthresh to 65535 bytes. TCP output routine output can not exceed the size of the cwnd and the receiver's advertised window. Congestion avoidance is used by the sender of flow control , while the advertised window is flow control of the receiving party. The former is perceived by the sender network congestion estimate, while the latter may be used on the connection with the receiver buffer size related. When congestion occurs (time-out or the receipt of a duplicate acknowledgment), ssthresh is set to half the current window size (the minimum CWnd and the receiver's advertised window size, but a minimum of two segments). In addition, if the congestion is caused by a timeout, then cwnd is set to one segment (this is the slow start). When new data is confirmed each other, increases cwnd, but the increase depends on whether the method being slow start or congestion avoidance. If cwnd is less than or equal to ssthresh, the ongoing slow start, otherwise the ongoing congestion avoidance. Slow start continues until the time when the half-back position which did not stop when congestion occurs (because the record in half to create trouble in step 2 window size), and then into the implementation of congestion avoidance.
 
Fast retransmission and fast recovery algorithm
  This is the data packet loss A method for repairing a case where the given mechanism. In general case, retransmission occurs after a timeout, but if the transmission termination by three or more duplicate ACK, it should be appreciated that the lost data, the need to re-transfer. This mechanism is not required to wait until the retransmission timer overflow, so called fast retransmit, because it avoids the sender waits for the retry timer and idle for a long time, in order to increase network throughput. And after redelivery, because walking is not a slow start but congestion avoidance algorithm, so this is also called fast recovery algorithm. Process is as follows:
  Upon receipt of the third duplicate ACK, ssthresh is set to the current congestion window half of cwnd. Retransmission of lost  segments . Set cwnd to ssthresh plus 3 times the segment size. Each time it receives another duplicate ACK, cwnd increases a segment size, and transmits a packet (if allowed to send a new cwnd). When the next new data acknowledgment ACK arrives, set cwnd to ssthresh (the value set in step 1). This acknowledgment ACK should be retransmitted in step 1 within a round trip time after performing the retransmission. Further, the ACK should be all lost packets between the intermediate and the first duplicate ACK is received segment  acknowledgment. This step is used to avoid congestion. ICMP does not cause redelivery, TCP will stick with their own timer, but will remain under TCP ICMP error and notifies the user.
 
Regrouping
  TCP in order to improve their efficiency, allowing the re-transmission time, as long as the transmission includes retransmission data packet message can instead only retransmitted packets to be transmitted.
 
 

Guess you like

Origin www.cnblogs.com/Jummyer/p/11069075.html