Skip to content

Commit

Permalink
Add program to parse throughput and retransmissions from iperf3 JSON log
Browse files Browse the repository at this point in the history
  • Loading branch information
ccanel committed Apr 2, 2024
1 parent e5e5258 commit a15ec6b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ratemon/scripts/tput_rxmits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""
Parses iperf3 sender-side JSON output file generated by cctestbedv2.py.
"""

import argparse
import json
import sys


def parse_args():
parser = argparse.ArgumentParser(
description="Calculate average throughput and retransmission count"
)
parser.add_argument(
"--in-file",
type=str,
help="Input JSON file (output of iperf3 sender).",
required=True,
)
parser.add_argument("--out-file", type=str, help="Output file.", required=True)
return parser.parse_args()


def main(args):
with open(args.in_file, "r", encoding="utf-8") as fil:
res = json.load(fil)

if "end" not in res:
print(f"Error: 'end' key not found in JSON file: {args.in_file}")
return 1

bps = res["end"]["bits_per_second"]
rxmits = res["end"]["retransmits"]
msg = f"Throughput: {bps / 1e9:.2f} Gbps\nRetransmits: {rxmits}"
print(msg)
with open(args.out_file, "w", encoding="utf-8") as fil:
fil.write(msg)
return 0


if __name__ == "__main__":
sys.exit(main(parse_args()))

0 comments on commit a15ec6b

Please sign in to comment.