tor_multipath_voip/scripts/deltams.py
2019-09-26 11:41:07 +02:00

34 lines
1.4 KiB
Python
Executable file

#!/usr/bin/python3
import sys,re
print("run,packet_id,measure_type,latency,latency_ms")
for i in range(1,len(sys.argv)):
path = sys.argv[i]
client_server = f"{sys.argv[i]}/log/server-measlat-stdout.log"
server_client = f"{sys.argv[i]}/log/client-measlat-stdout.log"
run = path
agg = {}
with open(client_server, 'r') as f:
for line in f:
res = re.match(r".*Packet (\d+) latency (\d+)µs", line)
if not res: continue
pkt_id,lat = res.groups()
pkt_id,lat = int(pkt_id), int(lat)
agg[pkt_id] = {"client_server": lat }
with open(server_client, 'r') as f:
for line in f:
res = re.match(r".*Packet (\d+) latency (\d+)µs", line)
if not res: continue
pkt_id,lat = res.groups()
pkt_id,lat = int(pkt_id), int(lat)
if not pkt_id in agg: agg[pkt_id] = {}
agg[pkt_id]["server_client"] = lat
for packet_id, lats in agg.items():
if "client_server" not in lats or "server_client" not in lats: continue
print(f"{run},{packet_id},client_server,{lats['client_server']},{lats['client_server'] / 1000}")
print(f"{run},{packet_id},server_client,{lats['server_client']},{lats['server_client'] / 1000}")
print(f"{run},{packet_id},delta,{lats['client_server'] - lats['server_client']},{(lats['client_server'] - lats['server_client'])/1000}")
print(f"{run},{packet_id},delta_abs,{abs(lats['client_server'] - lats['server_client'])},{abs(lats['client_server'] - lats['server_client'])/1000}")