forked from maratishe/e2eprobe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_bandwidth.py
More file actions
74 lines (58 loc) · 2.17 KB
/
plot_bandwidth.py
File metadata and controls
74 lines (58 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import base64
import bz2
import json
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
FILE_PATH = "test.bz64jsonl"
methods = []
throughputs = []
with open(FILE_PATH, "r") as f:
for line in f:
line = line.strip()
if not line:
continue
try:
decoded = bz2.decompress(base64.b64decode(line))
data = json.loads(decoded)
method = data.get("method", "unknown")
probe = data.get("probe", [])
psize = int(data.get("psize", 1200))
psize_bits = psize * 8
valid_gaps = [float(g) for g in probe if str(g).lstrip('-').isdigit() and float(g) > 0]
if valid_gaps:
total_time_us = sum(valid_gaps)
thru_mbps = (psize_bits * len(valid_gaps)) / (total_time_us * 1e-6) / 1e6
else:
thru_mbps = 0.0
if method == 'igi':
continue
full_names = {
'pathchirp': 'PathChirp',
'proposed': 'Proposed'
}
methods.append(full_names.get(method, method))
throughputs.append(round(thru_mbps, 2))
print(f" {method}: {len(valid_gaps)} valid gaps, thru = {thru_mbps:.2f} Mbps")
except Exception as e:
print("Skipping line:", e)
if not throughputs:
print("No data found.")
exit()
expected_bw = 5.0
methods_plot = ["Expected"] + methods
throughputs_plot = [expected_bw] + throughputs
plt.figure(figsize=(8, 5))
method_colors = {'PathChirp': '#4CAF50', 'Initial Gap Increasing': '#FF9800', 'Proposed': '#9C27B0'}
colors = ['#2196F3'] + [method_colors.get(m, '#4CAF50') for m in methods]
bars = plt.bar(methods_plot, throughputs_plot, color=colors)
plt.xlabel("Bandwidth Estimation Method")
plt.ylabel("Available Bandwidth (Mbps)")
plt.title("End-to-End Available Bandwidth Estimation")
for i, v in enumerate(throughputs_plot):
plt.text(i, v + 0.1, f"{v:.2f}", ha='center', fontsize=10)
plt.ylim(0, max(throughputs_plot) + 2)
plt.grid(axis='y', linestyle='--', alpha=0.6)
plt.tight_layout()
plt.savefig("bandwidth_plot.png", dpi=150)
print(f"\nPlot saved to bandwidth_plot.png")