fix(irtt): use effective RTT for latency fallback
This commit is contained in:
4 files changed
+13
-1
No files matched your search
@@ -289,6 +289,7 @@ mod tests {
|
||||
},
|
||||
started_at: received_at,
|
||||
observed_at: received_at,
|
||||
round_trip: None,
|
||||
one_way: Some(OneWayLatency {
|
||||
uplink: SignedDuration::from_millis(up_time as i64),
|
||||
downlink: SignedDuration::from_millis(down_time as i64),
|
||||
|
||||
@@ -326,6 +326,7 @@ impl IcmpEngine {
|
||||
stream: probe.stream,
|
||||
started_at: probe.sent_at,
|
||||
observed_at,
|
||||
round_trip: None,
|
||||
one_way: None,
|
||||
})
|
||||
}
|
||||
@@ -385,6 +386,7 @@ impl IcmpEngine {
|
||||
stream: probe.stream,
|
||||
started_at: probe.sent_at,
|
||||
observed_at,
|
||||
round_trip: None,
|
||||
one_way: Some(OneWayLatency {
|
||||
uplink: SignedDuration::from_millis(uplink_ms),
|
||||
downlink: SignedDuration::from_millis(downlink_ms),
|
||||
|
||||
@@ -255,6 +255,7 @@ impl IrttEngine {
|
||||
sent_at,
|
||||
received_at,
|
||||
one_way,
|
||||
rtt,
|
||||
..
|
||||
} => {
|
||||
let Some(stream) = stream else {
|
||||
@@ -265,6 +266,8 @@ impl IrttEngine {
|
||||
stream,
|
||||
started_at: sent_at.mono,
|
||||
observed_at: received_at.mono,
|
||||
round_trip: i64::try_from(rtt.effective.as_nanos())
|
||||
.ok().map(SignedDuration::from_nanos),
|
||||
one_way: one_way.and_then(map_one_way),
|
||||
};
|
||||
|
||||
|
||||
@@ -121,6 +121,9 @@ pub struct MeasurementObservation {
|
||||
/// Local monotonic time at which the result was observed.
|
||||
pub observed_at: Instant,
|
||||
|
||||
/// Measured round-trip latency when it differs from elapsed local time.
|
||||
pub round_trip: Option<SignedDuration>,
|
||||
|
||||
/// Directional timing, when the measurement mechanism can provide it.
|
||||
pub one_way: Option<OneWayLatency>,
|
||||
}
|
||||
@@ -131,7 +134,10 @@ impl MeasurementObservation {
|
||||
}
|
||||
|
||||
pub fn rtt_ms(&self) -> f64 {
|
||||
self.rtt().as_secs_f64() * 1000.0
|
||||
self.round_trip
|
||||
.map(SignedDuration::as_secs_f64)
|
||||
.unwrap_or_else(|| self.rtt().as_secs_f64())
|
||||
* 1000.0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user