From: Guus Sliepen Date: Mon, 14 Oct 2019 20:32:35 +0000 (+0200) Subject: Fix retransmission timeout calculation. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=eb85ec4ae5f32102430e0622e3855aaba110c032;p=utcp Fix retransmission timeout calculation. The RTO calculation was missing a factor 4 multiplication of the RTT variance, which caused it to set the RTO to a much lower value than specified by RFC 6298. This would result in more retranmissions and a lower throughput. --- diff --git a/utcp.c b/utcp.c index f35f965..802d95a 100644 --- a/utcp.c +++ b/utcp.c @@ -415,13 +415,13 @@ static void update_rtt(struct utcp_connection *c, uint32_t rtt) { if(!utcp->srtt) { utcp->srtt = rtt; utcp->rttvar = rtt / 2; - utcp->rto = rtt + max(2 * rtt, CLOCK_GRANULARITY); } else { utcp->rttvar = (utcp->rttvar * 3 + absdiff(utcp->srtt, rtt)) / 4; utcp->srtt = (utcp->srtt * 7 + rtt) / 8; - utcp->rto = utcp->srtt + max(utcp->rttvar, CLOCK_GRANULARITY); } + utcp->rto = utcp->srtt + max(4 * utcp->rttvar, CLOCK_GRANULARITY); + if(utcp->rto > MAX_RTO) { utcp->rto = MAX_RTO; }