- # Warm-up phase.
- if warmup_time > 0:
- # Clear the stats before injecting.
- client.clear_stats()
- # Choose CPS and start traffic.
- client.start(mult=mult, duration=warmup_time)
- time_start = time.monotonic()
-
- # Read the stats after the warmup duration (no sampling needed).
- time.sleep(warmup_time)
- stats[time.monotonic()-time_start] = client.get_stats()
-
- if client.get_warnings():
- for warning in client.get_warnings():
- print(warning)
-
- client.reset()
-
- print(u"##### Warmup Statistics #####")
- print(json.dumps(stats, indent=4, separators=(u",", u": ")))
-
- # TODO: check stats format
- stats = stats[sorted(stats.keys())[-1]]
- lost_a = stats[port_0][u"opackets"] - stats[port_1][u"ipackets"]
- if traffic_directions > 1:
- lost_b = stats[port_1][u"opackets"] - stats[port_0][u"ipackets"]
-
- print(f"packets lost from {port_0} --> {port_1}: {lost_a} pkts")
- if traffic_directions > 1:
- print(f"packets lost from {port_1} --> {port_0}: {lost_b} pkts")
-