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.

This commit is contained in:
Herbert Wolverson 2024-07-26 09:53:46 -05:00
parent c7f06f9a39
commit b9ad794dc5
2 changed files with 6 additions and 0 deletions

View File

@ -41,6 +41,8 @@ pub struct FlowbeeLocalData {
pub flags: u8,
/// Recent RTT median
pub rtt: [RttData; 2],
/// Throughput Buffer
pub throughput_buffer: Vec<DownUpOrder<u64>>,
}
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 ],
}
}
}

View File

@ -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;