- str(stats["latency"][0]["latency"]["total_min"]),
- str(stats["latency"][0]["latency"]["average"]),
- str(stats["latency"][0]["latency"]["total_max"]))
- lat_b = fmt_latency(
- str(stats["latency"][1]["latency"]["total_min"]),
- str(stats["latency"][1]["latency"]["average"]),
- str(stats["latency"][1]["latency"]["total_max"]))
-
- total_sent = stats[0]["opackets"] + stats[1]["opackets"]
- total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"]
-
- print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
- print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
+ str(stats["latency"][port_0]["latency"]["total_min"]),
+ str(stats["latency"][port_0]["latency"]["average"]),
+ str(stats["latency"][port_0]["latency"]["total_max"]))
+ if not unidirection:
+ lat_b = fmt_latency(
+ str(stats["latency"][port_1]["latency"]["total_min"]),
+ str(stats["latency"][port_1]["latency"]["average"]),
+ str(stats["latency"][port_1]["latency"]["total_max"]))
+
+ if not unidirection:
+ total_sent = stats[0]["opackets"] + stats[1]["opackets"]
+ total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"]
+ else:
+ total_sent = stats[port_0]["opackets"]
+ total_rcvd = stats[port_1]["ipackets"]
+
+ print("\npackets lost from {p_0} --> {p_1}: {v} pkts".format(
+ p_0=port_0, p_1=port_1, v=lost_a))
+ if not unidirection:
+ print("packets lost from {p_1} --> {p_0}: {v} pkts".format(
+ p_0=port_0, p_1=port_1, v=lost_b))