forked from moonlight200/quic-opensand-emulation
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopensand.sh
executable file
·929 lines (848 loc) · 25.3 KB
/
opensand.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
#!/bin/bash
set -o nounset
set -o errtrace
set -o functrace
export SCRIPT_VERSION="1.5.4"
export SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
set -o allexport
source "${SCRIPT_DIR}/env.sh"
set +o allexport
source "${SCRIPT_DIR}/setup.sh"
source "${SCRIPT_DIR}/setup-namespaces.sh"
source "${SCRIPT_DIR}/setup-opensand.sh"
source "${SCRIPT_DIR}/teardown.sh"
source "${SCRIPT_DIR}/teardown-namespaces.sh"
source "${SCRIPT_DIR}/teardown-opensand.sh"
source "${SCRIPT_DIR}/run-ping.sh"
source "${SCRIPT_DIR}/run-quic.sh"
source "${SCRIPT_DIR}/run-tcp.sh"
source "${SCRIPT_DIR}/run-http.sh"
source "${SCRIPT_DIR}/stats.sh"
declare -A pids
# log(level, message...)
# Log a message of the specified level to the output and the log file.
function log() {
local level="$1"
shift
local msg="$@"
if [[ "$level" == "-" ]] || [[ "$msg" == "-" ]]; then
if [[ "$level" == "-" ]]; then
# Level will be read from stdin
level=""
fi
# Log each line in stdin as separate log message
while read -r err_line; do
log $level $err_line
done < <(cat -)
return
fi
local log_time="$(date --rfc-3339=seconds)"
local level_name="INFO"
local level_color="\e[0m"
local visible=true
case $level in
D | d)
level_name="DEBUG"
level_color="\e[2m"
;;
S | s)
level_name="STAT"
level_color="\e[34m"
visible=$show_stats
;;
I | i)
level_name="INFO"
level_color="\e[0m"
;;
W | w)
level_name="WARN"
level_color="\e[33m"
;;
E | e)
level_name="ERROR"
level_color="\e[31m"
;;
*)
# No level given, assume info
msg="$level $msg"
level="I"
level_name="INFO"
level_color="\e[0m"
;;
esac
# Build and print log message
local log_entry="$log_time [$level_name]: $msg"
if [[ "$visible" == true ]]; then
echo -e "$level_color$log_entry\e[0m"
fi
if [ -d "$EMULATION_DIR" ]; then
echo "$log_entry" >>"$EMULATION_DIR/opensand.log"
fi
}
# _osnd_cleanup()
function _osnd_cleanup() {
# Ensure all tmux sessions are closed
tmux -L ${TMUX_SOCKET} kill-server &>/dev/null
# Remove temporary directory
rm -rf "$OSND_TMP" &>/dev/null
}
# _osnd_abort_measurements()
# Trap function executed on the EXIT trap during active measurements.
function _osnd_abort_measurements() {
log E "Aborting measurements"
osnd_teardown 2>/dev/null
for pid in "${pids[@]}"; do
kill $pid &>/dev/null
done
_osnd_cleanup
}
# _osnd_interrupt_measurements()
# Trap function executed when the SIGINT signal is received
function _osnd_interrupt_measurements() {
# Don't just stop the current command, exit the entire script instead
exit 1
}
# _osnd_check_running_emulation()
function _osnd_check_running_emulation() {
# Check for running tmux sessions
if [ ! tmux -L ${TMUX_SOCKET} list-sessions ] &>/dev/null; then
echo >&2 "Active tmux sessions found!"
echo >&2 "Another emulation might already be running, or this is a leftover of a previous run."
echo >&2 "Execute the ./teardown.sh script to get rid of any leftovers."
exit 2
fi
# Check if namespaces exist
for ns in $(sudo ip netns list); do
if [[ "$ns" == "osnd"* ]]; then
echo >&2 "Existing namespace $ns!"
echo >&2 "Another emulation might already be running, or this is a leftover of a previous run."
echo >&2 "Execute the ./teardown.sh script to get rid of any leftovers."
exit 3
fi
done
}
# _osnd_create_emulation_output_dir()
function _osnd_create_emulation_output_dir() {
log D "Creating output directory"
if [ -e "$EMULATION_DIR" ]; then
echo >&2 "Output directory $EMULATION_DIR already exists"
exit 4
fi
mkdir -p "$EMULATION_DIR"
if [ $? -ne 0 ]; then
echo >&2 "Failed to create output directory $EMULATION_DIR"
exit 5
fi
# Create 'latest' symlink
local latest_link="$RESULTS_DIR/latest"
if [ -h "$latest_link" ]; then
rm "$latest_link"
fi
if [ ! -e "$latest_link" ]; then
ln -s "$EMULATION_DIR" "$latest_link"
fi
}
# _osnd_create_emulation_tmp_dir()
function _osnd_create_emulation_tmp_dir() {
log D "Creating temporary directory"
local tmp_dir=$(mktemp -d --tmpdir opensand.XXXXXX)
if [ "$?" -ne 0 ]; then
echo >&2 "Failed to create temporary directory"
exit 6
fi
export OSND_TMP="$tmp_dir"
}
# _osnd_start_logging_pipe()
# Creates a named pipe to be used by processes in tmux sessions to output log messages
function _osnd_start_logging_pipe() {
log D "Starting log pipe"
mkfifo "${OSND_TMP}/logging"
tail -f -n +0 "${OSND_TMP}/logging" > >(log -) &
pids['logpipe']=$!
}
# _osnd_stop_logging_pipe()
function _osnd_stop_logging_pipe() {
log D "Stopping log pipe"
kill ${pids['logpipe']} &>/dev/null
unset pids['logpipe']
rm "${OSND_TMP}/logging"
}
# _osnd_generate_scenarios()
function _osnd_generate_scenarios() {
scenario_file="$OSND_TMP/scenarios"
echo "# Scenario config generated at $(date)" >"$scenario_file"
local common_options="-N ${run_cnt} -T ${ttfb_run_cnt} -P ${env_prime_secs} -D ${dump_packets}"
if [[ "$exec_plain" != "true" ]]; then
common_options="$common_options -V"
fi
if [[ "$exec_pep" != "true" ]]; then
common_options="$common_options -W"
fi
if [[ "$exec_ping" != "true" ]]; then
common_options="$common_options -X"
fi
if [[ "$exec_quic" != "true" ]]; then
common_options="$common_options -Y"
fi
if [[ "$exec_tcp" != "true" ]]; then
common_options="$common_options -Z"
fi
if [[ "$exec_http" != "true" ]]; then
common_options="$common_options -H"
fi
if [[ ${#qlog_file} -le 0 ]]; then
qlog_file="${EMULATION_DIR}/client.qlog,${EMULATION_DIR}/server.qlog"
fi
for orbit in "${orbits[@]}"; do
for attenuation in "${attenuations[@]}"; do
for ccs in "${cc_algorithms[@]}"; do
for tbs in "${transfer_buffer_sizes[@]}"; do
for qbs in "${quicly_buffer_sizes[@]}"; do
for ubs in "${udp_buffer_sizes[@]}"; do
for delay in "${delays[@]}"; do
for loss in "${packet_losses[@]}"; do
for iw in "${iws[@]}"; do
for ack_freq in "${ack_freqs[@]}"; do
local scenario_options="-O ${orbit} -A ${attenuation} -C ${ccs} -B ${tbs} -Q ${qbs} -U ${ubs} -E ${delay} -L ${loss} -I ${iw} -F ${ack_freq} -l ${qlog_file}"
echo "$common_options $scenario_options" >>"$scenario_file"
done
done
done
done
done
done
done
done
done
done
}
# _osnd_count_scenarios()
function _osnd_count_scenarios() {
awk '!/^(#.*)?$/' "$scenario_file" | wc -l
}
# _osnd_read_scenario(config_ref, scenario)
function _osnd_read_scenario() {
local -n config_ref="$1"
local scenario="$2"
local parsed_scenario_args=$(getopt -n "opensand scenario" -o "A:B:C:D:E:F:HI:M:N:l:L:O:P:Q:T:U:VWXYZ" -l "attenuation:,transport-buffers:,congestion-control:,dump:,modulation:,runs:,orbits:,prime:,quicly-buffers:,timing-runs:,delay:,loss:,initial-window:,udp-buffers:,ack-frequency:,qlog-file:,disable-plain,disable-pep,disable-ping,disable-quic,disable-tcp,disable-http" -- $scenario)
local parsing_status=$?
if [ "$parsing_status" != "0" ]; then
return 1
fi
set +o nounset
eval set -- "$parsed_scenario_args"
while :; do
case "$1" in
-A | --attenuation)
config_ref['attenuation']="$2"
shift 2
;;
-B | --transport-buffers)
config_ref['tbs']="$2"
shift 2
;;
-C | --congestion-control)
config_ref['ccs']="$2"
shift 2
;;
-D | --dump)
config_ref['dump']="$2"
shift 2
;;
-E | --delay)
config_ref['delay']="$2"
shift 2
;;
-F | --ack-frequency)
config_ref['ack_freq']="$2"
shift 2
;;
-H | --disable-http)
config_ref['exec_http']="false"
shift 1
;;
-I | --initial-window)
config_ref['iw']="$2"
shift 2
;;
-M | --modulation)
config_ref['modulation_id']="$2"
shift 2
;;
-N | --runs)
config_ref['runs']="$2"
shift 2
;;
-l | --qlog-file)
config_ref['qlog_file']="$2"
shift 2
;;
-L | --loss)
config_ref['loss']="$2"
shift 2
;;
-O | --orbit)
config_ref['orbit']="$2"
shift 2
;;
-P | --prime)
config_ref['prime']="$2"
shift 2
;;
-Q | --quicly-buffers)
config_ref['qbs']="$2"
shift 2
;;
-T | --timing-runs)
config_ref['timing_runs']="$2"
shift 2
;;
-U | --udp-buffers)
config_ref['ubs']="$2"
shift 2
;;
-V | --disable-plain)
config_ref['exec_plain']="false"
shift 1
;;
-W | --disable-pep)
config_ref['exec_pep']="false"
shift 1
;;
-X | --disable-ping)
config_ref['exec_ping']="false"
shift 1
;;
-Y | --disable-quic)
config_ref['exec_quic']="false"
shift 1
;;
-Z | --disable-tcp)
config_ref['exec_tcp']="false"
shift 1
;;
--)
# Stop parsing args
shift 1
break
;;
*)
echo >&2 "Unknown argument while reading scenario: $1"
return 2
;;
esac
done
set -o nounset
}
# _osnd_exec_scenario_with_config(config_name)
function _osnd_exec_scenario_with_config() {
local config_name="$1"
local -n config_ref="$1"
# Create output directory for measurements in this configuration
local measure_output_dir="${EMULATION_DIR}/${config_ref['id']}"
if [ -d "$measure_output_dir" ]; then
log W "Output directory $measure_output_dir already exists"
fi
mkdir -p "$measure_output_dir"
# Save configuration
{
echo "script_version=${SCRIPT_VERSION}"
for config_key in "${!config_ref[@]}"; do
echo "${config_key}=${config_ref[$config_key]}"
done
} | sort >"$measure_output_dir/config.txt"
local run_cnt=${config_ref['runs']:-1}
local run_timing_cnt=${config_ref['timing_runs']:-2}
if [[ "${config_ref['exec_ping']:-true}" == true ]]; then
osnd_measure_ping "$config_name" "$measure_output_dir"
fi
if [[ "${config_ref['exec_quic']:-true}" == true ]]; then
if [[ "${config_ref['exec_plain']:-true}" == true ]]; then
osnd_measure_quic_goodput "$config_name" "$measure_output_dir" false $run_cnt
osnd_measure_quic_timing "$config_name" "$measure_output_dir" false $run_timing_cnt
fi
if [[ "${config_ref['exec_pep']:-true}" == true ]]; then
osnd_measure_quic_goodput "$config_name" "$measure_output_dir" true $run_cnt
osnd_measure_quic_timing "$config_name" "$measure_output_dir" true $run_timing_cnt
fi
fi
if [[ "${config_ref['exec_tcp']:-true}" == true ]]; then
if [[ "${config_ref['exec_plain']:-true}" == true ]]; then
osnd_measure_tcp_goodput "$config_name" "$measure_output_dir" false $run_cnt
osnd_measure_tcp_timing "$config_name" "$measure_output_dir" false $run_timing_cnt
fi
if [[ "${config_ref['exec_pep']:-true}" == true ]]; then
osnd_measure_tcp_goodput "$config_name" "$measure_output_dir" true $run_cnt
osnd_measure_tcp_timing "$config_name" "$measure_output_dir" true $run_timing_cnt
fi
fi
if [[ "${config_ref['exec_http']:-true}" == true ]]; then
if [[ "${config_ref['exec_tcp']:-true}" == true ]]; then
if [[ "${config_ref['exec_plain']:-true}" == true ]]; then
osnd_measure_http "$config_name" "$measure_output_dir" false $run_cnt false
fi
if [[ "${config_ref['exec_pep']:-false}" == true ]]; then
osnd_measure_http "$config_name" "$measure_output_dir" true $run_cnt false
fi
fi
if [[ "${config_ref['exec_quic']:-true}" == true ]]; then
if [[ "${config_ref['exec_plain']:-true}" == true ]]; then
osnd_measure_http "$config_name" "$measure_output_dir" false $run_cnt true
fi
if [[ "${config_ref['exec_pep']:-true}" == true ]]; then
osnd_measure_http "$config_name" "$measure_output_dir" true $run_cnt true
fi
fi
fi
}
#_osnd_get_cc(ccs, index)
function _osnd_get_cc() {
local ccs="$1"
local index=$2
case ${ccs:$index:1} in
c | C)
echo "cubic"
;;
r | R)
echo "reno"
;;
esac
}
# _osnd_run_scenarios()
function _osnd_run_scenarios() {
local measure_cnt=$(_osnd_count_scenarios)
local measure_nr=0
env | sort >"${EMULATION_DIR}/environment.txt"
while read scenario; do
((measure_nr++))
log I "Starting measurement ${measure_nr}/${measure_cnt}"
log D "Reading scenario: $scenario"
unset scenario_config
declare -A scenario_config
# Default configuration values
scenario_config['exec_plain']="true"
scenario_config['exec_pep']="true"
scenario_config['exec_ping']="true"
scenario_config['exec_quic']="true"
scenario_config['exec_tcp']="true"
scenario_config['exec_http']="true"
scenario_config['prime']=5
scenario_config['runs']=1
scenario_config['timing_runs']=4
scenario_config['dump']=0
scenario_config['orbit']="GEO"
scenario_config['attenuation']=0
scenario_config['modulation_id']=1
scenario_config['ccs']="rrrr"
scenario_config['tbs']="1M,1M"
scenario_config['qbs']="1M,1M,1M,1M"
scenario_config['ubs']="1M,1M,1M,1M"
scenario_config['delay']="125,125"
scenario_config['loss']=0
scenario_config['iw']="10,10,10,10"
scenario_config['ack_freq']="25,1000,8"
scenario_config['qlog_file']="${EMULATION_DIR}/client.qlog,${EMULATION_DIR}/server.qlog"
_osnd_read_scenario scenario_config "$scenario"
local read_status=$?
if [ "$read_status" != "0" ]; then
log E "Failed to read scenario($read_status): '$scenario'"
sleep $MEASURE_WAIT
continue
fi
scenario_config['id']="$(md5sum <<<"$scenario" | cut -d' ' -f 1)"
# Extract combined values
scenario_config['cc_sv']="$(_osnd_get_cc "${scenario_config['ccs']}", 0)"
scenario_config['cc_gw']="$(_osnd_get_cc "${scenario_config['ccs']}", 1)"
scenario_config['cc_st']="$(_osnd_get_cc "${scenario_config['ccs']}", 2)"
scenario_config['cc_cl']="$(_osnd_get_cc "${scenario_config['ccs']}", 3)"
local -a tbuf_sizes=()
IFS=',' read -ra tbuf_sizes <<<"${scenario_config['tbs']}"
scenario_config['tbs_gw']="${tbuf_sizes[0]}"
scenario_config['tbs_st']="${tbuf_sizes[1]}"
local -a qbuf_sizes=()
IFS=',' read -ra qbuf_sizes <<<"${scenario_config['qbs']}"
scenario_config['qbs_sv']="${qbuf_sizes[0]}"
scenario_config['qbs_gw']="${qbuf_sizes[1]}"
scenario_config['qbs_st']="${qbuf_sizes[2]}"
scenario_config['qbs_cl']="${qbuf_sizes[3]}"
local -a ubuf_sizes=()
IFS=',' read -ra ubuf_sizes <<<"${scenario_config['ubs']}"
scenario_config['ubs_sv']="${ubuf_sizes[0]}"
scenario_config['ubs_gw']="${ubuf_sizes[1]}"
scenario_config['ubs_st']="${ubuf_sizes[2]}"
scenario_config['ubs_cl']="${ubuf_sizes[3]}"
local -a delays=()
IFS=',' read -ra delays <<<"${scenario_config['delay']}"
scenario_config['delay_gw']="${delays[0]}"
scenario_config['delay_st']="${delays[1]}"
local -a iw_sizes=()
IFS=',' read -ra iw_sizes <<<"${scenario_config['iw']}"
scenario_config['iw_sv']="${iw_sizes[0]}"
scenario_config['iw_gw']="${iw_sizes[1]}"
scenario_config['iw_st']="${iw_sizes[2]}"
scenario_config['iw_cl']="${iw_sizes[3]}"
local -a ack_freq_params=()
IFS=',' read -ra ack_freq_params <<<"${scenario_config['ack_freq']}"
scenario_config['max_ack_delay']="${ack_freq_params[0]}"
scenario_config['first_ack_freq_packet_number']="${ack_freq_params[1]}"
scenario_config['ack_freq_cwnd_fraction']="${ack_freq_params[2]}"
local -a qlog_files=()
IFS=',' read -ra qlog_files <<<"${scenario_config['qlog_file']}"
scenario_config['qlog_file_client']="${qlog_files[0]}"
scenario_config['qlog_file_server']="${qlog_files[1]}"
# Execute scenario
echo "${scenario_config['id']} $scenario" >>"${EMULATION_DIR}/scenarios.txt"
_osnd_exec_scenario_with_config scenario_config
sleep $MEASURE_WAIT
done < <(awk '!/^(#.*)?$/' "$scenario_file")
}
# _osnd_print_usage()
function _osnd_print_usage() {
cat <<USAGE
Usage: $1 [options]
General:
-f <file> read the scenarios from this file instead of the command line arguments.
-h print this help message
-s show statistic logs in stdout
-t <tag> optional tag to identify this measurement
-v print version and exit
Scenario configuration:
-A <#,> csl of attenuations to measure (default: 0db)
-B <#,>* QUIC-specific: csl of two qperf transfer buffer sizes for G and T (default: 1M)
-C <SGTC,> csl of congestion control algorithms to measure (c = cubic, r = reno) (default: r)
-D # dump the first # packets of a measurement
-E <GT,> csl of two delay values: each one value or multiple seconds-delay values (default: 125)
-F <#,>* QUIC-specific: csl of three values: max. ACK Delay, packet no. after which first ack frequency packet is sent, fraction of CWND to be used in ACK frequency frame (default: 25, 1000, 8)
-H disable http measurements
-I <#,>* csl of four initial window sizes for SGTC (default: 10)
-l <#,> QUIC-specific: csl of two file paths for qlog file output: client, server (default: server.qlog und client.qlog in output directory)
-L <#,> percentages of packets to be dropped (default: 0%)
-N # number of goodput measurements per config (default: 1)
-O <#,> csl of orbits to measure (GEO|MEO|LEO) (default: GEO)
-P # seconds to prime a new environment with some pings (default: 5)
-Q <#,>* QUIC-specific: csl of four qperf quicly buffer sizes for SGTC (default: 1M)
-T # number of timing measurements per config (default: 4)
-U <#,>* QUIC-specific: csl of four qperf udp buffer sizes for SGTC (default: 1M)
-V disable plain (non pep) measurements
-W disable pep measurements
-X disable ping measurement
-Y disable quic measurements
-Z disable tcp measurements
Scenario file format:
Each line in the file describes a single scenario, blank lines and lines
starting with a # are ignored. A scenario can be configured using the arguments
in the scenario configuration section above. However all arguments that accept
a comma separated list of values only accept a single value in the scenario
file. Same goes for the repeated arguments, only one value is accepted.
<#,> indicates that the argument accepts a comma separated list (csl) of values
...* indicates, that the argument can be repeated multiple times
SGTC specifies one value for each of the emulation components:
server, gateway, satellite terminal and client
USAGE
}
function _osnd_parse_args() {
show_stats=false
osnd_tag=""
env_prime_secs=5
ttfb_run_cnt=4
run_cnt=1
exec_plain=true
exec_pep=true
exec_ping=true
exec_quic=true
exec_tcp=true
exec_http=true
scenario_file=""
dump_packets=0
qlog_file=""
local -a new_transfer_buffer_sizes=()
local -a new_quicly_buffer_sizes=()
local -a new_udp_buffer_sizes=()
local -a new_delays=()
local -a new_quicly_iw_sizes=()
local -a new_quicly_ack_freq=()
local measure_cli_args="false"
while getopts ":f:hst:vA:B:C:D:E:F:HI:l:L:N:O:P:Q:T:U:VWXYZ" opt; do
if [[ "${opt^^}" == "$opt" ]]; then
measure_cli_args="true"
if [[ "$scenario_file" != "" ]]; then
echo >&2 "Cannot configure measurements with cli args when scenario file is given"
exit 1
fi
fi
case "$opt" in
f)
if [[ "$measure_cli_args" == "true" ]]; then
echo >&2 "Cannot set scenario file and configure measurements with cli args at the same time"
exit 1
fi
scenario_file="$OPTARG"
;;
h)
_osnd_print_usage "$0"
exit 0
;;
s)
show_stats=true
;;
t)
osnd_tag="_$OPTARG"
;;
v)
echo "opensand-measurement $SCRIPT_VERSION"
exit 0
;;
A)
IFS=',' read -ra attenuations <<<"$OPTARG"
;;
B)
IFS=',' read -ra buffer_sizes_config <<<"$OPTARG"
if [[ "${#buffer_sizes_config[@]}" != 2 ]]; then
echo "Need exactly two transfer buffer size configurations for G and T, ${#buffer_sizes_config[@]} given in '$OPTARG'"
exit 1
fi
new_transfer_buffer_sizes+=("$OPTARG")
;;
C)
IFS=',' read -ra cc_algorithms <<<"$OPTARG"
for ccs in "${cc_algorithms[@]}"; do
if [[ "${#ccs}" != 4 ]]; then
echo "Need exactly four cc algorithms for SGT, ${#ccs} given in '$ccs'"
exit 1
fi
for i in 0 1 2 3; do
if [[ "$(_osnd_get_cc "$ccs" $i)" == "" ]]; then
echo "Unknown cc algorithm '${ccs:$i:1}' in '$ccs'"
exit 1
fi
done
done
;;
D)
if [[ "$OPTARG" =~ ^[0-9]+$ ]]; then
dump_packets=$OPTARG
else
echo "Invalid integer value for -D"
exit 1
fi
;;
E)
IFS=',' read -ra delay_values <<<"$OPTARG"
if [[ "${#delay_values[@]}" != 2 ]]; then
echo "Need exactly two delay values, ${#delay_values[@]} given in '${delay_values[@]}'"
exit 1
else
for delay in "${delay_values[@]}"; do
IFS=';' read -ra procDelays <<< "${delay}"
if [[ "${#procDelays[@]}" == 1 ]]; then
if ! [[ "${procDelays[0]}" =~ ^[0-9]+$ ]]; then
echo "Invalid integer value for -E"
exit 1
fi
else
for delayFileLine in "${procDelays[@]}"; do
IFS='-' read -ra procDelayFileLine <<< "${delayFileLine}"
if [[ "${#procDelayFileLine[@]}" != 2 ]]; then
echo "Invalid integer value for -E"
exit 1
fi
for procDelayFileLine in "${procDelayFileLine[@]}"; do
if ! [[ "${procDelayFileLine}" =~ ^[0-9]+$ ]]; then
echo "Invalid integer value for -E"
exit 1
fi
done
done
fi
done
fi
new_delays+=("$OPTARG")
;;
F)
IFS=',' read -ra ack_freq_values <<<"$OPTARG"
if [[ "${#ack_freq_values[@]}" != 3 ]]; then
echo "Need exactly three ack frequency values, ${#ack_freq_values[@]} given in '${ack_freq_values[@]}'"
exit 1
else
for ack_freq in "${ack_freq_values[@]}"; do
if ! [[ "${ack_freq}" =~ ^[0-9]+$ ]]; then
echo "Invalid integer value for -F"
exit 1
fi
done
if [[ ack_freq_values[1] -gt 65535 ]]; then
echo "First packet number has the type uint16 and cannot be larger than 65535"
exit 1
fi
if [[ ack_freq_values[2] -gt 255 ]]; then
echo "CWND fraction has the type uint8 and cannot be larger than 255"
exit 1
fi
fi
new_quicly_ack_freq+=("$OPTARG")
;;
H)
exec_http=false
;;
I)
IFS=',' read -ra iw_sizes_config <<< "$OPTARG"
if [[ "${#iw_sizes_config[@]}" != 4 ]]; then
echo "Need exactly four initial window configurations for SGTC, ${#iw_sizes_config[@]} given in '$OPTARG'"
exit 1
else
for iw in "${iw_sizes_config[@]}"; do
if ! [[ "${iw}" =~ ^[0-9]+$ ]]; then
echo "Invalid integer value for -I"
exit 1
fi
done
fi
new_quicly_iw_sizes+=("$OPTARG")
;;
l)
IFS=',' read -ra qlog_files <<< "$OPTARG"
if [[ "${#qlog_files[@]}" != 2 ]]; then
echo "Need exactly two files, ${#qlog_files[@]} given in '$OPTARG'"
exit 1
fi
qlog_file=$OPTARG
;;
L)
IFS=',' read -ra packet_losses <<<"$OPTARG"
for loss in "${packet_losses[@]}"; do
if ! [[ "${loss}" =~ ^[0-9]+(.[0-9]+)?$ ]]; then
echo "Invalid float value for -L"
exit 1
fi
done
;;
N)
if [[ "$OPTARG" =~ ^[0-9]+$ ]]; then
run_cnt=$OPTARG
else
echo "Invalid integer value for -N"
exit 1
fi
;;
O)
IFS=',' read -ra orbits <<<"$OPTARG"
;;
P)
if [[ "$OPTARG" =~ ^[0-9]+$ ]]; then
env_prime_secs=$OPTARG
else
echo "Invalid integer value for -P"
exit 1
fi
;;
Q)
IFS=',' read -ra buffer_sizes_config <<<"$OPTARG"
if [[ "${#buffer_sizes_config[@]}" != 4 ]]; then
echo "Need exactly four quicly buffer size configurations for SGTC, ${#buffer_sizes_config[@]} given in '$OPTARG'"
exit 1
fi
new_quicly_buffer_sizes+=("$OPTARG")
;;
T)
if [[ "$OPTARG" =~ ^[0-9]+$ ]]; then
ttfb_run_cnt=$OPTARG
else
echo "Invalid integer value for -T"
exit 1
fi
;;
U)
IFS=',' read -ra buffer_sizes_config <<<"$OPTARG"
if [[ "${#buffer_sizes_config[@]}" != 4 ]]; then
echo "Need exactly four udp buffer size configurations for SGTC, ${#buffer_sizes_config[@]} given in '$OPTARG'"
exit 1
fi
new_udp_buffer_sizes+=("$OPTARG")
;;
V)
exec_plain=false
;;
W)
exec_pep=false
;;
X)
exec_ping=false
;;
Y)
exec_quic=false
;;
Z)
exec_tcp=false
;;
:)
echo "Argumet required for -$OPTARG" >&2
echo "$0 -h for help" >&2
exit 1
;;
?)
echo "Unknown argument -$OPTARG" >&2
echo "$0 -h for help" >&2
exit 2
;;
esac
done
if [[ "${#new_transfer_buffer_sizes[@]}" > 0 ]]; then
transfer_buffer_sizes=("${new_transfer_buffer_sizes[@]}")
fi
if [[ "${#new_quicly_buffer_sizes[@]}" > 0 ]]; then
quicly_buffer_sizes=("${new_quicly_buffer_sizes[@]}")
fi
if [[ "${#new_udp_buffer_sizes[@]}" > 0 ]]; then
udp_buffer_sizes=("${new_udp_buffer_sizes[@]}")
fi
if [[ "${#new_delays[@]}" > 0 ]]; then
delays=("${new_delays[@]}")
fi
if [[ "${#new_quicly_iw_sizes[@]}" > 0 ]]; then
iws=("${new_quicly_iw_sizes[@]}")
fi
if [[ "${#new_quicly_ack_freq[@]}" > 0 ]]; then
ack_freqs=("${new_quicly_ack_freq[@]}")
fi
}
function _main() {
declare -a orbits=("GEO")
declare -a attenuations=(0)
declare -a cc_algorithms=("rrrr")
declare -a transfer_buffer_sizes=("1M,1M")
declare -a quicly_buffer_sizes=("1M,1M,1M,1M")
declare -a udp_buffer_sizes=("1M,1M,1M,1M")
declare -a delays=("125,125")
declare -a packet_losses=(0)
declare -a iws=("10,10,10,10")
declare -a ack_freqs=("25,1000,8")
_osnd_parse_args "$@"
_osnd_check_running_emulation
emulation_start="$(date +"%Y-%m-%d-%H-%M")"
export EMULATION_DIR="${RESULTS_DIR}/${emulation_start}_opensand${osnd_tag}"
_osnd_create_emulation_output_dir
_osnd_create_emulation_tmp_dir
if [[ "$scenario_file" == "" ]]; then
_osnd_generate_scenarios
fi
log I "Starting Opensand satellite emulation measurements"
# Start printing stats
osnd_stats_every 4 &
pids['stats']=$!
_osnd_start_logging_pipe
trap _osnd_abort_measurements EXIT
trap _osnd_interrupt_measurements SIGINT
_osnd_run_scenarios 2> >(log E -)
trap - SIGINT
trap - EXIT
log I "All measurements are done, cleaning up"
_osnd_stop_logging_pipe
kill ${pids['stats']} &>/dev/null
unset pids['stats']
_osnd_cleanup
log I "Done with all measurements"
}
# If script is executed directly
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
_main "$@"
fi