/// The smallest time that the system timer (via `sleep()`, `nanosleep()`, /// `select()`, or similar) can reliably deliver; see `neqo_common::hrtime`. pubconst GRANULARITY: Duration = Duration::from_millis(1); // Defined in -recovery 6.2 as 333ms but using lower value. pubconst DEFAULT_INITIAL_RTT: Duration = Duration::from_millis(100);
/// The source of the RTT measurement. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pubenum RttSource { /// RTT guess from a retry or dropping a packet number space.
Guesstimate, /// Ack on an unconfirmed connection.
Ack, /// Ack on a confirmed connection.
AckConfirmed,
}
fn init(&mutself, rtt: Duration) { // Only allow this when there are no samples.
debug_assert!(self.first_sample_time.is_none()); self.latest_rtt = rtt; self.min_rtt = rtt; self.smoothed_rtt = rtt; self.rttvar = rtt / 2;
}
pubfn set_initial(&mutself, rtt: Duration) {
qtrace!("initial RTT={rtt:?}"); if rtt >= GRANULARITY { // Ignore if the value is too small. self.init(rtt);
}
}
/// For a new path, prime the RTT based on the state of another path. pubfn prime_rtt(&mutself, other: &Self) { self.set_initial(other.smoothed_rtt + other.rttvar); self.ack_delay = other.ack_delay.clone();
}
/// Get the estimated value. pubconstfn estimate(&self) -> Duration { self.smoothed_rtt
}
pubfn pto(&self, confirmed: bool) -> Duration { letmut t = self.estimate() + max(4 * self.rttvar, GRANULARITY); if confirmed {
t += self.ack_delay.max();
}
t
}
/// Calculate the loss delay based on the current estimate and the last /// RTT measurement received. pubfn loss_delay(&self) -> Duration { // kTimeThreshold = 9/8 // loss_delay = kTimeThreshold * max(latest_rtt, smoothed_rtt) // loss_delay = max(loss_delay, kGranularity) let rtt = max(self.latest_rtt, self.smoothed_rtt);
max(rtt * 9 / 8, GRANULARITY)
}
/// A fresh `RttEstimate` after one real sample using the initial RTT. fn initialized_rtt() -> RttEstimate { letmut rtt = RttEstimate::new(DEFAULT_INITIAL_RTT);
update_ack(&mut rtt, DEFAULT_INITIAL_RTT);
rtt
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.