tor_multipath_voip/scripts/drop_parse.py

20 lines
458 B
Python
Executable file

#!/usr/bin/python3
import sys,re,math
group_by = int(sys.argv[1])
total = int(sys.argv[2])
prev = 0
bins = [0] * (total // group_by)
for line in sys.stdin:
res = re.match(r".*Packet (\d+) latency.*", line)
if not res: continue
pkt_id, = res.groups()
pkt_id = int(pkt_id) - 1
for missing in range(prev+1,pkt_id):
bins[missing // group_by] += 1
prev = pkt_id
for i in range(len(bins)):
print(f"{i*group_by}-{(i+1)*group_by-1},{bins[i]}")