Commit f6f704c5 authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête

stun timer: fix timeout of the last retransmission

According to RFC 5389, section 7.2.1, a special timeout is applied to
the last retransmission (Rm * RTO), with Rm default value of 16, instead
of (64 * RTO), 2^6 when the number of transmissions Rc is set to 7.

As spotted by Olivier Crete, stun_timer_* is a public API, that cannot
be changed, and the initial delay (RTO) is not preserved in the
stun_timer_s struct. So we use a hack that implicitely guess Rm from the
number of transmissions Rc, by generalizing the default value of the
spec for Rm and Rc to other values of Rc passed in stun_timer_start(

According to the spec, with the default value of Rc=7, the last delay
should be (64 * RTO), and it is instead (16 * RTO). So the last delay
can be computed by dividing the penultimate delay by two, instead of
multiplying it by two.

Differential Revision: https://phabricator.freedesktop.org/D1108
parent b0538d8c
...@@ -145,7 +145,11 @@ StunUsageTimerReturn stun_timer_refresh (StunTimer *timer) ...@@ -145,7 +145,11 @@ StunUsageTimerReturn stun_timer_refresh (StunTimer *timer)
if (timer->retransmissions >= timer->max_retransmissions) if (timer->retransmissions >= timer->max_retransmissions)
return STUN_USAGE_TIMER_RETURN_TIMEOUT; return STUN_USAGE_TIMER_RETURN_TIMEOUT;
add_delay (&timer->deadline, timer->delay *= 2); if (timer->retransmissions == timer->max_retransmissions - 1)
timer->delay = timer->delay / 2;
else
timer->delay = timer->delay * 2;
add_delay (&timer->deadline, timer->delay);
timer->retransmissions++; timer->retransmissions++;
return STUN_USAGE_TIMER_RETURN_RETRANSMIT; return STUN_USAGE_TIMER_RETURN_RETRANSMIT;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment