aboutgitcodebugslistschat
path: root/test/demo/podman
blob: a83a04fd8e2062a50b59ee00d93c877bfd5b95f9 (plain) (blame)
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
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# PASST - Plug A Simple Socket Transport
#  for qemu/UNIX domain socket mode
#
# PASTA - Pack A Subtle Tap Abstraction
#  for network namespace/tap device mode
#
# test/demo/podman - Show pasta operation with Podman
#
# Copyright (c) 2022 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com>

set	OPTS -Z -w 4M -l 1M -P 2 -t10 --pacing-timer 10000

say	This is an overview of 
em	Podman
say	 using 
em	pasta
say	.
nl
nl
sleep	3

say	Let's fetch Podman
sleep	1
host	git -C __STATEDIR__ clone https://github.com/containers/podman.git
sleep	1

say	, patch it
sleep	1
host	cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __STATEDIR__/podman
host	cd __STATEDIR__/podman
host	git am -3 0001-libpod-Add-pasta-networking-mode.patch
sleep	1

say	, and build it.
host	go get github.com/pkg/errors@v0.9.1
host	go mod vendor
host	make
sleep	1

nl
nl
say	By default, for 
em	rootless
say	 mode, Podman will pick
nl
em	slirp4netns
say	 to operate the network.
nl
nl
say	Let's start a container with it
sleep	1

ns1	cd __STATEDIR__/podman
ns1b	./bin/podman run --rm -ti alpine sh
sleep	2

say	,
nl
say	and one with 
em	pasta
say	 instead.

ns2	cd __STATEDIR__/podman
ns2b	./bin/podman run --net=pasta --rm -ti alpine sh
sleep	2

nl
nl
say	We can observe some practical differences:
nl

ns1b	ip addr show
sleep	3
say	- slirp4netns uses a predefined IPv4 address
hl	NS1
sleep	2

ns2b	ip addr show
sleep	3
say	,
nl
say	  pasta copies addresses from the host
hl	NS2
sleep	2

nl
say	- slirp4netns uses 
em	tap0
say	 as interface name
hl	NS1
sleep	2

say	, pasta
nl
say	  takes an interface name from the host
hl	NS2
sleep	2

nl
say	- same for routes:

ns1b	ip route show
sleep	3
say	 slirp4netns defines its own
nl
say	  gateway address
hl	NS1
sleep	2

say	, pasta copies it from the host
ns2b	ip route show
ns2b	ip -6 route show
sleep	5

nl
nl
say	Let's check connectivity...
sleep	2
ns1b	wget risotto.milane.se
ns2b	wget myfinge.rs
sleep	2
say	 fine.
sleep	5
nl
nl

say	Let's run a service in the container,
nl
say	configuring port forwarding first
sleep	5

ns1b	exit
sleep	2
ns1b	podman run --rm -p 8080:8080/tcp -ti alpine sh
sleep	5

ns2b	exit
sleep	2
ns2b	./bin/podman run --net=pasta --rm -p 8081:8081/tcp -ti alpine sh
sleep	5

nl
nl
say	...and now actually start the service
ns1b	apk add thttpd
ns2b	apk add thttpd
ns1b	>index.html cat << EOF
ns1b	<!doctype html><body>Hello via slirp4netns</body>
ns1b	EOF
ns2b	>index.html cat << EOF
ns2b	<!doctype html><body>Hello via pasta</body>
ns2b	EOF
ns1b	thttpd -p 8080
ns2b	thttpd -p 8081

sleep	3
say	, then check
nl
say	that it's accessible.
sleep	3

hostb	lynx http://127.0.0.1:8080/
sleep	5
hostb	q
hostb	lynx http://[::1]:8081/
sleep	5
hostb	q
sleep	2

nl
nl
say	What about performance, you might ask.
nl
say	For simplicity, we'll measure between init
nl
say	namespace (the "host") and container. To do
nl
say	that, we need to allow the container direct
nl
say	access to the host, which needs an extra option
nl
say	in slirp4netns. Let's restart that container,
nl
say	while also mapping ports for iperf3 and neper.
nl
sleep	3

ns1	exit

ns1b	podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh
sleep	5
nl
nl
say	pasta allows that by default, so we wouldn't need
nl
say	to touch the container using pasta, but let's
nl
say	take the chance to look at passing extra options
nl
say	there as well.
nl
nl
ns2	exit

