From 882746380ef6c3bcff0eaf6d62d1309205f436cb Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 25 Jun 2016 22:10:17 +0200 Subject: [PATCH] Correct RTT Variation --- transport/internet/kcp/kcp.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/internet/kcp/kcp.go b/transport/internet/kcp/kcp.go index 124be025..1f99f006 100644 --- a/transport/internet/kcp/kcp.go +++ b/transport/internet/kcp/kcp.go @@ -139,7 +139,7 @@ type KCP struct { conv, mtu, mss, state uint32 snd_una, snd_nxt, rcv_nxt uint32 ts_recent, ts_lastack, ssthresh uint32 - rx_rttval, rx_srtt, rx_rto uint32 + rx_rttvar, rx_srtt, rx_rto uint32 snd_wnd, rcv_wnd, rmt_wnd, cwnd, probe uint32 current, interval, ts_flush, xmit uint32 updated uint32 @@ -272,19 +272,19 @@ func (kcp *KCP) update_ack(rtt int32) { var rto uint32 = 0 if kcp.rx_srtt == 0 { kcp.rx_srtt = uint32(rtt) - kcp.rx_rttval = uint32(rtt) / 2 + kcp.rx_rttvar = uint32(rtt) / 2 } else { delta := rtt - int32(kcp.rx_srtt) if delta < 0 { delta = -delta } - kcp.rx_rttval = (3*kcp.rx_rttval + uint32(delta)) / 4 + kcp.rx_rttvar = (3*kcp.rx_rttvar + uint32(delta)) / 4 kcp.rx_srtt = (7*kcp.rx_srtt + uint32(rtt)) / 8 if kcp.rx_srtt < 1 { kcp.rx_srtt = 1 } } - rto = kcp.rx_srtt + _imax_(kcp.interval, 4*kcp.rx_rttval) + rto = kcp.rx_srtt + _imax_(kcp.interval, 4*kcp.rx_rttvar) if rto > IKCP_RTO_MAX { rto = IKCP_RTO_MAX }