-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfl
executable file
·2770 lines (2399 loc) · 64.3 KB
/
fl
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
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#############################################################################
#
# CONFIG FUNCTIONS
#
#
SOURCE_DIR=$(dirname "$BASH_SOURCE[0]")
# config_files emits names of the config files
config_files() {
local exclude_regex="$1"
# end of params
for f in $SOURCE_DIR/config/fl_*; do
[[ $exclude_regex && $f =~ $exclude_regex ]] || echo "$f"
done
}
# source includes
if [ -d "$SOURCE_DIR/config" ]; then
for f in $(config_files); do
. "$f"
done
fi
#############################################################################
#
# GLOBALS
#
#
# fl.sh ssh destinations
FL_SSH=($MGMT_SSH $SCE_CLI_SSH $L4S_CLI_SSH)
# clients
CLIENTS_SSH=($SCE_CLI_SSH $L4S_CLI_SSH)
# push config
PUSH_RSYNC_DEST="$PUSH_SSH_DEST:$ARCHIVE_DIR"
#############################################################################
#
# PLOT FUNCTIONS
#
#
# plot_tattr emits a title attribute
plot_tattr() {
local key="$1"
local tattrs=($2)
# end of params
for a in "${tattrs[@]}"; do
IFS=":" read k v <<< "$a"
if [ "$key" == "$k" ]; then
echo "$v"
return 0
fi
done
}
# plot_rtt_scale emits the plot's RTT scale from the base RTT
plot_rtt_scale() {
case $1 in
10ms) echo "10,60" ;;
20ms) echo "20,70" ;;
80ms) echo "80,150" ;;
160ms) echo "160,260" ;;
500ms) echo "500,1000" ;;
*) echo "0,200" ;;
esac
}
# plot_bandwidth_scale emits the plot's bandwidth scale from the bandwidth
plot_bandwidth_scale() {
case $1 in
1Mbit|*/1Mbit) echo "0,1.2" ;;
5Mbit|*/5Mbit) echo "0,6" ;;
10Mbit|*/10Mbit) echo "0,12" ;;
20Mbit|*/20Mbit) echo "0,25" ;;
25Mbit|*/25Mbit) echo "0,30" ;;
50Mbit|*/50Mbit) echo "0,55" ;;
100Mbit|*/100Mbit) echo "0,110" ;;
200Mbit|*/200Mbit) echo "0,220" ;;
250Mbit|*/250Mbit) echo "0,260" ;;
1Gbit|*/1Gbit) echo "0,1050" ;;
*) echo "0,1050" ;;
esac
}
# plot_cc_algo_title emits the title of a CC algo from its key string
plot_cc_algo_title() {
case $1 in
cubic) echo "CUBIC" ;;
cubic-sce) echo "CUBIC-SCE" ;;
reno) echo "Reno" ;;
reno-sce) echo "Reno-SCE" ;;
dctcp) echo "DCTCP" ;;
dctcp-sce) echo "DCTCP-SCE" ;;
prague) echo "Prague" ;;
bbr) echo "BBR" ;;
*) echo "UnknownCC" ;;
esac
}
plot_vs_title() {
case $1 in
cubic-vs-cubic-sce) echo "CUBIC vs CUBIC-SCE" ;;
cubic-vs-cubic) echo "CUBIC vs CUBIC" ;;
cubic-vs-cubic-ect1) echo "CUBIC vs CUBIC(ECT1)" ;;
cubic-vs-prague) echo "CUBIC vs Prague" ;;
cubic-vs-cubic-ecn) echo "CUBIC vs CUBIC(ECN)" ;;
cubic-vs-cubic-noecn) echo "CUBIC vs CUBIC(Non-ECN)" ;;
cubic-vs-cubic-noecn-10mbps) echo "CUBIC vs CUBIC(Non-ECN 10Mbps)" ;;
cubic-ecn-vs-prague) echo "CUBIC(ECN) vs Prague" ;;
cubic-noecn-vs-prague) echo "CUBIC(Non-ECN) vs Prague" ;;
prague-vs-cubic) echo "Prague vs CUBIC" ;;
prague-vs-reno) echo "Prague vs Reno" ;;
prague-vs-prague) echo "Prague vs Prague" ;;
prague-vs-cubic-ecn) echo "Prague vs CUBIC(ECN)" ;;
prague-vs-cubic-noecn) echo "Prague vs CUBIC(Non-ECN)" ;;
prague-vs-reno) echo "Prague vs Reno" ;;
prague-vs-reno-ecn) echo "Prague vs Reno(ECN)" ;;
prague-vs-reno-noecn) echo "Prague vs Reno(Non-ECN)" ;;
reno-vs-reno) echo "Reno vs Reno" ;;
reno-ecn-vs-prague) echo "Reno(ECN) vs Prague" ;;
reno-noecn-vs-prague) echo "Reno(Non-ECN) vs Prague" ;;
bbr-vs-cubic-sce) echo "BBR vs CUBIC-SCE" ;;
bbr-vs-prague) echo "BBR vs Prague" ;;
*) echo "UnknownVS" ;;
esac
}
# plot_arch_title emits the title of the architecture from its key string
plot_arch_title() {
case $1 in
sce) echo "SCE" ;;
l4s) echo "L4S" ;;
*) echo "UnknownArch" ;;
esac
}
# plot_qdisc_title emits the qdisc title from its key string
plot_qdisc_title() {
case $1 in
*cake*) echo "Cake FQ" ;;
*cnq_codel_af*) echo "CNQ-CodelAF" ;;
*twin_codel_af*) echo "Twin-CodelAF" ;;
*lfq_cobalt*) echo "LFQ-COBALT" ;;
*dualpi2*) echo "DualPI2" ;;
*pie*) echo "PIE" ;;
*) echo "$1" ;;
esac
}
# plot_file generates one plot
plot_file() {
local arch="$1"
local in="$2"
local plot="$3"
local scenario=$4
# end of params
# jq_test_param emits a test parameter value from a .flent.gz file
jq_test_param() {
gzip -dc $in | jq -r ".metadata.TEST_PARAMETERS.$1"
}
# jq_title emits the metadata title from a .flent.gz file
jq_title() {
gzip -dc $in | jq -r ".metadata.TITLE"
}
# jq_batch_name emits the metadata batch name from a .flent.gz file
jq_batch_name() {
gzip -dc $in | jq -r ".metadata.BATCH_NAME"
}
# jq_scale_rtt emits the max RTT Y value calculated from the data values
jq_scale_rtt() {
gzip -dc "$in" | \
jq "(.results.\"Ping (ms) ICMP\"+.results.\"TCP upload::tcp_rtt\"|max-$rttval)*3+$rttval"
}
# read params from flent file
local cc_algo=$(jq_test_param cc_algo)
[[ $cc_algo == "null" ]] && cc_algo=$(jq_test_param tcp_cong_control)
local cc_algos=$(jq_test_param cc_algos)
local cc_algo_titles=$(jq_test_param cc_algo_titles)
local plot_title=$(jq_test_param plot_title)
local subtitle=$(jq_title)
local batch_name=$(jq_batch_name)
local rtt=$(plot_tattr rtt "$subtitle")
local rtt2=$(plot_tattr rtt2 "$subtitle")
local rttval=${rtt//[!0-9]/}
local bandwidth=$(plot_tattr bandwidth "$subtitle")
local vs=$(plot_tattr vs "$subtitle")
local qdisc=$(plot_tattr qdisc "$subtitle")
local tunnel=$(plot_tattr tunnel "$subtitle")
# output path
local outdir=$(dirname "$in")
local outfile=$(basename "$in")
outfile="${outfile#"batch-"}"
outfile="${outfile%".flent.gz"}"
outfile+="_$plot"
local outpath="$outdir/$outfile.$PLOT_FORMAT"
# further calculated params
local rtt_scale=$(plot_rtt_scale $rtt)
local bandwidth_scale=$(plot_bandwidth_scale $bandwidth)
local cc_title=$(plot_cc_algo_title $cc_algo)
local arch_title=$(plot_arch_title $arch)
local vs_title=$(plot_vs_title $vs)
local colors
[[ $COLORS ]] && colors="$COLORS"
# plot visitor assigned params
local title
local subtitle2
# other locals
local tput_name
local tput_abbrev
local tput_title
if [[ $plot =~ delivery ]]; then
tput_name="delivery rate"
tput_abbrev="delivery"
tput_title="Delivery Rate"
else
tput_name="throughput"
tput_abbrev="thruput"
tput_title="Throughput"
fi
# start empty array for arguments
local fl_args=()
# plot visitor assigns title and additional arguments
plot_${scenario}_${plot}
# common args
fl_args+=( "-i" "$in" )
fl_args+=( "-p" "$plot" )
fl_args+=( "-o" "$outpath" )
fl_args+=( "--figure-width" "$PLOT_WIDTH" )
fl_args+=( "--figure-height" "$PLOT_HEIGHT" )
[[ $colors ]] && fl_args+=("--colours" "$colors" )
fl_args+=( "--fallback-layout" )
# plot-specific args
case $plot in
tcp_delivery_with_rtt)
fl_args+=( "--bounds-y" "$bandwidth_scale" )
fl_args+=( "--bounds-y" "$rtt_scale" )
fl_args+=( "--label-y" "Mbps" )
fl_args+=( "--label-y" "ms" )
;;
box_totals)
fl_args+=( "--bounds-y" "$bandwidth_scale" )
fl_args+=( "--bounds-y" "$rtt_scale" )
;;
esac
local final_title=$(printf "%s\n\n%s" "$title" "$subtitle")
if [[ $subtitle2 ]]; then
final_title=$(printf "%s\n%s" "$final_title" "$subtitle2")
fi
fl_args+=( "--override-title" "$final_title" )
flent "${fl_args[@]}"
}
# plot_s1_tcp_delivery_with_rtt is the plot visitor for scenario 1
plot_s1_tcp_delivery_with_rtt() {
local IFS=,
local rtts=($rtt $rtt2)
local cca
local i
local r
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
i=0
for cca in $cc_algos; do
(( i == 0 )) && r=$rtt || r=$rtt2
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $r $tput_name" )
((i++))
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
i=0
for cca in $cc_algos; do
(( i == 0 )) && r=$rtt || r=$rtt2
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $r TCP RTT" )
((i++))
done
s1_colors_tput() {
local cubic1="#E41A1C"
local cubic2="#377EB8"
local prague1="#4DAF4A"
local prague2="#984EA3"
case "$cc_algos" in
cubic,cubic) echo -n "'$cubic1','$cubic2'," ;;
cubic,prague) echo -n "'$cubic1','$prague1'," ;;
prague,cubic) echo -n "'$prague1','$cubic1'," ;;
prague,prague) echo -n "'$prague1','$prague2'," ;;
*) return 1 ;;
esac
}
s1_colors_tcp_rtt() {
local cubic1="#FF7F00"
local cubic2="#FFFF33"
local prague1="#A65628"
local prague2="#F781BF"
case "$cc_algos" in
cubic,cubic) echo -n "'$cubic1','$cubic2'," ;;
cubic,prague) echo -n "'$cubic1','$prague1'," ;;
prague,cubic) echo -n "'$prague1','$cubic1'," ;;
prague,prague) echo -n "'$prague1','$prague2'," ;;
*) return 1 ;;
esac
}
s1_add_colors() {
local c
c="$(s1_colors_tput)" || return 1
c+="'#7F7F7F',"
c+="$(s1_colors_tcp_rtt)" || return 1
colors="$c"
}
s1_add_colors
plot_1_rtt_scale() {
case $1 in
pfifo*) echo "0,2000" ;;
*) echo "0,1000" ;;
esac
}
rtt_scale=$(plot_1_rtt_scale $qdisc)
title="$arch_title: RTT Fairness for $vs_title at $rtt and $rtt2"
}
# plot_s1_box_totals is the plot visitor for scenario 1
# TODO convert to upload_box plot
#plot_s1_box_totals() {
# plot_rtt_scale_s1() {
# case $1 in
# 20ms) echo "20,1000" ;;
# 80ms) echo "80,2000" ;;
# *) echo "0,200" ;;
# esac
# }
# rtt_scale=$(plot_rtt_scale_s1 $rtt2)
#
# title="$arch_title: RTT Fairness for $vs_title at $rtt and $rtt2"
#}
# plot_s2_tcp_delivery_with_rtt is the plot visitor for scenario 2
plot_s2_tcp_delivery_with_rtt() {
local bandwidth1=$(plot_tattr bandwidth1 "$subtitle")
title="$arch_title: Rate Reduction for $cc_title with $(plot_qdisc_title $qdisc), $bandwidth → $bandwidth1 at $rtt"
fl_args+=( "--override-label" "$cc_algo $tput_name" )
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "TCP RTT" )
plot_s2_rtt_scale() {
case $1 in
20ms) echo "0,1000" ;;
80ms) echo "0,2000" ;;
*) echo "0,200" ;;
esac
}
rtt_scale=$(plot_s2_rtt_scale $rtt)
}
# plot_s3_tcp_delivery_with_rtt is the plot visitor for scenario 3
plot_s3_tcp_delivery_with_rtt() {
local bandwidth1=$(plot_tattr bandwidth1 "$subtitle")
title="$arch_title: Variable Rate for $cc_title with $(plot_qdisc_title $qdisc), $bandwidth at $rtt"
fl_args+=( "--override-label" "$cc_algo $tput_name" )
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "TCP RTT" )
plot_s3_rtt_scale() {
case $1 in
20ms) echo "0,500" ;;
80ms) echo "0,2000" ;;
*) echo "0,200" ;;
esac
}
rtt_scale=$(plot_s3_rtt_scale $rtt)
}
# plot_s4_all_scaled_delivery is the plot visitor for scenario 4
plot_s4_all_scaled_delivery() {
title="$arch_title: Bi-directional $cc_title"
}
# plot_s4_box_totals is the plot visitor for scenario 4
plot_s4_box_totals() {
title="$arch_title: Bi-directional $cc_title"
plot_rtt_scale_s4() {
case $1 in
20ms) echo "0,1000" ;;
80ms) echo "0,2000" ;;
*) echo "0,200" ;;
esac
}
rtt_scale=$(plot_rtt_scale_s4 $rtt)
}
# plot_s5_tcp_delivery_with_rtt is the plot visitor for scenario 5
plot_s5_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
title="$arch_title: $tunnel tunnel, $vs_title"
}
# plot_s6_tcp_delivery_with_rtt is the plot visitor for scenario 6
plot_s6_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
title="$arch_title: $vs_title in $qdisc"
}
# plot_s7_tcp_delivery_with_rtt is the plot visitor for scenario 7
plot_s7_tcp_delivery_with_rtt() {
title="$arch_title: Single $cc_title flow through $qdisc, $rtt rtt"
fl_args+=( "--override-label" "$cc_algo $tput_name" )
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "TCP RTT" )
}
# plot_s8_tcp_delivery_with_rtt is the plot visitor for scenario 8
plot_s8_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
title="$arch_title: $vs_title in $qdisc"
}
# plot_s9_tcp_delivery_with_rtt is the plot visitor for scenario 9
plot_s9_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
rtt_scale="20,500"
title="$arch_title: $tunnel tunnel"
}
# plot_s10_tcp_delivery_with_rtt is the plot visitor for scenario 10
plot_s10_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for ccat in $cc_algo_titles; do
fl_args+=( "--override-label" "$ccat $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for ccat in $cc_algo_titles; do
fl_args+=( "--override-label" "$ccat TCP RTT" )
done
title="$arch_title: ${plot_title}"
}
# plot_s11_tcp_delivery_with_rtt is the plot visitor for scenario 11
plot_s11_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for ccat in $cc_algo_titles; do
fl_args+=( "--override-label" "$ccat $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for ccat in $cc_algo_titles; do
fl_args+=( "--override-label" "$ccat TCP RTT" )
done
title="$arch_title: ${plot_title}"
}
# plot_s12_tcp_delivery_with_rtt is the plot visitor for scenario 12
plot_s12_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
title="$arch_title: $vs_title in $qdisc"
}
# plot_s13_tcp_delivery_with_rtt is the plot visitor for scenario 13
plot_s13_tcp_delivery_with_rtt() {
local IFS=,
local cca
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) $tput_name" )
done
fl_args+=( "--override-label" "ICMP RTT" )
fl_args+=( "--override-label" "" )
fl_args+=( "--override-label" "" )
for cca in $cc_algos; do
fl_args+=( "--override-label" "$(plot_cc_algo_title $cca) TCP RTT" )
done
title="$arch_title: $vs_title in $qdisc"
}
#############################################################################
#
# UTILITY FUNCTIONS
#
#
# fl_ssh runs fl remotely via ssh
fl_ssh() {
local dest=$1; shift # ssh destination
local root=$1; shift # true|false
local background=$1; shift # true|false
local args="$@"
# end of params
local sudo_args
[[ $root == true ]] && sudo_args='$([[ $EUID != 0 ]] && echo sudo)'
local args_esc
args_esc=$(printf %q "$args")
# run directly on hosts with fl script, or via stdout on hosts without
if array_contains $dest "${FL_SSH[@]}"; then
if [[ $background == true ]]; then
ssh $dest cd $SCRIPT_DIR\; nohup $sudo_args ./fl $args_esc \&\>log.txt \&
else
ssh $dest cd $SCRIPT_DIR\; $sudo_args ./fl $args_esc 2>&1 | \
sed "s/^/$dest: /"
return ${PIPESTATUS[0]}
fi
else
if [[ $background == true ]]; then
cat $(config_files) fl | \
ssh $dest $sudo_args nohup bash -s $args_esc \&\> \
\$\(mktemp /tmp/fl.log.XXXXXXXX\) \&
else
cat $(config_files) fl | \
ssh $dest $sudo_args bash -s $args_esc || return $?
fi
fi
}
# fl_node runs fl either via netns or remotely via ssh
fl_node() {
local arch=$1; shift
local net=$1; shift
local node=$1; shift
local args="$@"
# end of params
case $net in
phys)
fl_ssh $(node_ssh $arch $node) true false $args || return $?
;;
ns)
nsx $node ./fl $args || return $?
;;
*)
>&2 echo "unknown net: $net"
return 1
esac
}
# fl_node_pull copies files from a node's directory to a local directory
fl_node_pull() {
local arch=$1
local net=$2
local node=$3
local src_dir="$4"
local dst_dir="$5"
# end of params
case $net in
phys)
ev scp \"$(node_ssh $arch $node):$src_dir/*\" "$dst_dir" || return $?
;;
ns)
ev cp "$src_dir/*" "$dst_dir" || return $?
;;
*)
>&2 echo "unknown net: $net"
return 1
esac
}
# send_pushover sends a pushover message
send_pushover() {
local sound="$1"
local msg="$2"
# end of params
if [[ $PUSHOVER_USER ]]; then
response=$(/usr/bin/curl -s \
--retry 3 \
--form-string token=$PUSHOVER_TOKEN \
--form-string user=$PUSHOVER_USER \
--form-string "sound=$sound" \
--form-string "message=$msg" \
https://api.pushover.net/1/messages.json)
[[ ! "$response" == *"\"status\":1"* ]] && echo "$response" >&2
fi
}
# set_offloads enables or disables offloads for an eth iface
set_offloads() {
local iface="$1"
local state="$2" # on|off
local ns="$3"
# end of params
local cmd
cmd="sudo"
[[ $ns ]] && cmd+=" ip netns exec $ns"
cmd+=" ethtool -K $iface"
cmd+=" rx $state tx $state"
cmd+=" sg $state tso $state"
cmd+=" gso $state gro $state"
cmd+=" rxvlan $state txvlan $state"
$cmd
}
# wait_for_pids waits for processes to exit and returns a count of failures
wait_for_pids() {
local pids=("$@")
# end of params
local errs=0
local p
for p in ${pids[@]}; do
wait $p || ((errs++))
done
return $errs
}
# wait_for_jobs waits until there are fewer than $(nproc) jobs in the background
wait_for_jobs() {
local procs=$(nproc)
while (( $(jobs -p | wc -w) >= $procs )); do
wait -n
done
}
# array_contains succeeds if an array contains an element
array_contains() {
local elem="$1"; shift
local arr=("$@")
# end of params
local e
for e in "${arr[@]}"; do
[[ $e == $elem ]] && return 0
done
return 1
}
# ifb emits the ifb interface name for an interface
ifb() {
local iface=$1
echo "ifb4$iface"
}
# ev emits and evaluates a command
ev() {
local r=0
echo "+ $@"
eval "$@"
r=$?
if [[ $DEBUG == 1 && $r != 0 ]]; then
>&2 echo "command failed with status $r: $@"
fi
echo
return $r
}
# evs runs eval separately for each command separated by ;
evs() {
IFS=';' read -r -a cmds <<< "$@"
local c
local r
for c in "${cmds[@]}"; do
# remove leading and trailing whitespace
c=$(echo $c | awk '{$1=$1};1')
eval $c
r=$?
if (( r != 0 )); then
>&2 echo "command failed with status $r: $c"
return $r
fi
done
}
# ev evaluates a command and only emits it if DEBUG is 1
evq() {
local r
[[ $DEBUG == 1 ]] && echo "+ $@"
eval "$@" &>/dev/null
r=$?
if [[ $DEBUG == 1 && $r != 0 ]]; then
>&2 echo "command failed with status $r: $@"
fi
return $r
}
# split splits a string by comma
split() {
local s=(${1//,/ })
echo "${s[@]}"
}
#############################################################################
#
# IPSEC SUPPORT FUNCTIONS
#
#
setup_ipsec() {
local ns="$1"; shift
local dev="$1"; shift
local src="$1"; shift
local dst="$1"; shift
local local="$1"; shift
local remote="$1"; shift
nsx $ns ip xfrm state flush
nsx $ns ip xfrm policy flush
nsx $ns ip xfrm state add src $src dst $dst proto esp \
spi $NS_IPSEC_ID reqid $NS_IPSEC_REQID \
mode tunnel auth sha256 $NS_IPSEC_KEY1 enc aes $NS_IPSEC_KEY2 \
replay-window 32
nsx $ns ip xfrm state add src $dst dst $src proto esp \
spi $NS_IPSEC_ID reqid $NS_IPSEC_REQID \
mode tunnel auth sha256 $NS_IPSEC_KEY1 enc aes $NS_IPSEC_KEY2 \
replay-window 32
nsx $ns ip xfrm policy add src $local dst $remote \
dir out tmpl src $src dst $dst proto esp \
reqid $NS_IPSEC_REQID mode tunnel
nsx $ns ip xfrm policy add src $remote dst $local \
dir in tmpl src $dst dst $src proto esp \
reqid $NS_IPSEC_REQID mode tunnel
nsx $ns ip link add $NS_IPSEC_IFACE type xfrm dev $dev
nsx $ns ip addr add $local dev $NS_IPSEC_IFACE
nsx $ns ip link set up dev $NS_IPSEC_IFACE
nsx $ns ip route add $remote dev $dev src $local
}
teardown_ipsec() {
local ns="$1"; shift
local dev="$1"; shift
local local="$1"; shift
local remote="$1"; shift
nsx $ns ip xfrm state flush
nsx $ns ip xfrm policy flush
nsx $ns ip route del $remote dev $dev src $local
nsx $ns ip link delete $NS_IPSEC_IFACE
}
#############################################################################
#
# NAMESPACES FUNCTIONS
#
#
# nsx executes a command in a namespace
nsx() {
local ns="$1"; shift
local args="$@"
# end of fixed args
# client is run in default namespace
if [[ $ns == cli ]]; then
sudo $args
else
sudo ip netns exec $ns $args
fi
}
# ns_setup sets up the netns environment
ns_setup() {
local arch=$1
# end of params
# srv
sudo ip netns add srv || return $?
sudo ip link add dev $NS_SRV_LEFT type veth peer name $NS_MID_RIGHT || return $?
sudo ip link set dev $NS_SRV_LEFT netns srv || return $?
nsx srv ip addr add $NS_SRV_NET dev $NS_SRV_LEFT || return $?
nsx srv ip link set $NS_SRV_LEFT up || return $?
# srv wireguard
nsx srv ip link add dev $NS_WG_IFACE type wireguard
nsx srv ip addr add dev $NS_WG_IFACE $NS_SRV_WG_NET peer $NS_CLI_WG_IP
echo $NS_SRV_WG_PRIV > /tmp/ns_srv_wg_priv
nsx srv wg set $NS_WG_IFACE listen-port $NS_WG_PORT private-key /tmp/ns_srv_wg_priv peer "$NS_CLI_WG_PUB" allowed-ips $NS_CLI_WG_IP endpoint $NS_CLI_IP:$NS_WG_PORT
nsx srv ip link set up dev $NS_WG_IFACE
## srv ipfou (unused now)
#nsx srv ip fou add port $NS_FOU_PORT ipproto 4
#nsx srv ip link add name $NS_FOU_IFACE type ipip \
# remote $NS_CLI_IP local $NS_SRV_IP ttl 225 \
# encap fou encap-sport $NS_FOU_PORT encap-dport $NS_FOU_PORT
#nsx srv ip addr add $NS_SRV_FOU_NET dev $NS_FOU_IFACE
#nsx srv ip link set $NS_FOU_IFACE up
# srv ipsec
setup_ipsec srv $NS_SRV_LEFT $NS_SRV_IP $NS_CLI_IP \
$NS_SRV_IPSEC_IP $NS_CLI_IPSEC_IP
if [[ $NS_OFFLOADS == off ]]; then
set_offloads $NS_SRV_LEFT off srv || return $?
fi
if [[ $arch == "sce" ]]; then
nsx srv sysctl -qw net.ipv4.tcp_sce=1 || return $?
#nsx srv sysctl -qw net.ipv4.tcp_sce_feedback_mode=1 || return $?
nsx srv sysctl -qw net.ipv4.tcp_ecn=1 || return $?
elif [[ $arch == "l4s" ]]; then
nsx srv sysctl -qw net.ipv4.tcp_ecn=3 || return $?
fi
# mid
sudo ip netns add mid || return $?
sudo ip link set dev $NS_MID_RIGHT netns mid || return $?
if [[ $NS_OFFLOADS == off ]]; then
set_offloads $NS_MID_RIGHT off mid || return $?
fi
nsx mid ip link set $NS_MID_RIGHT up || return $?
sudo ip link add dev $NS_MID_LEFT type veth peer name $NS_CLI_RIGHT || return $?
sudo ip link set dev $NS_MID_LEFT netns mid || return $?
if [[ $NS_OFFLOADS == off ]]; then
set_offloads $NS_MID_LEFT off mid || return $?
fi
nsx mid ip link set $NS_MID_LEFT up || return $?
nsx mid ip link add name mid.b type bridge || return $?
nsx mid ip link set dev $NS_MID_RIGHT master mid.b || return $?
nsx mid ip link set dev $NS_MID_LEFT master mid.b || return $?
nsx mid ip link set dev mid.b up || return $?
# cli uses default namespace
sudo ip addr add $NS_CLI_NET dev $NS_CLI_RIGHT || return $?
sudo ip link set $NS_CLI_RIGHT up || return $?
if [[ $NS_OFFLOADS == off ]]; then
set_offloads $NS_CLI_RIGHT off || return $?
fi
if [[ $arch == "sce" ]]; then
sudo sysctl -qw net.ipv4.tcp_sce=1 || return $? >/dev/null
#sudo sysctl -qw net.ipv4.tcp_sce_feedback_mode=1 || return $? >/dev/null
sudo sysctl -qw net.ipv4.tcp_ecn=1 || return $? >/dev/null
elif [[ $arch == "l4s" ]]; then
sudo sysctl -qw net.ipv4.tcp_ecn=3 || return $? >/dev/null
fi
# cli wireguard
sudo ip link add $NS_WG_IFACE type wireguard