Fix RTT outliers

1) When calculating median latency, reject any entry that doesn't
   have at least 5 data points. From local testing, 5 appears
   to be the magic number (when combined with sampling time) that
   ignores the "idle" traffic from CPEs, routers and long-poll
   sessions on devices.

2) Filter out RTT 0 from best/worst reports.

3) Note that no data is discarded - it's just filtered for display.

This results in a much cleaner display of RTT times in the
reporting interface, giving a much better ability to "zero in"
on problem areas without being distracted by poor RTT - but
basically no traffic - hosts that are idle.
This commit is contained in:
Herbert Wolverson 2023-02-24 14:53:47 +00:00
parent 791ff97eef
commit 6b82fd968e
2 changed files with 4 additions and 1 deletions

View File

@ -74,6 +74,7 @@ pub fn top_n(start: u32, end: u32) -> BusResponse {
.iter()
.filter(|(ip, _)| !ip.as_ip().is_loopback())
.filter(|(_, d)| retire_check(tp.cycle, d.most_recent_cycle))
.filter(|(_, te)| te.median_latency() > 0.0)
.map(|(ip, te)| {
(
*ip,
@ -116,6 +117,7 @@ pub fn worst_n(start: u32, end: u32) -> BusResponse {
.iter()
.filter(|(ip, _)| !ip.as_ip().is_loopback())
.filter(|(_, d)| retire_check(tp.cycle, d.most_recent_cycle))
.filter(|(_, te)| te.median_latency() > 0.0)
.map(|(ip, te)| {
(
*ip,
@ -157,6 +159,7 @@ pub fn best_n(start: u32, end: u32) -> BusResponse {
.iter()
.filter(|(ip, _)| !ip.as_ip().is_loopback())
.filter(|(_, d)| retire_check(tp.cycle, d.most_recent_cycle))
.filter(|(_, te)| te.median_latency() > 0.0)
.map(|(ip, te)| {
(
*ip,

View File

@ -24,7 +24,7 @@ impl ThroughputEntry {
.filter(|n| **n != 0)
.map(|n| *n as f32 / 100.0)
.collect();
if shifted.is_empty() {
if shifted.len() < 5 {
return 0.0;
}
shifted.sort_by(|a, b| a.partial_cmp(b).unwrap());