progress?
This commit is contained in:
@@ -29,6 +29,12 @@ class StatisticsEngine:
|
||||
|
||||
def _calculate_single_flow_statistics(self, flow: FlowStats) -> None:
|
||||
"""Calculate statistics for a single flow"""
|
||||
# Ensure timeline statistics are calculated
|
||||
if len(flow.timestamps) >= 2:
|
||||
flow.duration = flow.timestamps[-1] - flow.timestamps[0]
|
||||
flow.first_seen = flow.timestamps[0]
|
||||
flow.last_seen = flow.timestamps[-1]
|
||||
|
||||
if len(flow.inter_arrival_times) < 2:
|
||||
return
|
||||
|
||||
@@ -36,9 +42,19 @@ class StatisticsEngine:
|
||||
flow.avg_inter_arrival = statistics.mean(flow.inter_arrival_times)
|
||||
flow.std_inter_arrival = statistics.stdev(flow.inter_arrival_times)
|
||||
|
||||
# Calculate jitter as coefficient of variation (normalized standard deviation)
|
||||
if flow.avg_inter_arrival > 0:
|
||||
flow.jitter = flow.std_inter_arrival / flow.avg_inter_arrival
|
||||
else:
|
||||
flow.jitter = 0.0
|
||||
|
||||
# Detect outliers (frames with inter-arrival time > threshold * std deviations from mean)
|
||||
threshold = flow.avg_inter_arrival + (self.outlier_threshold_sigma * flow.std_inter_arrival)
|
||||
|
||||
# Clear existing outliers to recalculate
|
||||
flow.outlier_frames.clear()
|
||||
flow.outlier_details.clear()
|
||||
|
||||
for i, inter_time in enumerate(flow.inter_arrival_times):
|
||||
if inter_time > threshold:
|
||||
# Frame number is i+2 because inter_arrival_times[i] is between frame i+1 and i+2
|
||||
|
||||
Reference in New Issue
Block a user