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
|
#!/bin/bash
set -eu -o pipefail
cd $(dirname $0)
source ~/.profile
. ../param.bash
ALPINE_IMAGE="public.ecr.aws/docker/library/alpine:3.16"
nerdctl pull --quiet "${ALPINE_IMAGE}"
systemd-run --user --unit run-iperf3 iperf3 -s
echo "===== Benchmark: netns -> host With bypass4netns ====="
(
set +e
nerdctl rm -f test
systemctl --user stop run-bypass4netnsd
systemctl --user reset-failed
set -ex
# start bypass4netnsd for nerdctl integration
systemd-run --user --unit run-bypass4netnsd bypass4netnsd
sleep 1
nerdctl run --annotation nerdctl/bypass4netns=true -d --name test "${ALPINE_IMAGE}" sleep infinity
nerdctl exec test apk add --no-cache iperf3
nerdctl exec test iperf3 -c $HOST_IP
nerdctl rm -f test
)
echo "===== Benchmark: netns -> host Without bypass4netns (for comparison) ====="
(
set +e
nerdctl rm -f test
set -ex
nerdctl run -d --name test "${ALPINE_IMAGE}" sleep infinity
nerdctl exec test apk add --no-cache iperf3
nerdctl exec test iperf3 -c $HOST_IP
nerdctl rm -f test
)
echo "===== Benchmark: host -> netns With bypass4netns ====="
(
set +e
nerdctl rm -f test
systemctl --user stop run-iperf3-netns
systemctl --user reset-failed
set -ex
nerdctl run --annotation nerdctl/bypass4netns=true -d --name test -p 8080:5201 "${ALPINE_IMAGE}" sleep infinity
nerdctl exec test apk add --no-cache iperf3
systemd-run --user --unit run-iperf3-netns nerdctl exec test iperf3 -s -4
sleep 1 # waiting `iperf3 -s -4` becomes ready
iperf3 -c $HOST_IP -p 8080
nerdctl rm -f test
)
echo "===== Benchmark: host -> netns Without bypass4netns (for comparison) ====="
(
set +e
nerdctl rm -f test
systemctl --user stop run-iperf3-netns2
systemctl --user reset-failed
set -ex
nerdctl run -d --name test -p 8080:5201 "${ALPINE_IMAGE}" sleep infinity
nerdctl exec test apk add --no-cache iperf3
systemd-run --user --unit run-iperf3-netns2 nerdctl exec test iperf3 -s -4
sleep 1
iperf3 -c $HOST_IP -p 8080
nerdctl rm -f test
)
|