say	Options after '--net=pasta:' are the same as
nl
say	documented for the command line of pasta(1).
nl
say	For example, we can enable packet captures
sleep	3
ns2b	./bin/podman run --net=pasta:--pcap,demo.pcap --rm -ti alpine sh
sleep	5

say	,
nl
say	and generate some traffic we can look at.
nl
sleep	2
ns2b	wget -O - lameexcu.se
sleep	2
hostb	tshark -r demo.pcap tcp
sleep	5

nl
say	But back to performance now. By the way,
nl
say	pasta can also forward ports through the
nl
say	loopback interface for improved throughput.
nl
say	Let's configure that.
nl
sleep	2
ns2b	exit
sleep	1
ns2b	./bin/podman run --net=pasta:-T,5213-5214,-U,5213-5214 -p 5203-5204:5203-5204/tcp -p 5203-5204:5203-5204/udp --rm -ti alpine sh
sleep	5

nl
say	In slirp4netns mode, Podman enables by
nl
say	default the port forwarder from 'rootlesskit'
nl
say	for better performance.
nl
say	However, it can't be used for non-local
nl
say	mappings (traffic without loopback source 
nl
em	and
say	 destination) because it doesn't preserve
nl
say	the correct source address as it forwards
nl
say	packets to the container.
sleep	3
nl
nl
say	We'll check non-loopback mappings first for
nl
say	both pasta and slirp4netns, then restart the
nl
say	slirp4netns container with rootlesskit and
nl
say	switch to loopback mappings. pasta doesn't
nl
say	have this limitation.
nl
nl
say	One last note: slirp4netns doesn't support
nl
say	forwarding of IPv6 ports (to the container):
nl
say	github.com/rootless-containers/slirp4netns/issues/253
nl
say	so we'll skip IPv6 tests for slirp4netns as
nl
say	port forwarder (on the path to the container).

sleep	5
ns1	exit
ns1b	podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true,port_handler=slirp4netns -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh
sleep	3

nl
nl
say	We'll use iperf3(1) for throughput
sleep	2
ns1b	apk add iperf3 jq bc
ns2b	apk add iperf3 jq bc
sleep	2
say	 and static
nl
say	builds of neper (github.com/google/neper) for
nl
say	latency.
ns1	wget lameexcu.se/tcp_rr; chmod 755 tcp_rr
ns2	wget lameexcu.se/tcp_rr; chmod 755 tcp_rr
ns1	wget lameexcu.se/tcp_crr; chmod 755 tcp_crr
ns2	wget lameexcu.se/tcp_crr; chmod 755 tcp_crr
ns1	wget lameexcu.se/udp_rr; chmod 755 udp_rr
ns2	wget lameexcu.se/udp_rr; chmod 755 udp_rr
sleep	5

nl
nl
say	Everything is set now, let's start
sleep	2
hout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
hout	ADDR4 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout	ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout	GW4 ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
hout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'

nl
nl
resize	INFO D 15
info	Throughput in Gbps, latency in µs
info	  non-loopback (tap) connections
th	mode slirp4netns pasta

tr	TCP/IPv6 to ns
#ns1b	iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1
#hostb	iperf3 -c __ADDR6__ -p 5201 __OPTS__
#ns1out	BW cat t1
#bw	__BW__ 0.0 0.0
bw	-
ns2b	iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1
hostb	iperf3 -c __ADDR6__ -p 5203 __OPTS__
sleep	12
ns2b	
ns2out	BW cat t1
bw	__BW__ 0.0 0.0
hostb	

tl	  RR latency
#ns1b	./tcp_rr -6 --nolog -C 5201 -P 5202
#sleep	2
#hout	LAT tcp_rr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
#lat	__LAT__ 100000 100000
lat	-
ns2b	./tcp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_rr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
#ns1b	./tcp_crr -6 --nolog -C 5201 -P 5202
#sleep	2
#hout	LAT tcp_crr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
#lat	__LAT__ 100000 100000
lat	-
ns2b	./tcp_crr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_crr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	TCP/IPv4 to ns
ns1b	iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1
hostb	iperf3 -c __ADDR4__ -p 5201 __OPTS__
sleep	12
ns1b	
ns1out	BW cat t1
bw	__BW__ 0.0 0.0
ns2b	iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1
hostb	iperf3 -c __ADDR4__ -p 5203 __OPTS__
sleep	12
ns2b	
ns2out	BW cat t1
bw	__BW__ 0.0 0.0
hostb	

tl	  RR latency
ns1b	./tcp_rr -4 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_rr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_rr -4 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_rr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
ns1b	./tcp_crr -4 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_crr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_crr -4 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_crr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tr	TCP/IPv6 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1
ns1b	iperf3 -c fd00::2 -p 5211 __OPTS__
sleep	12
hostb	
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1
ns2b	iperf3 -c __GW6__%__IFNAME__ -p 5213 __OPTS__
sleep	12
hostb	
hout	BW cat t1
bw	__BW__ 0.0 0.0
ns1b	
ns2b	

tl	  RR latency
hostb	tcp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_rr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
hostb	tcp_crr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_crr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_crr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_crr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	TCP/IPv4 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1
ns1b	iperf3 -c 10.0.2.2 -p 5211 __OPTS__
sleep	12
hostb	
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1
ns2b	iperf3 -c __GW4__ -p 5213 __OPTS__
sleep	10
hostb	
hout	BW cat t1
bw	__BW__ 0.0 0.0
ns1b	
ns2b	

tl	  RR latency
hostb	tcp_rr -4 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_rr -4 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_rr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
hostb	tcp_crr -4 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_crr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_crr -4 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_crr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

sleep	5


tr	UDP/IPv6 to ns
#ns1b	iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1
#hostb	iperf3 -u -c __ADDR6__ -p 5201 -t5 -b 35G
#sleep	10
#ns1out	BW cat t1
#bw	__BW__ 0.0 0.0
bw	-
ns2b	iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c __ADDR6__ -p 5204 -t5 -b 35G
sleep	10
ns2out	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
#ns1b	./udp_rr -6 --nolog -C 5201 -P 5202
#sleep	2
#hout	LAT udp_rr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
#lat	__LAT__ 100000 100000
lat	-
ns2b	./udp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT udp_rr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	UDP/IPv4 to ns
ns1b	iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c __ADDR4__ -p 5201 -t5 -b 35G
sleep	10
ns1out	BW cat t1
bw	__BW__ 0.0 0.0
ns2b	iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c __ADDR4__ -p 5204 -t5 -b 35G
sleep	10
ns2out	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
ns1b	./udp_rr -6 --nolog -C 5201 -P 5202
sleep	2
hout	LAT udp_rr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./udp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT udp_rr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tr	UDP/IPv6 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns1b	iperf3 -u -c fd00::2 -p 5211 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns2b	iperf3 -u -c __GW6__%__IFNAME__ -p 5214 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
hostb	udp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./udp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	udp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./udp_rr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	UDP/IPv4 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns1b	iperf3 -u -c 10.0.2.2 -p 5211 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns2b	iperf3 -u -c __GW4__ -p 5214 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
hostb	udp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./udp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	udp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./udp_rr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000


ns1	exit
ns1	podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh
ns1	apk add iperf3 jq bc
ns1	wget lameexcu.se/tcp_rr; chmod 755 tcp_rr
ns1	wget lameexcu.se/tcp_crr; chmod 755 tcp_crr
ns1	wget lameexcu.se/udp_rr; chmod 755 udp_rr
info	
info	
info	  loopback (lo) connections
th	mode rootlesskit pasta


tr	TCP/IPv6 to ns
ns1b	(iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) &
ns1b	iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2
hostb	iperf3 -c ::1 -p 5201 __OPTS__ & iperf3 -c ::1 -p 5202 __OPTS__
sleep	12
ns1b	
ns1out	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
ns2b	(iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) &
ns2b	iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2
hostb	iperf3 -c ::1 -p 5203 __OPTS__ & iperf3 -c ::1 -p 5204 __OPTS__
sleep	12
ns2b	
ns2out	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
hostb	

tl	  RR latency
ns1b	./tcp_rr -6 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_rr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_rr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
ns1b	./tcp_crr -6 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_crr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_crr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_crr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	TCP/IPv4 to ns
ns1b	(iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) &
ns1b	iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2
hostb	iperf3 -c 127.0.0.1 -p 5201 __OPTS__ & iperf3 -c 127.0.0.1 -p 5202 __OPTS__
sleep	12
ns1b	
ns1out	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
ns2b	(iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) &
ns2b	iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2
hostb	iperf3 -c 127.0.0.1 -p 5203 __OPTS__ & iperf3 -c 127.0.0.1 -p 5204 __OPTS__
sleep	12
ns2b	
ns2out	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
hostb	

tl	  RR latency
ns1b	./tcp_rr -4 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_rr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_rr -4 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_rr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
ns1b	./tcp_crr -4 --nolog -C 5201 -P 5202
sleep	2
hout	LAT tcp_crr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./tcp_crr -4 --nolog -C 5203 -P 5204
sleep	2
hout	LAT tcp_crr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tr	TCP/IPv6 to host
hostb	(iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) &
hostb	iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2
ns1b	iperf3 -c fd00::2 -p 5211 __OPTS__ & iperf3 -c fd00::2 -p 5212 __OPTS__
sleep	12
hostb	
hout	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
hostb	(iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) &
hostb	iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2
ns2b	iperf3 -c ::1 -p 5213 __OPTS__ & iperf3 -c ::1 -p 5214 __OPTS__
sleep	12
hostb	
hout	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
ns1b	
ns2b	

tl	  RR latency
hostb	tcp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_rr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
hostb	tcp_crr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_crr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_crr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_crr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	TCP/IPv4 to host
hostb	(iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) &
hostb	iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2
ns1b	iperf3 -c 10.0.2.2 -p 5211 __OPTS__ & iperf3 -c 10.0.2.2 -p 5212 __OPTS__
sleep	12
hostb	
hout	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
hostb	(iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) &
hostb	iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2
ns2b	iperf3 -c 127.0.0.1 -p 5213 __OPTS__ & iperf3 -c 127.0.0.1 -p 5214 __OPTS__
sleep	12
hostb	
hout	BW echo "$(cat t1) + $(cat t2)" | bc -l
bw	__BW__ 0.0 0.0
ns1b	
ns2b	

tl	  RR latency
hostb	tcp_rr -4 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_rr -4 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_rr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	  CRR latency
hostb	tcp_crr -4 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./tcp_crr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	tcp_crr -4 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./tcp_crr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

sleep	5


tr	UDP/IPv6 to ns
ns1b	iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c ::1 -p 5201 -t5 -b 35G
sleep	10
ns1out	BW cat t1
bw	__BW__ 0.0 0.0
ns2b	iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c ::1 -p 5204 -t5 -b 35G
sleep	10
ns2out	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
ns1b	./udp_rr -6 --nolog -C 5201 -P 5202
sleep	2
hout	LAT udp_rr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./udp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT udp_rr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	UDP/IPv4 to ns
ns1b	iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c 127.0.0.1 -p 5201 -t5 -b 35G
sleep	10
ns1out	BW cat t1
bw	__BW__ 0.0 0.0
ns2b	iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1
hostb	iperf3 -u -c 127.0.0.1 -p 5204 -t5 -b 35G
sleep	10
ns2out	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
ns1b	./udp_rr -6 --nolog -C 5201 -P 5202
sleep	2
hout	LAT udp_rr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
ns2b	./udp_rr -6 --nolog -C 5203 -P 5204
sleep	2
hout	LAT udp_rr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tr	UDP/IPv6 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns1b	iperf3 -u -c fd00::2 -p 5211 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns2b	iperf3 -u -c ::1 -p 5214 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
hostb	udp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./udp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	udp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./udp_rr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000

tl	UDP/IPv4 to host
hostb	iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns1b	iperf3 -u -c 10.0.2.2 -p 5211 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0
hostb	iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1
ns2b	iperf3 -u -c 127.0.0.1 -p 5214 -t5 -b 35G
sleep	10
hout	BW cat t1
bw	__BW__ 0.0 0.0

tl	  RR latency
hostb	udp_rr -6 --nolog -C 5211 -P 5212
sleep	2
ns1out	LAT ./udp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000
hostb	udp_rr -6 --nolog -C 5213 -P 5214
sleep	2
ns2out	LAT ./udp_rr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p'
lat	__LAT__ 100000 100000


nl
nl
say	Thanks for watching!
sleep	15