Commit bf32e00e authored by Juliane Aulbach's avatar Juliane Aulbach

Adapt ss to print BBR v2 values and framework to use them

parent 850833ad
......@@ -439,6 +439,15 @@ def parse_buffer_backlog(path):
f.close()
return output
def parse_bw(bw):
if 'Mbps' in bw:
return float(bw.replace('Mbps', '')) * 1000000
elif 'Kbps' in bw:
return float(bw.replace('Kbps', '')) * 1000
elif 'bps' in bw:
return float(bw.replace('bps', ''))
else:
return 0
def parse_bbr_and_cwnd_values(path):
cwnd_values = {}
......@@ -453,7 +462,7 @@ def parse_bbr_and_cwnd_values(path):
cwnd_values[i] = ([], [], [])
bbr_values[i] = ([], [], [], [], [], [])
bbr2_values[i] = ([], [], [])
bbr2_values[i] = ([], [], [], [], [], [], [], [])
f = open_compressed_file(file_path)
......@@ -486,14 +495,7 @@ def parse_bbr_and_cwnd_values(path):
pacing_gain = float(bbr[2])
cwnd_gain = float(bbr[3])
if 'Mbps' in bbr[0]:
bw = float(bbr[0].replace('Mbps', '')) * 1000000
elif 'Kbps' in bbr[0]:
bw = float(bbr[0].replace('Kbps', '')) * 1000
elif 'bps' in bbr[0]:
bw = float(bbr[0].replace('bps', ''))
else:
bw = 0
bw = parse_bw(bbr[0])
rtt = float(bbr[1])
......@@ -505,17 +507,23 @@ def parse_bbr_and_cwnd_values(path):
bbr_values[i][5].append(bw * rtt / 1000)
if split[4] != '':
bbr2 = split[4].replace('bbr_bw_lo=', '')\
.replace('bbr_bw_hi=','')
# bw_hi, bw_lo, mode, phase, inflight_lo, inflight_hi
bbr2 = split[4]
bbr2 = bbr2.split(',')
bbr_bw_lo = int(bbr2[0], 16)
bbr_bw_hi = int(bbr2[1], 16)
bbr2_values[i][0].append(timestamp)
bbr2_values[i][1].append(bbr_bw_lo)
bbr2_values[i][2].append(bbr_bw_hi)
parameters = ['bw_hi:', 'bw_lo:', 'mode:', 'phase:', 'inflight_lo:', 'inflight_hi:', 'extra_acked']
for index, parameter in enumerate(parameters):
value = 0
for postion in bbr2:
if parameter in postion:
value = postion.replace(parameter,'')
#if parameter == 'bw_hi:' or parameter == 'bw_lo:':
if parameter == 'bw_hi:':
value = parse_bw(value)
break
bbr2_values[i][index+1].append(value)
f.close()
return cwnd_values, bbr_values, bbr2_values
......
......@@ -25,7 +25,7 @@ PLOT_TYPES = [
'rt_prop',
'window_gain',
'pacing_gain',
'bbr_bw_lo_hi',
'inflight_lo_hi',
]
......
......@@ -143,9 +143,9 @@ def plot_all(path, pcap_data, plot_only, hide_total=False, all_plots=False):
has_bbr2 = True
break
if 'bbr_bw_lo_hi' in plot_only and has_bbr2:
if 'inflight_lo_hi' in plot_only and has_bbr2:
plots += [
Plot(bbr2_values, plot_bbr_bw_lo_hi, 'plot_bbr_bw_lo_hi.pdf', 'BBR2 BW Lo and Hi', 'bit', len(bbr2_values)),
Plot(bbr2_values, plot_inflight_lo_hi, 'plot_inflight_lo_hi.pdf', 'BBR2 BW Lo and Hi', 'bit', len(bbr2_values)),
]
if all_plots:
......@@ -440,17 +440,17 @@ def plot_diff_inflight_bdp(data, p_plt):
p_plt.plot(ts, diff, label='{}'.format(c))
def plot_bbr_bw_lo_hi(bbr_bw_lo_hi, p_plt):
def plot_inflight_lo_hi(inflight_lo_hi, p_plt):
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
p_plt.plot([], [], label='bbr_bw_lo', color='black')
p_plt.plot([], [], ':', label='bbr_bw_hi', color='black')
p_plt.plot([], [], label='inflight_lo', color='black')
p_plt.plot([], [], ':', label='inflight_hi', color='black')
p_plt.legend()
for i, c in enumerate(bbr_bw_lo_hi):
data = bbr_bw_lo_hi[c]
p_plt.plot(data[0], data[1], color=colors[i % len(colors)])
p_plt.plot(data[0], data[2], ':', color=colors[i % len(colors)])
for i, c in enumerate(inflight_lo_hi):
data = inflight_lo_hi[c]
p_plt.plot(data[0], data[6], color=colors[i % len(colors)])
p_plt.plot(data[0], data[7], ':', color=colors[i % len(colors)])
def filter_smooth(data, size, repeat=1):
......
File added
......@@ -2,15 +2,14 @@ while true;
do
# ‘s/regexp/replacement/flags’
# -E: use normal RegEx syntax
# tr: remove newlines
# sed #2: reorder output - very ugly, but the only solution I found
# -e#1: BBR v2 with pacing_gain and cwnd_gain being optional
# -e#2: BBR v1
# -e#3: Cubic
# ts: add timestamp
strace ss -tin 2>&1 | sed -En \
-e 's/.* cwnd:([0-9]*).* bbr:\(([^)]*)\).*/\1;;\2;/p' \
-e 's/.* \{(bbr_bw_lo=[^,]*),\s(bbr_bw_hi=[^,]*).*/\1,\2;/p' \
./ss -tin | sed -En \
-e 's/.* cwnd:([0-9]*).* bbr:\((.*mrtt:[0-9.]*.*),(bw_hi:[^)]*).*/\1;;\2;\3;/p' \
-e 's/.* cwnd:([0-9]*).* bbr:\(([^)]*)\).*/\1;;\2/p' \
-e 's/.* cwnd:([0-9]*).* ssthresh:([0-9]*).*/\1;\2;/p' \
| tr -d '\n' \
| sed -En -e 's/(bbr_bw_lo=[^,]*,bbr_bw_hi=[^;]*;)(.*)/\2\1\n/p' \
| ts '%.s;'
sleep $1;
done
\ No newline at end of file
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