-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-iperf-duplex.sh
330 lines (275 loc) · 12.3 KB
/
run-iperf-duplex.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/bin/bash
# cellular-satcom-emulator : Multipath Cellular and Satellite Emulation Testbed
# Copyright (C) 2023 Kaushik Chavali
#
# This file is part of the cellular-satcom-emulator.
#
# cellular-satcom-emulator is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# _osnd_moon_capture_start(output_dir, run_id, route)
function _osnd_moon_capture_start() {
local output_dir="$1"
local run_id="$2"
local route="$3"
log I "Starting tcpdump"
# Server
tmux -L ${TMUX_SOCKET} new-session -s tcpdump-sv -d "sudo ip netns exec osnd-moon-sv bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-sv "ethtool -K gw5 tx off sg off tso off" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-sv "tcpdump -i gw5 -s ${SNAP_LEN} -w ${output_dir}/${run_id}_dump_server_gw5.pcap" Enter
# Client
if [[ "$route" == "LTE" ]]; then
log D "Capturing dump at ue3 (LTE)"
tmux -L ${TMUX_SOCKET} new-session -s tcpdump-cl -d "sudo ip netns exec osnd-moon-cl bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "ethtool -K ue3 tx off sg off tso off" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "tcpdump -i ue3 -s ${SNAP_LEN} -w ${output_dir}/${run_id}_dump_client_ue3.pcap" Enter
elif [[ "$route" == "SAT" ]]; then
log D "Capturing dump at st3 (SATCOM)"
tmux -L ${TMUX_SOCKET} new-session -s tcpdump-cl -d "sudo ip netns exec osnd-moon-cl bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "ethtool -K st3 tx off sg off tso off" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "tcpdump -i st3 -s ${SNAP_LEN} -w ${output_dir}/${run_id}_dump_client_st3.pcap" Enter
else
log D "Capturing dump at ue3 (LTE) and st3 (SATCOM)"
tmux -L ${TMUX_SOCKET} new-session -s tcpdump-cl -d "sudo ip netns exec osnd-moon-cl bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "ethtool -K ue3 tx off sg off tso off" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "ethtool -K st3 tx off sg off tso off" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t tcpdump-cl "tcpdump -i any -s ${SNAP_LEN} -w ${output_dir}/${run_id}_dump_client_ue3_st3.pcap" Enter
fi
}
# _osnd_moon_capture_mptcp_queue_occ(output_dir, run_id, route)
function _osnd_moon_capture_mptcp_queue_occ() {
local output_dir="$1"
local run_id="$2"
local route="$3"
log I "Starting MPTCP Queue Instrumentation"
if [[ "$route" == "MP" ]]; then
tmux -L ${TMUX_SOCKET} new-session -s mptcp-ofo -d "sudo bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t mptcp-ofo "sudo modprobe mptcp_queue_probe" Enter
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t mptcp-ofo "sudo cat /proc/net/mptcp_queue_probe > ${output_dir}/${run_id}_dump_mptcp_queue_occ.log" Enter
fi
}
# _capture_stop(tmux_ns)
function _capture_stop() {
local tmux_ns="$1"
tmux -L ${TMUX_SOCKET} send-keys -t ${tmux_ns} C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t ${tmux_ns} C-d
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} kill-session -t ${tmux_ns} >/dev/null 2>&1
}
# _osnd_moon_capture_stop()
function _osnd_moon_capture_stop() {
local output_dir="$1"
local run_id="$2"
local route="$3"
log I "Stopping tcpdump"
# Server
_capture_stop "tcpdump-sv"
# Client
_capture_stop "tcpdump-cl"
}
# _osnd_moon_iperf_measure_dl(output_dir, run_id, bandwidth, measure_secs, timeout, route)
function _osnd_moon_iperf_measure_dl() {
local output_dir="$1"
local run_id="$2"
local bandwidth="$3"
local measure_secs="$4"
local timeout="$5"
log I "Running iperf client on DL"
tmux -L ${TMUX_SOCKET} new-session -s iperf-cl-dl -d "sudo ip netns exec osnd-moon-sv bash"
sleep $TMUX_INIT_WAIT
if [[ "$route" == "SAT" ]]; then
tmux -L ${TMUX_SOCKET} send-keys -t iperf-cl-dl "${IPERF_BIN} -c ${CL_LAN_CLIENT_IP%%/*} -p 5201 -b ${bandwidth} -t $measure_secs -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_dl_client.log\" 2>&1" Enter
else
tmux -L ${TMUX_SOCKET} send-keys -t iperf-cl-dl "${IPERF_BIN} -c ${CL_LAN_CLIENT_IP_MG%%/*} -p 5201 -b ${bandwidth} -t $measure_secs -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_dl_client.log\" 2>&1" Enter
fi
}
# _osnd_moon_iperf_measure_ul(output_dir, run_id, bandwidth, measure_secs, timeout, route)
function _osnd_moon_iperf_measure_ul() {
local output_dir="$1"
local run_id="$2"
local bandwidth="$3"
local measure_secs="$4"
local timeout="$5"
log I "Running iperf client on UL"
tmux -L ${TMUX_SOCKET} new-session -s iperf-cl-ul -d "sudo ip netns exec osnd-moon-cl bash"
sleep $TMUX_INIT_WAIT
if [[ "$route" == "SAT" ]]; then
tmux -L ${TMUX_SOCKET} send-keys -t iperf-cl-ul "${IPERF_BIN} -c ${SV_LAN_SERVER_IP%%/*} -p 4242 -b ${bandwidth} -t $measure_secs -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_ul_client.log\" 2>&1" Enter
else
tmux -L ${TMUX_SOCKET} send-keys -t iperf-cl-ul "${IPERF_BIN} -c ${SV_LAN_SERVER_IP_MP%%/*} -p 4242 -b ${bandwidth} -t $measure_secs -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_ul_client.log\" 2>&1" Enter
fi
}
# _moon_iperf_client_stop(host_name, tmux_ns)
function _osnd_moon_iperf_client_stop() {
local host_name="$1"
local tmux_ns="$2"
sudo ip netns exec $host_name killall $(basename $IPERF_BIN) -q
tmux -L ${TMUX_SOCKET} kill-session -t $tmux_ns >/dev/null 2>&1
}
# _osnd_moon_iperf_server_dl_start(output_dir, run_id)
function _osnd_moon_iperf_server_dl_start() {
local output_dir="$1"
local run_id="$2"
log I "Starting iperf server on DL"
sudo ip netns exec osnd-moon-sv killall $(basename $IPERF_BIN) -q
tmux -L ${TMUX_SOCKET} new-session -s iperf-dl -d "sudo ip netns exec osnd-moon-cl bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t iperf-dl "${IPERF_BIN} -s -p 5201 -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_dl_server.log\" 2>&1" Enter
}
# _osnd_moon_iperf_server_ul_start(output_dir, run_id)
function _osnd_moon_iperf_server_ul_start() {
local output_dir="$1"
local run_id="$2"
log I "Starting iperf server on UL"
tmux -L ${TMUX_SOCKET} new-session -s iperf-ul -d "sudo ip netns exec osnd-moon-sv bash"
sleep $TMUX_INIT_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t iperf-ul "${IPERF_BIN} -s -p 4242 -i ${REPORT_INTERVAL} > \"${output_dir}/${run_id}_iperf_ul_server.log\" 2>&1" Enter
}
# _moon_iperf_server_stop(tmux_ns, host_name)
function _osnd_moon_iperf_server_stop() {
local tmux_ns="$1"
local host_name="$2"
log I "Stopping iperf server"
tmux -L ${TMUX_SOCKET} send-keys -t $tmux_ns C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t $tmux_ns C-d
sleep $CMD_SHUTDOWN_WAIT
sudo ip netns exec $host_name killall $(basename $IPERF_BIN) -q
tmux -L ${TMUX_SOCKET} kill-session -t $tmux_ns >/dev/null 2>&1
}
# _osnd_moon_capture_mptcp_queue_occ_stop()
function _osnd_moon_capture_mptcp_queue_occ_stop {
log I "Stopping MPTCP Queue Instrumentation"
tmux -L ${TMUX_SOCKET} send-keys -t mptcp-ofo C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t mptcp-ofo "sudo modprobe -r mptcp_queue_probe" Enter
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t mptcp-ofo C-d
}
# _osnd_moon_extract_pcap()
function _osnd_moon_extract_pcap() {
local output_dir="$1"
local run_id="$2"
local file="$3"
xz -T0 ${output_dir}/${run_id}_${file}.pcap
}
# _osnd_moon_process_capture()
function _osnd_moon_process_capture() {
local output_dir="$1"
local run_id="$2"
local route="$3"
log I "Post-processing PCAPs in situ"
# Server
_osnd_moon_extract_pcap "$output_dir" "$run_id" "dump_server_gw5"
# Client
if [[ "$route" == "LTE" ]]; then
_osnd_moon_extract_pcap "$output_dir" "$run_id" "dump_client_ue3"
elif [[ "$route" == "SAT" ]]; then
_osnd_moon_extract_pcap "$output_dir" "$run_id" "dump_client_st3"
else
_osnd_moon_extract_pcap "$output_dir" "$run_id" "dump_client_ue3_st3"
xz -T0 ${output_dir}/${run_id}_dump_mptcp_queue_occ.log
fi
}
# osnd_moon_measure_iperf_tcp_duplex_metrics(scenario_config_name, output_dir, pep=false, route, run_cnt=12)
# Run TCP duplex traffic on the emulation environment with TCP stream on the downlink (DL) emulating a
# constant bitrate (CBR) control traffic, and a RTP over (MP)TCP stream on the uplink (UL) mimicing a
# constant bitrate (CBR) telemetry and video traffic.
function osnd_moon_measure_iperf_tcp_duplex_metrics() {
local scenario_config_name=$1
local output_dir="$2"
local pep=${3:-false}
local route="$4"
local run_cnt=${5:-4}
local -n scenario_config_ref=$scenario_config_name
local base_run_id="tcp_iperf_duplex"
local name_ext=""
local bw_ul="${scenario_config_ref['bw_ul']}"
local bw_dl="${scenario_config_ref['bw_dl']}"
if [[ "$pep" == true ]]; then
base_run_id="${base_run_id}_pep"
name_ext="${name_ext} (PEP)"
fi
for i in $(seq $run_cnt); do
log I "TCP Duplex${name_ext} run $i/$run_cnt"
local run_id="${base_run_id}_$i"
# Environment
osnd_moon_setup $scenario_config_name "$output_dir" "$run_id" "$pep" "$route"
sleep $MEASURE_WAIT
# Start iPerf servers
_osnd_moon_iperf_server_dl_start "$output_dir" "$run_id"
sleep $CMD_SHUTDOWN_WAIT
_osnd_moon_iperf_server_ul_start "$output_dir" "$run_id"
sleep $MEASURE_WAIT
# Proxy
if [[ "$pep" == true ]]; then
_osnd_pepsal_proxies_start "$output_dir" "$run_id"
sleep $MEASURE_WAIT
fi
# Dump packets
_osnd_moon_capture_start "$output_dir" "$run_id" "$route"
# Start logging MPTCP OFO and RCV queue occupancies
_osnd_moon_capture_mptcp_queue_occ "$output_dir" "$run_id" "$route"
# Start iPerf clients
_osnd_moon_iperf_measure_dl "$output_dir" "$run_id" "$bw_dl" $MEASURE_TIME $(echo "${MEASURE_TIME} * 1.2" | bc -l)
_osnd_moon_iperf_measure_ul "$output_dir" "$run_id" "$bw_ul" $MEASURE_TIME $(echo "${MEASURE_TIME} * 1.2" | bc -l)
sleep $MEASURE_TIME
sleep $MEASURE_GRACE
_osnd_moon_iperf_client_stop "osnd-moon-cl" "iperf-cl-ul"
_osnd_moon_iperf_client_stop "osnd-moon-sv" "iperf-cl-dl"
# Cleanup
if [[ "$pep" == true ]]; then
_osnd_pepsal_proxies_stop
fi
_osnd_moon_iperf_server_stop "iperf-dl" "osnd-moon-cl"
_osnd_moon_iperf_server_stop "iperf-ul" "osnd-moon-sv"
_osnd_moon_capture_stop "$output_dir" "$run_id" "$route"
_osnd_moon_capture_mptcp_queue_occ_stop
osnd_moon_teardown
# Do post-processing of PCAPs
_osnd_moon_process_capture "$output_dir" "$run_id" "$route"
sleep $RUN_WAIT
done
}
# 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)"
export CONFIG_DIR="${SCRIPT_DIR}/config"
export OSND_DIR="${SCRIPT_DIR}/quic-opensand-emulation"
set -a
source "${CONFIG_DIR}/testbed-config.sh"
set +a
if [[ "$@" ]]; then
osnd_moon_measure_iperf_tcp_duplex_metrics scenario_config "$@"
else
osnd_moon_measure_iperf_tcp_duplex_metrics scenario_config "." 0 1
fi
fi