nquic_rtt (nquic v1.0.0)

View Source

RTT estimation per RFC 9002 Section 5.

Maintains smoothed RTT, RTT variance, minimum RTT, and latest RTT.

All values are kept in microseconds to match the rest of the loss / congestion-control plumbing (which measures elapsed time with erlang:monotonic_time(microsecond)). Initial values are 333 ms (smoothed) and 166 ms (variance) per RFC 9002 5.3, expressed in microseconds.

Summary

Functions

Return a map of current RTT statistics: latest, min, smoothed, and variance.

Initialize RTT state with a 333 ms smoothed RTT and 166 ms variance, in microseconds.

Update RTT with a new sample and the peer-reported ACK delay.

Types

rtt_state()

-type rtt_state() ::
          #rtt_state{latest_rtt :: non_neg_integer(),
                     min_rtt :: non_neg_integer(),
                     smoothed_rtt :: non_neg_integer(),
                     rttvar :: non_neg_integer(),
                     first_sample_time :: non_neg_integer()}.

Functions

get(State)

-spec get(rtt_state()) ->
             #{latest_rtt := non_neg_integer(),
               min_rtt := non_neg_integer(),
               smoothed_rtt := non_neg_integer(),
               rttvar := non_neg_integer()}.

Return a map of current RTT statistics: latest, min, smoothed, and variance.

new()

-spec new() -> rtt_state().

Initialize RTT state with a 333 ms smoothed RTT and 166 ms variance, in microseconds.

smoothed_rtt(State)

-spec smoothed_rtt(rtt_state()) -> non_neg_integer().

update(State, Sample, AckDelay)

-spec update(rtt_state(), non_neg_integer(), non_neg_integer()) -> rtt_state().

Update RTT with a new sample and the peer-reported ACK delay.