标签:out should cpp red nta util network cal avoidance
https://titanwolf.org/Network/Articles/Article?AID=6d260d47-8ba6-4fa6-ba2f-4dc4c2dd6800#gsc.tab=0
Calculation of RTO in tcp and related open source implementation (Linux kernel, unbound)
1. Concept
RTT: Round trip delay.
RTO: After tcp sends a data packet, it will start a retransmission timer, RTO is the retransmission time of this timer.
Since RTO refers to the estimated timeout time of sending the current data packet this time, then RTO needs a good statistical method to better predict the timeout time of this time.
SRTT: smoothed tound-trip time
RTTVAR: round-trip time variation
Second, we can think of the calculation method (take the average)
For example, the first RTT is 500 milliseconds and the second is 800 milliseconds, then the RTO should be 650 milliseconds when it is sent for the third time.
3. RFC793 calculation method
Similar to taking the average.
3.1 Method
SRTT = ( ALPHA * SRTT ) + ( ( 1-ALPHA ) * RTT )
RTO = min [ UBOUND, max [ LBOUND, ( BETA * SRTT ) ] ]
3.2 Parameter meaning
UBOUND is the maximum value of RTO;
LBOUND is the minimum value of RTO;
The value of ALPHA is 0.8 ~ 0.9;
The value of BETA is 1.3 ~ 2.0.
RFC793: http://tools.ietf.org/html/rfc793
4. Calculation method of paper "Congestion Avoidance and Control"
Compared with RFC793, mean deviation is increased.
4.1 Method
Err ≡ m?a
a ← a + gErr
v ← v + g (| Err | ?v)
4.2 Parameter meaning
m is RTT;
a is SRTT;
v is the mean difference;
g is a factor.
4.3 Method changes
Since there may be floating point numbers in the presence of g, we only need to make a change so that g = 1/2 ^ n, then the above equation becomes the following
2 ^ na ← 2 ^ na + Err
2 ^ nv ← 2 ^ nv + g (| Err | ?v)
4.4 Pseudocode
/? update Average estimator ?/ m ? = (sa >> 3); sa + = m; /? update Deviation estimator ?/ if (m <0) m = ?m; m ? = (sv >> 2); sv + = m; rto = (sa >> 3) + sv;
paper "Congestion Avoidance and Control": http://ee.lbl.gov/papers/congavoid.pdf
Five, RFC6298 calculation method
5.1 Calculation method
At the first RTT:
SRTT <- R
RTTVAR <- R/2
RTO <- SRTT + max (G, K*RTTVAR)
During subsequent RTT:
RTTVAR <- (1 - beta) * RTTVAR + beta * |SRTT - R‘|
SRTT <- (1 - alpha) * SRTT + alpha * R‘
RTO <- SRTT + max (G, K*RTTVAR)
5.2 Parameter meaning
R and R ‘are RTT;
alpha = 1/8;
beta = 1/4;
K = 4.
5.3 Changed calculation method (this method is the same as the calculation method above)
delta = RTT - SRTT
SRTT = SRTT + g * delta
rttvar = rttvar + h(|delta| - rttvar)
RTO = srtt + 4*rttvar
among them:
g = 1/8
h = 1/4
RFC6298: http://tools.ietf.org/html/rfc6298
6. Some open source implementations of computing RTO
In the Linux kernel: net/ipv4/tcp_input.c tcp_rtt_estimator ()
Unbound: util/rtt.c
Reference materials:
RFC793: http://tools.ietf.org/html/rfc793
paper "Congestion Avoidance and Control": http://ee.lbl.gov/papers/congavoid.pdf
RFC6298: http://tools.ietf.org/html/rfc6298
Calculation of RTO in tcp and implementation under linux: http://www.cnblogs.com/hfww/archive/2012/08/01/2618109.html
TCP reliable transmission and flow control series 3: Retransmission time RTO calculation: http://zenhumany.blog.163.com/blog/static/1718066332010827104042708/
标签:out should cpp red nta util network cal avoidance
原文地址:https://www.cnblogs.com/ztguang/p/14415544.html