- # read the stats after the test
- stats = client.get_stats()
-
- print("#####statistics (approx.)#####")
- print(json.dumps(stats, indent=4,
- separators=(',', ': '), sort_keys=True))
-
- lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
- lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
-
- print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
- print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
-
- except STLError as ex_error:
- print_error(str(ex_error))
- sys.exit(1)
-
+ # Read the stats after the test,
+ # we need to update values before the last trial started.
+ if args.xstat0:
+ snapshot = eval(args.xstat0)
+ client.ports[0].get_xstats().reference_stats = snapshot
+ if args.xstat1:
+ snapshot = eval(args.xstat1)
+ client.ports[1].get_xstats().reference_stats = snapshot
+ # Now we can call the official method to get differences.
+ xstats0 = client.get_xstats(0)
+ xstats1 = client.get_xstats(1)
+
+ # If STLError happens, let the script fail with stack trace.