Class RttEstimator
java.lang.Object
io.github.mahmoudimus.quic.congestion.RttEstimator
Round-trip time estimation for one network path (RFC 9002 section 5): the latest sample, the
smoothed RTT and its variance (RFC 6298), and the minimum RTT. All durations are nanoseconds.
Threads. Not thread-safe; an estimator belongs to one connection, which serializes access.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe initial RTT before any sample, 333 ms (RFC 9002 section 6.2.2).static final longThe system timer granularity assumed by loss detection, 1 ms (RFC 9002 section 6.1.2). -
Constructor Summary
ConstructorsConstructorDescriptionRttEstimator(long initialRtt) An estimator with no samples.RttEstimator(RttEstimator other) A copy of another estimator. -
Method Summary
Modifier and TypeMethodDescriptionlongA conservative estimate, the larger of the smoothed and latest RTT (RFC 9002 section 6.1.2).longget()The best current estimate: the smoothed RTT, or the initial RTT before any sample.booleanWhether a sample has been taken.longlatest()The most recent sample.longmin()The minimum RTT seen.longptoBase()The probe timeout before backoff andmax_ack_delay:smoothed_rtt + max(4 * rttvar, kGranularity)(RFC 9002 section 6.2.1).voidupdate(long ackDelay, long rtt) Takes an RTT sample (RFC 9002 section 5.3).longvariance()The RTT variance.
-
Field Details
-
TIMER_GRANULARITY
public static final long TIMER_GRANULARITYThe system timer granularity assumed by loss detection, 1 ms (RFC 9002 section 6.1.2).- See Also:
-
DEFAULT_INITIAL_RTT
public static final long DEFAULT_INITIAL_RTTThe initial RTT before any sample, 333 ms (RFC 9002 section 6.2.2).- See Also:
-
-
Constructor Details
-
RttEstimator
public RttEstimator(long initialRtt) An estimator with no samples.- Parameters:
initialRtt- the RTT to assume until the first sample, in nanoseconds
-
RttEstimator
A copy of another estimator.- Parameters:
other- the estimator to copy
-
-
Method Details
-
get
public long get()The best current estimate: the smoothed RTT, or the initial RTT before any sample.- Returns:
- nanoseconds
-
conservative
public long conservative()A conservative estimate, the larger of the smoothed and latest RTT (RFC 9002 section 6.1.2).- Returns:
- nanoseconds
-
min
public long min()The minimum RTT seen.- Returns:
- nanoseconds
-
latest
public long latest()The most recent sample.- Returns:
- nanoseconds
-
variance
public long variance()The RTT variance.- Returns:
- nanoseconds
-
hasSample
public boolean hasSample()Whether a sample has been taken.- Returns:
- true after the first
update(long, long)
-
ptoBase
public long ptoBase()The probe timeout before backoff andmax_ack_delay:smoothed_rtt + max(4 * rttvar, kGranularity)(RFC 9002 section 6.2.1).- Returns:
- nanoseconds
-
update
public void update(long ackDelay, long rtt) Takes an RTT sample (RFC 9002 section 5.3). The ACK delay is subtracted only when that does not take the sample below the minimum RTT; the first sample resets every estimate.- Parameters:
ackDelay- the peer's reported ACK delay, already limited to itsmax_ack_delayrtt- the time from sending the largest newly acknowledged packet to receiving the ACK
-