-
Notifications
You must be signed in to change notification settings - Fork 6
/
run-quic.sh
executable file
·225 lines (191 loc) · 7.59 KB
/
run-quic.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash
# _osnd_quic_measure(output_dir, run_id, cc, tbs, qbs, ubs, measure_secs, timeout, server_ip)
function _osnd_quic_measure() {
local output_dir="$1"
local run_id="$2"
local cc="$3"
local tbs="$4"
local qbs="$5"
local ubs="$6"
local measure_secs="$7"
local timeout="$8"
local server_ip="$9"
local measure_opt="-t ${measure_secs}"
if [[ "$measure_secs" -lt 0 ]]; then
measure_opt="-e"
fi
log I "Running qperf client"
sudo timeout --foreground $timeout ip netns exec osnd-cl ${QPERF_BIN} -c ${server_ip} -p 18080 --cc ${cc} -i ${REPORT_INTERVAL} -b ${tbs} -q ${qbs} -u ${ubs} $measure_opt --print-raw >"${output_dir}/${run_id}_client.txt"
local status=$?
# Check for error, report if any
if [ "$status" -ne 0 ]; then
local emsg="qperf exited with status $status"
if [ "$status" -eq 124 ]; then
emsg="${emsg} (timeout)"
fi
log E "$emsg"
fi
log D "qperf done"
return $status
}
# _osnd_quic_server_start(output_dir, run_id, cc, tbs, qbs, ubs)
function _osnd_quic_server_start() {
local output_dir="$1"
local run_id="$2"
local cc="$3"
local tbs="$4"
local qbs="$5"
local ubs="$6"
log I "Starting qperf server"
sudo ip netns exec osnd-sv killall qperf -q
tmux -L ${TMUX_SOCKET} new-session -s qperf-server -d "sudo ip netns exec osnd-sv bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-server \
"${QPERF_BIN} -s --tls-cert ${QPERF_CRT} --tls-key ${QPERF_KEY} --cc ${cc} -i ${REPORT_INTERVAL} -b ${tbs} -q ${qbs} -u ${ubs} --listen-addr ${SV_LAN_SERVER_IP%%/*} --listen-port 18080 --print-raw > '${output_dir}/${run_id}_server.txt' 2> >(awk '{print(\"E\", \"qperf-server:\", \$0)}' > ${OSND_TMP}/logging)" \
Enter
}
# _osnd_quic_server_stop()
function _osnd_quic_server_stop() {
log I "Stopping qperf server"
tmux -L ${TMUX_SOCKET} send-keys -t qperf-server C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-server C-d
sleep $CMD_SHUTDOWN_WAIT
sudo ip netns exec osnd-sv killall $(basename $QPERF_BIN) -q
tmux -L ${TMUX_SOCKET} kill-session -t qperf-server >/dev/null 2>&1
}
# _osnd_quic_proxies_start(output_dir, run_id, cc_gw, cc_st, tbs_gw, tbs_st, qbs_gw, qbs_st, ubs_gw, ubs_st)
function _osnd_quic_proxies_start() {
local output_dir="$1"
local run_id="$2"
local cc_gw="$3"
local cc_st="$4"
local tbs_gw="$5"
local tbs_st="$6"
local qbs_gw="$7"
local qbs_st="$8"
local ubs_gw="$9"
local ubs_st="${10}"
log I "Starting qperf proxies"
# Gateway proxy
log D "Starting gateway proxy"
tmux -L ${TMUX_SOCKET} new-session -s qperf-proxy-gw -d "sudo ip netns exec osnd-gwp bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-gw \
"${QPERF_BIN} -P ${SV_LAN_SERVER_IP%%/*} -p 18080 --tls-cert ${QPERF_CRT} --tls-key ${QPERF_KEY} --cc ${cc_gw} -i ${REPORT_INTERVAL} -b ${tbs_gw} -q ${qbs_gw} -u ${ubs_gw} --listen-addr ${GW_LAN_PROXY_IP%%/*} --listen-port 18080 --print-raw > '${output_dir}/${run_id}_proxy_gw.txt' 2> >(awk '{print(\"E\", \"qperf-gw-proxy:\", \$0)}' > ${OSND_TMP}/logging)" \
Enter
# Satellite terminal proxy
log D "Starting satellite terminal proxy"
tmux -L ${TMUX_SOCKET} new-session -s qperf-proxy-st -d "sudo ip netns exec osnd-stp bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-st \
"${QPERF_BIN} -P ${GW_LAN_PROXY_IP%%/*} -p 18080 --tls-cert ${QPERF_CRT} --tls-key ${QPERF_KEY} --cc ${cc_st} -i ${REPORT_INTERVAL} -b ${tbs_st} -q ${qbs_st} -u ${ubs_st} --listen-addr ${CL_LAN_ROUTER_IP%%/*} --listen-port 18080 --print-raw > '${output_dir}/${run_id}_proxy_st.txt' 2> >(awk '{print(\"E\", \"qperf-st-proxy:\", \$0)}' > ${OSND_TMP}/logging)" \
Enter
}
# _osnd_quic_proxies_stop()
function _osnd_quic_proxies_stop() {
log I "Stopping qperf proxies"
# Gateway proxy
log D "Stopping gateway proxy"
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-gw C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-gw C-d
sleep $CMD_SHUTDOWN_WAIT
sudo ip netns exec osnd-gw killall $(basename $QPERF_BIN) -q
tmux -L ${TMUX_SOCKET} kill-session -t qperf-proxy-gw >/dev/null 2>&1
# Satellite terminal proxy
log D "Stopping satellite terminal proxy"
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-st C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t qperf-proxy-st C-d
sleep $CMD_SHUTDOWN_WAIT
sudo ip netns exec osnd-st killall $(basename $QPERF_BIN) -q
tmux -L ${TMUX_SOCKET} kill-session -t qperf-proxy-st >/dev/null 2>&1
}
# _osnd_measure_quic(scenario_config_name, output_dir, pep=false, timing=false, run_cnt=5)
function _osnd_measure_quic() {
local scenario_config_name=$1
local output_dir="$2"
local pep=${3:-false}
local timing=${4:-false}
local run_cnt=${5:-5}
local -n scenario_config_ref=$scenario_config_name
local base_run_id="quic"
local name_ext=""
local measure_secs=$MEASURE_TIME
local timeout=$(echo "${MEASURE_TIME} * 1.1" | bc -l)
local server_ip="${SV_LAN_SERVER_IP%%/*}"
if [[ "$pep" == true ]]; then
base_run_id="${base_run_id}_pep"
name_ext="${name_ext} (PEP)"
server_ip="${CL_LAN_ROUTER_IP%%/*}"
fi
if [[ "$timing" == true ]]; then
base_run_id="${base_run_id}_ttfb"
name_ext="${name_ext} timing"
measure_secs=-1
timeout=4
fi
for i in $(seq $run_cnt); do
log I "QUIC${name_ext} run $i/$run_cnt"
local run_id="${base_run_id}_$i"
# Environment
osnd_setup $scenario_config_name "$output_dir" "$run_id" "$pep"
sleep $MEASURE_WAIT
# Server
_osnd_quic_server_start "$output_dir" "$run_id" "${scenario_config_ref['cc_sv']:-reno}" "${scenario_config_ref['tbs_sv']:-1M}" "${scenario_config_ref['qbs_sv']:-1M}" "${scenario_config_ref['ubs_sv']:-1M}"
sleep $MEASURE_WAIT
# Proxy
if [[ "$pep" == true ]]; then
_osnd_quic_proxies_start "$output_dir" "$run_id" "${scenario_config_ref['cc_gw']:-reno}" "${scenario_config_ref['cc_st']:-reno}" "${scenario_config_ref['tbs_gw']:-1M}" "${scenario_config_ref['tbs_st']:-1M}" "${scenario_config_ref['qbs_gw']:-1M}" "${scenario_config_ref['qbs_st']:-1M}" "${scenario_config_ref['ubs_gw']:-1M}" "${scenario_config_ref['ubs_st']:-1M}"
sleep $MEASURE_WAIT
fi
# Client
_osnd_quic_measure "$output_dir" "$run_id" "${scenario_config_ref['cc_cl']:-reno}" "${scenario_config_ref['tbs_cl']:-1M}" "${scenario_config_ref['qbs_cl']:-1M}" "${scenario_config_ref['ubs_cl']:-1M}" $measure_secs $timeout "$server_ip"
sleep $MEASURE_GRACE
# Cleanup
if [[ "$pep" == true ]]; then
_osnd_quic_proxies_stop
fi
_osnd_quic_server_stop
osnd_teardown
sleep $RUN_WAIT
done
}
# osnd_run_quic_goodput(scenario_config_name, output_dir, pep=false, run_cnt=4)
# Run QUIC goodput measurements on the emulation environment
function osnd_measure_quic_goodput() {
local scenario_config_name=$1
local output_dir="$2"
local pep=${3:-false}
local run_cnt=${4:-4}
_osnd_measure_quic $scenario_config_name "$output_dir" $pep false $run_cnt
}
# osnd_run_quic_ttfb(scenario_config_name, output_dir, pep=false, run_cnt=12)
# Run QUIC timing measurements on the emulation environment
function osnd_measure_quic_timing() {
local scenario_config_name=$1
local output_dir="$2"
local pep=${3:-false}
local run_cnt=${4:-12}
_osnd_measure_quic $scenario_config_name "$output_dir" $pep true $run_cnt
}
# If script is executed directly
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
declare -F log >/dev/null || function log() {
local level="$1"
local msg="$2"
echo "[$level] $msg"
}
declare -A scenario_config
export SCRIPT_VERSION="manual"
export SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
set -a
source "${SCRIPT_DIR}/env.sh"
set +a
if [[ "$@" ]]; then
osnd_measure_quic_goodput scenario_config "$@"
else
osnd_measure_quic_goodput scenario_config "." 0 1
fi
fi