Skip to main content

keepalive_interval

Function keepalive_interval 

Source
pub fn keepalive_interval(
    flow_timer: Option<Duration>,
    keepalive: Keepalive,
    power: Power,
    fraction: f64,
) -> Duration
Expand description

How long to wait before the next keep-alive (§4.4.1, §4.4.2).

fraction selects within the range and must be in 0.0..=1.0; every ping re-draws it, because §4.4.1 says “the random number will be different for each keep-alive ping”. Randomising is not decoration: a fleet that pings on a fixed period synchronises after any shared outage and arrives at the registrar as one spike.

A Flow-Timer from the registrar wins outright — it is a statement about how long it will hold the flow, so a UA’s own preference is not a competing opinion.

The published defaults are used verbatim: 95–120 seconds, or 672–840 where battery matters, and 24–29 for STUN. §4.4.1 describes the lower bound as “20% less than the upper bound” and then gives 95 for an upper bound of 120, which is 20.8% less rather than 20%. The literal numbers are what interoperates, so those are the ones here.