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:
parent b0538d8c
......@@ -145,7 +145,11 @@ StunUsageTimerReturn stun_timer_refresh (StunTimer *timer)
if (timer->retransmissions >= timer->max_retransmissions)
add_delay (&timer->deadline, timer->delay *= 2);
if (timer->retransmissions == timer->max_retransmissions - 1)
timer->delay = timer->delay / 2;
timer->delay = timer->delay * 2;
add_delay (&timer->deadline, timer->delay);
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