In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the timeout and retransmission mechanism of TCP". In daily operation, I believe that many people have doubts about the timeout and retransmission mechanism of TCP. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the timeout and retransmission mechanism of TCP?" Next, please follow the editor to study!
TCP provides a reliable transport layer. One of the methods it uses is to confirm the data received from the other end. But both data and confirmation can be lost. TCP solves this problem by setting a timer when sending. If an acknowledgement is not received when the timer overflows, it retransmits the data. For any implementation, the key lies in the strategy of timeout and retransmission, that is, how to determine the timeout interval and how to determine the frequency of retransmission.
Timeout
The calculation of the timeout is the core of the timeout, and TCP requires this algorithm to roughly estimate the current state of the network, although this is indeed very difficult. There are two reasons for precision:
The main results are as follows: (1) timing for a long time will result in low network utilization.
(2) if the timing is too short, it will cause multiple retransmissions and cause network congestion. Therefore, the book gives a set of empirical formulas and other measures to ensure the accuracy of the timer.
An introduction to Recursive Formula
The earliest TCP used a very simple formula to estimate the current state of the network, such as R
Initialization of RTO
The initialization of RTO is determined by the formula, for example, the initial formula, the initial value should be 1. In the modified formula, the initial RTO should be Agg4D.
Updates to RTO
When the data is transmitted normally, we will update each data with the above formula and restart the timer to ensure that the next data is transmitted smoothly. It should be noted that in the case of retransmission, RTO does not use the above formula to calculate, but uses a method called "exponential Backoff". For example, when the RTO is 1s and the data retransmission occurs, we use the RTO=2S timer to retransmit the data, and use 4S next time. All the way to 64s.
Initialization of estimator
Here, the initialization of the estimator used by SYN seems to be different from the estimator used for transmission (I am not sure) to make my understanding. In the modified formula, in the case of SYN, An initializes to 0pencil D and initializes to 3s. When you get the ACK that transmits the first data, you should initialize it according to the following formula: A=M+0.5D=A/2
Update of the estimator 6 times 9 games 8
Similar to the above discussion, under normal circumstances, the above formula is used to calculate, in the case of retransmission, the various parameters of the estimator are not updated. The reason is still because the estimation is not accurate.
Karn algorithm
This is not an algorithm, it should be a strategy, which is about the timing of updating the values of RTO and estimators. And 1.5. The update timing is the Karn algorithm.
The use of timers
Two sentences:
\ 1. In a connection, one and only one measurement timer is used. That is, if the TCP sends out three sets of data in a row, only one set of data will be measured.
\ 2. ACK datagrams are not measured for the simple reason that there are no ACK responses for ACK to be measured by the end timer.
Retransmission
When there is a timeout, there is a retransmission, but even the retransmission has a strategy, rather than simply sending the data.
The size of the data sent during retransmission
As mentioned earlier, data can not be transmitted using only one window protocol, we also need a congestion window to control the flow of data, so that the data will not all go to the network at once to cause "congestion". It has also been mentioned that the congestion window initially uses an exponential growth rate to increase its own window until a timeout retransmission occurs and then fine-tunes. But there is no mention of how to fine-tune, congestion avoidance algorithms and slow start thresholds are created for this. The so-called slow start threshold means that when the congestion window exceeds this threshold, the congestion avoidance algorithm is used, and the slow start algorithm is used within the threshold. That's why this standard is called the threshold. Usually, the congestion window is recorded as cwnd and the slow start threshold as ssthresh. Let's take a look at how congestion avoidance and slow start work together. Summary of algorithms (copied directly from the book)
1. For a given connection, the initialization cwnd is 1 message segment and the ssthresh is 65535 bytes.
The output of the 2.TCP output routine cannot exceed the size of the cwnd and receiver advertisement window. Congestion avoidance is the flow control used by the sender, while the notification window is the flow control carried out by the receiver. The former is an estimate of the network congestion felt by the sender, while the latter is related to the size of the available cache of the receiver on the connection.
3. When congestion occurs (timeout or duplicate acknowledgements received), the ssthresh is set to half the current window size (the minimum size of the cwnd and receiver advertised window size, but at least 2 message segments). In addition, if the timeout causes congestion, the cwnd is set to 1 message segment (this is slow startup).
4. Cwnd is added when new data is confirmed by the other party, but the added method depends on whether we are doing slow startup or congestion avoidance. If cwnd is less than or equal to ssthresh, slow start is in progress, otherwise congestion avoidance is in progress. The slow start continues until we get back to where we were at the time of congestion (because we recorded half the size of the window that caused us trouble in step 2), and then switch to congestion avoidance.
Fast retransmission and fast recovery algorithm
This is a repair mechanism in the case of data packet loss. Generally speaking, retransmission occurs after a timeout, but if the sender receives more than three duplicate ACK, it should be aware that the data is lost and needs to be retransmitted. This mechanism does not need to wait until the retransmission timer overflows, so it is called fast retransmission, and after retransmission, it is also called fast recovery algorithm because it is not slow start but congestion avoidance algorithm. The process is as follows:
\ 1. When the third duplicate ACK is received, the ssthresh is set to half of the current congestion window cwnd. Retransmit the missing message. Set cwnd to ssthresh plus 3 times the packet segment size.
\ 2. Each time another duplicate ACK is received, the cwnd increases the message segment size and sends one packet (if the new cwnd allows it to be sent).
\ 3. When the next ACK that confirms the new data arrives, set cwnd to ssthresh (the value set in step 1). This ACK should be a confirmation of the retransmission in step 1 within a round trip time after the retransmission. In addition, this ACK should also be an acknowledgement of all intermediate message segments between the lost packet and the first duplicate ACK received. This step uses congestion avoidance because we halve the current rate when packets are lost.
Will ICMP cause retransmission?
The answer is: no, TCP will stick with its own timer, but TCP will keep the ICMP error and notify the user.
Regroup
In order to improve its efficiency, TCP allows retransmission as long as it transmits messages that contain retransmitted data messages, instead of retransmitting only the messages that need to be transmitted.
At this point, the study on "what is the timeout and retransmission mechanism of TCP" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.