From 019d3019135e5c03e584d259b6f596e98d59db6c Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Mon, 18 Mar 2024 16:04:43 -0500 Subject: [PATCH] Make the country RTTs actually add up --- .../flow_data/flow_analysis/finished_flows.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs index e0872afb..3dbe9b13 100644 --- a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs +++ b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs @@ -82,18 +82,27 @@ impl TimeBuffer { // Store the country let rtt = [ if total_rtt[0] > 0.0 { + rtt_count[0] += 1; (total_rtt[0] / rtt_count[0] as f64) as f32 } else { 0.0 }, if total_rtt[1] > 0.0 { + rtt_count[1] += 1; (total_rtt[1] / rtt_count[1] as f64) as f32 } else { 0.0 }, ]; - country_summary.push((last_country, total_bytes, rtt)); + if rtt_count[0] > 0 { + total_rtt[0] = (total_rtt[0] / rtt_count[0] as f64) as f64; + } + if rtt_count[1] > 0 { + total_rtt[1] = (total_rtt[1] / rtt_count[1] as f64) as f64; + } + + country_summary.push((last_country, total_bytes, total_rtt)); } last_country = country.to_string();