Commit 551e86c2 authored by Joanne Hugé's avatar Joanne Hugé

Update txtime_stats script to print a histogram to a file

parent 23419f94
......@@ -28,6 +28,16 @@ import math
import sys
def compute_offsets_stats(file_path):
measure_set = {}
measure_set["measure_type"] = "packet_jitter_tcpdump"
measure_set["props_names"] = ["packet_jitter_tcpdump"]
measure_set["units"] = ["us"]
measure_set["props_type"] = ["histogram"]
measure_set["metadata"] = {"i": interval}
histogram = [0 for i in range(0, 2000)]
with open(file_path) as f:
min_t = sys.maxsize
max_t = -sys.maxsize
......@@ -40,17 +50,32 @@ def compute_offsets_stats(file_path):
if i > 0:
val = arrival_tstamp - prev_tstamp
jitter = (val - interval) / 1000
histogram_index = 1000 + jitter
if histogram_index < 0 or histogram_index > 2000:
print("jitter too high: {}\n".format(jitter))
else:
histogram[histogram_index]++
# Update statistics.
# Compute the mean and variance online using Welford's algorithm.
min_t = val if val < min_t else min_t
max_t = val if val > max_t else max_t
min_t = jitter if jitter < min_t else min_t
max_t = jitter if jitter > max_t else max_t
i += 1
prev_tstamp = arrival_tstamp
if i > 0:
print("Jitter: " + str((max_t - min_t) / 1000) + "us")
print("Jitter: {}us".format(max_t - min_t))
measure_set["props"] = [histogram]
data = {}
data["measure_sets"] = [{measure_set}]
path = "tcpdump_histogram"
with open(path, 'w') as outfile:
json.dump(data, outfile)
def main():
parser = argparse.ArgumentParser()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment