aboutgitcodebugslistschat
path: root/test/demo
diff options
context:
space:
mode:
Diffstat (limited to 'test/demo')
-rw-r--r--test/demo/passt248
-rw-r--r--test/demo/pasta274
2 files changed, 522 insertions, 0 deletions
diff --git a/test/demo/passt b/test/demo/passt
new file mode 100644
index 0000000..a6edbf0
--- /dev/null
+++ b/test/demo/passt
@@ -0,0 +1,248 @@
+# 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/passt - Quick introduction to passt
+#
+# Copyright (c) 2021 Red Hat GmbH
+# Author: Stefano Brivio <sbrivio@redhat.com>
+
+onlyfor passt
+say This is a short introduction to
+em passt
+say .
+nl
+nl
+sleep 3
+
+say Let's fetch the source
+sleep 1
+tempdir TEMPDIR
+host cd __TEMPDIR__
+host git clone https://passt.top/passt
+sleep 1
+
+say and build it.
+sleep 1
+host cd passt
+host make avx2
+sleep 1
+
+nl
+nl
+say A quick look at the man page...
+sleep 1
+hostb man ./passt.1
+sleep 5
+hostb /ports
+sleep 2
+hostb n
+sleep 2
+hostb n
+sleep 10
+
+nl
+say '-t' to forward TCP ports.
+sleep 3
+host q
+
+nl
+nl
+say Let's create a small initramfs image for the guest.
+guest cd __TEMPDIR__
+guest git clone https://mbuto.lameexcu.se/mbuto
+guest cd mbuto
+guest ./mbuto -f passt.img -p passt -c lz4
+sleep 2
+
+nl
+nl
+say We want to isolate passt and guest in a
+nl
+say network namespace. For convenience, we'll
+nl
+say create it with 'pasta', see also the
+nl
+say 'pasta' demo above.
+sleep 3
+
+passt cd __TEMPDIR__/passt
+passt ./pasta
+sleep 3
+passt /sbin/dhclient
+sleep 2
+passt /sbin/dhclient -6
+sleep 2
+
+nl
+nl
+say Now let's run 'passt' in the new namespace, and
+nl
+say enter this namespace from the guest terminal too.
+sleep 3
+pout TARGET_PID echo $$
+sleep 1
+
+passtb ./passt -f -t 5201,5203
+sleep 2
+
+guest nsenter -t __TARGET_PID__ -U -n --preserve-credentials
+sleep 5
+
+nl
+nl
+say We're ready to start qemu with the qrap wrapper,
+nl
+say that we currently need to connect the netdev
+nl
+say back-end to passt's UNIX domain socket.
+sleep 2
+hout VMLINUZ echo "/boot/vmlinuz-$(uname -r)"
+guest ../passt/qrap 5 kvm -m 4096 -cpu host -smp 4 -kernel __VMLINUZ__ -initrd passt.img -nographic -serial stdio -nodefaults -append "console=ttyS0 virtio-net.napi_tx=1" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384 -netdev socket,fd=5,id=hostnet0
+sleep 10
+
+nl
+nl
+guest ip li sh
+sleep 3
+say Guest is up. Let's configure IPv4 first...
+sleep 2
+guest dhclient
+sleep 2
+guest ip ad sh
+sleep 5
+
+nl
+say SLAAC is already done, but we can also
+nl
+say get another address via DHCPv6.
+sleep 3
+guest dhclient -6
+sleep 3
+
+nl
+nl
+say Let's try to communicate between host and guest.
+sleep 2
+guestb nc -6 -l -p 5201
+sleep 2
+host echo "Hello from the host" | nc -N ::1 5201
+sleep 5
+
+nl
+nl
+say Now the other way around... using
+nl
+say the address of the default gateway.
+sleep 2
+gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
+sleep 5
+hostb nc -l -p 31337
+sleep 2
+guest echo "Hello from the guest" | nc -N __GW__ 31337
+sleep 3
+
+nl
+nl
+say Let's have a (quick!) look at performance
+nl
+say more in the "Performance" section below.
+sleep 3
+
+host nsenter -t __TARGET_PID__ -U -n --preserve-credentials
+
+guest /sbin/sysctl -w net.core.rmem_max=536870912
+guest /sbin/sysctl -w net.core.wmem_max=536870912
+guest /sbin/sysctl -w net.core.rmem_default=33554432
+guest /sbin/sysctl -w net.core.wmem_default=33554432
+guest /sbin/sysctl -w net.ipv4.tcp_rmem="4096 131072 268435456"
+guest /sbin/sysctl -w net.ipv4.tcp_wmem="4096 131072 268435456"
+guest /sbin/sysctl -w net.ipv4.tcp_timestamps=0
+
+host sysctl -w net.ipv4.tcp_rmem="4096 524288 134217728"
+host sysctl -w net.ipv4.tcp_wmem="4096 524288 134217728"
+host sysctl -w net.ipv4.tcp_timestamps=0
+
+gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
+gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
+nl
+nl
+info Throughput in Gbps, latency in µs
+th flow host>guest guest>host
+
+set OPTS -P4 -w 64M -l 1M -i1 --pacing-timer 100000
+
+tr TCP/IPv6 throughput
+hostb sleep 10; iperf3 -c ::1 __OPTS__
+gout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 2.0 3.0
+sleep 5
+guestb sleep 10; iperf3 -c __GW6__%__IFNAME__ -p 5202 __OPTS__ -O3
+hout BW iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 2.0 3.0
+
+tl TCP/IPv6 RR latency
+guestb tcp_rr -C 5201 -P 5203 -6 --nolog
+sleep 2
+hout LAT tcp_rr -C 5201 -P 5203 --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+hostb tcp_rr -6 --nolog
+sleep 2
+gout LAT tcp_rr --nolog -c -H __GW6__%__IFNAME__ | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+
+tl TCP/IPv6 CRR latency
+guestb tcp_crr -C 5201 -P 5203 -6 --nolog
+sleep 2
+hout LAT tcp_crr -C 5201 -P 5203 --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+hostb tcp_crr -6 --nolog
+sleep 2
+gout LAT tcp_crr --nolog -c -H __GW6__%__IFNAME__ | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+
+tr TCP/IPv4 throughput
+hostb sleep 10; iperf3 -c 127.0.0.1 __OPTS__
+gout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 2.0 3.0
+sleep 5
+guestb sleep 10; iperf3 -c __GW__ -p 5202 __OPTS__ -O3
+hout BW iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 2.0 3.0
+
+tl TCP/IPv4 RR latency
+guestb tcp_rr -C 5201 -P 5203 -4 --nolog
+sleep 2
+hout LAT tcp_rr -C 5201 -P 5203 --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+hostb tcp_rr -4 --nolog
+sleep 2
+gout LAT tcp_rr --nolog -c -H __GW__ | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+
+tl TCP/IPv4 CRR latency
+guestb tcp_crr -C 5201 -P 5203 -4 --nolog
+sleep 2
+hout LAT tcp_crr -C 5201 -P 5203 --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+hostb tcp_crr -4 --nolog
+sleep 2
+gout LAT tcp_crr --nolog -c -H __GW__ | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 800
+sleep 2
+
+nl
+nl
+say Thanks for watching!
+sleep 5
diff --git a/test/demo/pasta b/test/demo/pasta
new file mode 100644
index 0000000..508323a
--- /dev/null
+++ b/test/demo/pasta
@@ -0,0 +1,274 @@
+# 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/pasta - Quick introduction to pasta
+#
+# Copyright (c) 2021 Red Hat GmbH
+# Author: Stefano Brivio <sbrivio@redhat.com>
+
+onlyfor pasta
+say This is a short introduction to
+em pasta
+say .
+nl
+nl
+sleep 3
+
+say Let's fetch the source
+sleep 1
+tempdir TEMPDIR
+host cd __TEMPDIR__
+host git clone https://passt.top/passt
+sleep 1
+
+say and build it.
+sleep 1
+host cd passt
+host make
+sleep 1
+
+nl
+nl
+say A quick look at the man page...
+sleep 1
+hostb man ./pasta.1
+sleep 5
+hostb /pasta
+sleep 2
+hostb n
+sleep 2
+hostb n
+sleep 10
+
+nl
+say without TARGET_PID, it will create a namespace.
+sleep 3
+passt cd __TEMPDIR__/passt
+passt ./pasta
+sleep 3
+
+nl
+nl
+say For convenience, let's enter this namespace
+nl
+say from another terminal.
+sleep 3
+pout TARGET_PID echo $$
+sleep 1
+
+ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
+sleep 5
+
+nl
+nl
+say Now, we're ready to configure networking.
+sleep 2
+host q
+
+nl
+nl
+ns ip li sh
+sleep 3
+say Let's configure IPv4 first...
+sleep 2
+ns dhclient
+sleep 2
+ns ip ad sh
+sleep 5
+
+nl
+say SLAAC is already done, but we can also
+nl
+say get another address via DHCPv6.
+sleep 3
+ns dhclient -6
+sleep 3
+
+nl
+nl
+say Let's try to communicate between host and namespace
+sleep 2
+nl
+say ...there's no need to configure port forwarding,
+nl
+say pasta detects bound ports and forwards them.
+sleep 3
+
+nsb nc -6 -l -p 31337
+sleep 2
+host echo "Hello from the host" | nc -N ::1 31337
+sleep 5
+
+nl
+nl
+say Now the other way around...
+nl
+say we can use a loopback address
+sleep
+hostb nc -l -p 31337
+sleep 2
+ns echo "Hello from the namespace" | nc -N 127.0.0.1 31337
+sleep 5
+
+nl
+say or the address of the default gateway.
+sleep 2
+nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
+sleep 5
+hostb nc -l -p 31337
+sleep 2
+ns echo "Hello from the namespace" | nc -N __GW__ 31337
+sleep 3
+
+nl
+nl
+say UDP...
+sleep 2
+ns host -t A passt.top
+sleep 3
+say seems to work too.
+sleep 3
+
+nl
+nl
+em pasta
+say can also take packet captures.
+sleep 3
+passt exit
+sleep 2
+temp TEMP
+passtb ./pasta -p __TEMP__.pcap
+sleep 2
+passt
+passt /sbin/dhclient
+sleep 2
+hostb tshark -r __TEMP__.pcap
+sleep 5
+
+nl
+nl
+say And there are tons of totally useless
+sleep 1
+bsp 14
+say absolutely useful features
+nl
+say you can find described in the man page.
+sleep 5
+
+nl
+nl
+say Let's have a (quick!) look at performance
+nl
+say more in the "Performance" section below.
+sleep 3
+passt exit
+passt CFLAGS="-g" make avx2
+sleep 2
+passt perf record -g ./pasta
+sleep 2
+
+pout TARGET_PID echo $$
+sleep 1
+ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
+sleep 5
+
+nl
+nl
+info Throughput in Gbps, latency in µs
+th flow init>ns ns>init
+
+set OPTS -P4 -l 1M -w 32M -i1 --pacing-timer 100000
+
+tr TCP/IPv6 throughput
+nsb sleep 10; iperf3 -c ::1 __OPTS__
+hout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 10.0 20.0
+sleep 5
+hostb sleep 10; iperf3 -c ::1 __OPTS__
+nsout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 10.0 20.0
+
+tl TCP/IPv6 RR latency
+hostb tcp_rr -6 --nolog
+sleep 2
+nsout LAT tcp_rr --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+nsb tcp_rr -6 --nolog
+sleep 2
+hout LAT tcp_rr --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+
+tl TCP/IPv6 CRR latency
+hostb tcp_crr -6 --nolog
+sleep 2
+nsout LAT tcp_crr --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+nsb tcp_crr -6 --nolog
+sleep 2
+hout LAT tcp_crr --nolog -c -H ::1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+
+tr TCP/IPv4 throughput
+nsb sleep 10; iperf3 -c 127.0.0.1 __OPTS__
+hout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 10.0 20.0
+sleep 5
+hostb sleep 10; iperf3 -c 127.0.0.1 __OPTS__
+nsout BW iperf3 -s1J | jq -rM ".end.sum_received.bits_per_second"
+bw __BW__ 10.0 20.0
+
+tl TCP/IPv4 RR latency
+hostb tcp_rr -4 --nolog
+sleep 2
+nsout LAT tcp_rr --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+nsb tcp_rr -4 --nolog
+sleep 2
+hout LAT tcp_rr --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+
+tl TCP/IPv4 CRR latency
+hostb tcp_crr -4 --nolog
+sleep 2
+nsout LAT tcp_crr --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+nsb tcp_crr -4 --nolog
+sleep 2
+hout LAT tcp_crr --nolog -c -H 127.0.0.1 | sed -n 's/^throughput=\(.*\)/\1/p'
+lat __LAT__ 1000 500
+sleep 2
+
+sleep 5
+passt exit
+sleep 2
+killp PASST
+killp HOST
+sleep 2
+nsb perf report -g --max-stack 3
+sleep 10
+
+nl
+nl
+say I
+em knew
+say it.
+em syscalls
+say .
+sleep 5
+
+nl
+nl
+say Thanks for watching!
+sleep 5