|
23 | 23 | import numpy as np |
24 | 24 | import pandas as pd |
25 | 25 | from ftanalyzer.common.pandas_multiprocessing import PandasMultiprocessingHelper |
26 | | -from ftanalyzer.events.events import ExportEvent |
| 26 | +from ftanalyzer.events.events import ExportEvent, FlowStartEvent |
27 | 27 | from ftanalyzer.models.sm_data_types import ( |
28 | 28 | SMException, |
29 | 29 | SMMetricType, |
@@ -279,7 +279,9 @@ def _run_sim( |
279 | 279 | statistic_objects, metric_to_obj = setup_statsitic_objects( |
280 | 280 | sim, start_time, end_time, inactive_timeout |
281 | 281 | ) |
282 | | - event_queue = create_event_queue(flows_file, host_stats, output_dir) |
| 282 | + event_queue = create_event_queue( |
| 283 | + flows_file, host_stats, inactive_timeout, output_dir |
| 284 | + ) |
283 | 285 | process_events(event_queue, statistic_objects, metric_to_obj, sim) |
284 | 286 |
|
285 | 287 | shutil.rmtree(output_dir, ignore_errors=True) |
@@ -764,19 +766,17 @@ def _flush_event_data( |
764 | 766 | # aggregate OnePacketFlow events within this window |
765 | 767 | one_packet_data_rate = sum(e.bytes for e in one_packet_events) * 8 / duration_s |
766 | 768 | one_packet_packet_rate = sum(e.packets for e in one_packet_events) / duration_s |
767 | | - one_packet_flows = np.uint64(sum(e.flows for e in one_packet_events)) |
768 | 769 |
|
769 | 770 | # Compose final rates |
770 | 771 | total_data_rate = one_packet_data_rate + current_data_rate |
771 | 772 | total_packet_rate = one_packet_packet_rate + current_packet_rate |
772 | | - total_flows = one_packet_flows + current_flows |
773 | 773 |
|
774 | 774 | update_statistic_objects( |
775 | 775 | statistic_objects, |
776 | 776 | metric_mapping, |
777 | 777 | data_rate=total_data_rate, |
778 | 778 | packet_rate=total_packet_rate, |
779 | | - flow_count=total_flows, |
| 779 | + flow_count=current_flows, |
780 | 780 | ) |
781 | 781 |
|
782 | 782 | export_events: List[ExportEvent] = [ |
@@ -889,14 +889,18 @@ def process_events( |
889 | 889 |
|
890 | 890 | # apply each event's effect to current rates |
891 | 891 | for e in simultaneous_events: |
892 | | - if isinstance(e, HostStatsEvent) or isinstance(e, ExportEvent): |
| 892 | + if isinstance(e, HostStatsEvent): |
893 | 893 | pass |
| 894 | + elif isinstance(e, ExportEvent): |
| 895 | + current_flows -= e.flows |
894 | 896 | elif isinstance(e, OnePacketFlow): |
895 | 897 | one_packet_events.append(e) |
| 898 | + current_flows += e.flows |
896 | 899 | else: |
897 | 900 | current_data_rate += e.data_rate |
898 | 901 | current_packet_rate += e.packet_rate |
899 | | - current_flows += e.flows |
| 902 | + if isinstance(e, FlowStartEvent): |
| 903 | + current_flows += e.flows |
900 | 904 |
|
901 | 905 | current_data_rate = max(0, current_data_rate) |
902 | 906 | current_packet_rate = max(0, current_packet_rate) |
|
0 commit comments