tor_multipath_voip/scripts/drop_parse.py

24 lines
530 B
Python
Raw Normal View History

2019-09-17 08:04:23 +00:00
#!/usr/bin/python3
import sys,re,math
group_by = int(sys.argv[1])
total = int(sys.argv[2])
2019-09-17 09:18:42 +00:00
run = sys.argv[3]
2019-09-17 08:04:23 +00:00
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):
2019-09-17 09:18:42 +00:00
idx = missing // group_by
if idx >= len(bins): continue
bins[idx] += 1
2019-09-17 08:04:23 +00:00
prev = pkt_id
for i in range(len(bins)):
2019-09-17 09:18:42 +00:00
print(f"{run},{i*group_by}-{(i+1)*group_by-1},{bins[i]}")