diff options
author | Fabrice Bellet <fabrice@bellet.info> | 2016-06-09 22:22:33 +0200 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-04-11 20:04:35 -0400 |
commit | f6f704c5e8d2193bc67ba2b697c77694e1698c43 (patch) | |
tree | 6653b667ccacbdba83ab126f7451d821cf3a2229 /stun | |
parent | b0538d8c51f65019867b56a45cf90a70bef38f01 (diff) | |
download | libnice-f6f704c5e8d2193bc67ba2b697c77694e1698c43.tar.gz |
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
Diffstat (limited to 'stun')
-rw-r--r-- | stun/usages/timer.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/stun/usages/timer.c b/stun/usages/timer.c index 2862ab8..5370cba 100644 --- a/stun/usages/timer.c +++ b/stun/usages/timer.c @@ -145,7 +145,11 @@ StunUsageTimerReturn stun_timer_refresh (StunTimer *timer) if (timer->retransmissions >= timer->max_retransmissions) 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++; return STUN_USAGE_TIMER_RETURN_RETRANSMIT; } |