fix(stats): preserve signed per-packet IPDV in output
This commit is contained in:
4 files changed
+28
-20
No files matched your search
@@ -175,29 +175,31 @@ impl CoreStats {
|
||||
let mut updates = Vec::new();
|
||||
|
||||
for pair in self.ipdv_tracker.insert(sample) {
|
||||
let Some(rtt_ipdv) = duration_from_non_negative_i128_ns(pair.rtt_ipdv_ns) else {
|
||||
let rtt_magnitude_ns = pair.rtt_ipdv_ns.saturating_abs();
|
||||
let send_magnitude_ns = pair.send_ipdv_ns.map(i128::saturating_abs);
|
||||
let receive_magnitude_ns = pair.receive_ipdv_ns.map(i128::saturating_abs);
|
||||
let Some(rtt_ipdv) = duration_from_non_negative_i128_ns(rtt_magnitude_ns) else {
|
||||
continue;
|
||||
};
|
||||
let send_ipdv = pair
|
||||
.send_ipdv_ns
|
||||
.and_then(duration_from_non_negative_i128_ns);
|
||||
let receive_ipdv = pair
|
||||
.receive_ipdv_ns
|
||||
.and_then(duration_from_non_negative_i128_ns);
|
||||
let send_ipdv = send_magnitude_ns.and_then(duration_from_non_negative_i128_ns);
|
||||
let receive_ipdv = receive_magnitude_ns.and_then(duration_from_non_negative_i128_ns);
|
||||
|
||||
self.ipdv_round_trip.push_ns(pair.rtt_ipdv_ns);
|
||||
self.ipdv_round_trip.push_ns(rtt_magnitude_ns);
|
||||
|
||||
if let Some(value) = pair.send_ipdv_ns {
|
||||
if let Some(value) = send_magnitude_ns {
|
||||
self.ipdv_send.push_ns(value);
|
||||
}
|
||||
|
||||
if let Some(value) = pair.receive_ipdv_ns {
|
||||
if let Some(value) = receive_magnitude_ns {
|
||||
self.ipdv_receive.push_ns(value);
|
||||
}
|
||||
|
||||
updates.push(IpdvPairUpdate {
|
||||
previous_seq: pair.previous_seq,
|
||||
current_seq: pair.current_seq,
|
||||
rtt_ipdv_ns: pair.rtt_ipdv_ns,
|
||||
send_ipdv_ns: pair.send_ipdv_ns,
|
||||
receive_ipdv_ns: pair.receive_ipdv_ns,
|
||||
rtt_ipdv,
|
||||
send_ipdv,
|
||||
receive_ipdv,
|
||||
|
||||
@@ -89,9 +89,9 @@ impl IpdvTracker {
|
||||
Some(CompletedIpdvPair {
|
||||
previous_seq,
|
||||
current_seq,
|
||||
rtt_ipdv_ns: abs_i128_ns(current.rtt_primary_ns - previous.rtt_primary_ns),
|
||||
send_ipdv_ns: send_ipdv_ns(previous, current).map(abs_i128_ns),
|
||||
receive_ipdv_ns: receive_ipdv_ns(previous, current).map(abs_i128_ns),
|
||||
rtt_ipdv_ns: current.rtt_primary_ns - previous.rtt_primary_ns,
|
||||
send_ipdv_ns: send_ipdv_ns(previous, current),
|
||||
receive_ipdv_ns: receive_ipdv_ns(previous, current),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -161,10 +161,6 @@ fn duration_ns_i128(duration: Duration) -> i128 {
|
||||
i128::try_from(duration.as_nanos()).unwrap_or(i128::MAX)
|
||||
}
|
||||
|
||||
fn abs_i128_ns(value: i128) -> i128 {
|
||||
value.saturating_abs()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -520,6 +520,12 @@ pub struct IpdvPairUpdate {
|
||||
pub previous_seq: u32,
|
||||
/// Sequence number of the later reply in the adjacent pair.
|
||||
pub current_seq: u32,
|
||||
/// Signed round-trip delay change (current minus previous) in nanoseconds.
|
||||
pub rtt_ipdv_ns: i128,
|
||||
/// Signed send-side delay change in nanoseconds, when available for both replies.
|
||||
pub send_ipdv_ns: Option<i128>,
|
||||
/// Signed receive-side delay change in nanoseconds, when available for both replies.
|
||||
pub receive_ipdv_ns: Option<i128>,
|
||||
/// Absolute round-trip IPDV between the adjacent replies.
|
||||
pub rtt_ipdv: Duration,
|
||||
/// Absolute send-side IPDV when send one-way delay is available for both replies.
|
||||
|
||||
Reference in new issue
Block a user