From b9ad794dc55bebb2cb343c43da078435f29ab703 Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Fri, 26 Jul 2024 09:53:46 -0500 Subject: [PATCH] Start tracking bytes/second over time per-flow. This is experimental; in theory it won't cause problems, but it needs to be thoroughly tested. --- .../lqosd/src/throughput_tracker/flow_data/flow_tracker.rs | 3 +++ src/rust/lqosd/src/throughput_tracker/tracking_data.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_tracker.rs b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_tracker.rs index 943b3600..49c52484 100644 --- a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_tracker.rs +++ b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_tracker.rs @@ -41,6 +41,8 @@ pub struct FlowbeeLocalData { pub flags: u8, /// Recent RTT median pub rtt: [RttData; 2], + /// Throughput Buffer + pub throughput_buffer: Vec>, } impl From<&FlowbeeData> for FlowbeeLocalData { @@ -56,6 +58,7 @@ impl From<&FlowbeeData> for FlowbeeLocalData { tos: data.tos, flags: data.flags, rtt: [RttData::from_nanos(0); 2], + throughput_buffer: vec![ data.bytes_sent ], } } } \ No newline at end of file diff --git a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs index 7467269d..a7e60ed9 100644 --- a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs +++ b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs @@ -200,6 +200,7 @@ impl ThroughputTracker { get_flowbee_event_count_and_reset(); let since_boot = Duration::from(now); let expire = (since_boot - Duration::from_secs(timeout_seconds)).as_nanos() as u64; + let zeroed = DownUpOrder::zeroed(); // Tracker for per-circuit RTT data. We're losing some of the smoothness by sampling // every flow; the idea is to combine them into a single entry for the circuit. This @@ -234,6 +235,8 @@ impl ThroughputTracker { this_flow.0.end_status = data.end_status; this_flow.0.tos = data.tos; this_flow.0.flags = data.flags; + let prev_bytes = this_flow.0.throughput_buffer.last().unwrap_or(&zeroed); + this_flow.0.throughput_buffer.push(data.bytes_sent.checked_sub_or_zero(*prev_bytes)); if let Some([up, down]) = rtt_samples.get(&key) { if up.as_nanos() != 0 { this_flow.0.rtt[0] = *up;