From 6419ae6b478d268dc367dc75c909845ea249dec4 Mon Sep 17 00:00:00 2001 From: Damien Deville Date: Tue, 5 Sep 2023 17:39:53 +0200 Subject: [PATCH 1/3] Allow running perf client and server within dockers --- .gitignore | 2 + perf/docker/Dockerfile | 15 +++++++ perf/docker/build.sh | 12 ++++++ perf/docker/docker-compose.yml | 33 ++++++++++++++++ perf/docker/entrypoint.sh | 3 ++ perf/docker/run-client.sh | 62 +++++++++++++++++++++++++++++ perf/docker/run-server.sh | 71 ++++++++++++++++++++++++++++++++++ 7 files changed, 198 insertions(+) create mode 100644 perf/docker/Dockerfile create mode 100755 perf/docker/build.sh create mode 100644 perf/docker/docker-compose.yml create mode 100755 perf/docker/entrypoint.sh create mode 100755 perf/docker/run-client.sh create mode 100755 perf/docker/run-server.sh diff --git a/.gitignore b/.gitignore index 20e2395ea..b8d4ae736 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ Cargo.lock .idea .DS_Store .vscode + +perf/docker/work/ diff --git a/perf/docker/Dockerfile b/perf/docker/Dockerfile new file mode 100644 index 000000000..abdd64f18 --- /dev/null +++ b/perf/docker/Dockerfile @@ -0,0 +1,15 @@ +# https://hub.docker.com/_/debian +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y procps iputils-ping iproute2 ethtool tcpdump + +WORKDIR /root + +RUN mkdir -p .local/share/quinn + +COPY ./entrypoint.sh . + +COPY ./target/perf_client . +COPY ./target/perf_server . + +ENTRYPOINT [ "/root/entrypoint.sh" ] diff --git a/perf/docker/build.sh b/perf/docker/build.sh new file mode 100755 index 000000000..2f27aa3ca --- /dev/null +++ b/perf/docker/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +CURDIR=$(pwd) + +mkdir -p ./target + +cd ../.. +cargo build -p perf --release +cp -au ./target/release/perf_server ./target/release/perf_client ${CURDIR}/target + +cd ${CURDIR} +docker compose build diff --git a/perf/docker/docker-compose.yml b/perf/docker/docker-compose.yml new file mode 100644 index 000000000..2bd44d5bf --- /dev/null +++ b/perf/docker/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' + +networks: + quinn-perf: + ipam: + config: + - subnet: 172.42.0.0/16 + +services: + server: + build: . + image: quinn_perf + networks: + quinn-perf: + ipv4_address: 172.42.0.2 + volumes: + - ./work:/root/.local/share/quinn + cap_add: + - NET_ADMIN + environment: + - SSLKEYLOGFILE=/root/.local/share/quinn/server.key + + client: + image: quinn_perf + networks: + quinn-perf: + ipv4_address: 172.42.0.3 + volumes: + - ./work:/root/.local/share/quinn + cap_add: + - NET_ADMIN + environment: + - SSLKEYLOGFILE=/root/.local/share/quinn/client.key diff --git a/perf/docker/entrypoint.sh b/perf/docker/entrypoint.sh new file mode 100755 index 000000000..423c24e5e --- /dev/null +++ b/perf/docker/entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +while :; do sleep 10; done diff --git a/perf/docker/run-client.sh b/perf/docker/run-client.sh new file mode 100755 index 000000000..a35c94a1e --- /dev/null +++ b/perf/docker/run-client.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +SERVICE=client +PERF_CLIENT_ARGS="--keylog --duration 5 172.42.0.2:4433" + +LATENCY=0 +CAPTURE=0 +OPEN=0 + +function usage() { + echo "usage: $0 [-hco] [-l number]" + echo " -h display help" + echo " -c enable packet capture" + echo " -o open packet capture" + echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)" + exit 1 +} + +while getopts "hcl:" opt; do + case $opt in + c) CAPTURE=1;; + o) OPEN=1;; + l) LATENCY=$OPTARG;; + h) usage;; + *) usage;; + esac +done + +mkdir -p ./work + +echo "Launching docker ${SERVICE}" +docker compose up -d --force-recreate ${SERVICE} +if [ ${LATENCY} -ne 0 ]; then + echo "Enforcing a latency of ${LATENCY}ms" + docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay ${LATENCY}ms +fi + +# FIXME disable GSO due to this issue +# https://gitlab.com/wireshark/wireshark/-/issues/19109 +docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off + +if [ ${CAPTURE} -eq 1 ]; then + echo "Starting capture within docker" + docker compose exec -d ${SERVICE} tcpdump -ni eth0 -s0 -w /root/.local/share/quinn/${SERVICE}.pcap udp and port 4433 +fi + +echo "Launching quinn perf client" +docker compose exec -it ${SERVICE} /root/perf_client ${PERF_CLIENT_ARGS} + +if [ ${CAPTURE} -eq 1 ]; then + echo "Stopping capture within docker" + docker compose exec -it ${SERVICE} killall -STOP tcpdump +fi + +if [ ${LATENCY} -ne 0 ]; then + echo "Dumping QOS stats" + docker compose exec -it ${SERVICE} tc -s qdisc ls dev eth0 +fi + +if [ ${CAPTURE} -eq 1 ] && [ ${OPEN} -eq 1 ]; then + wireshark -o tls.keylog_file:./work/${SERVICE}.key ./work/${SERVICE}.pcap +fi diff --git a/perf/docker/run-server.sh b/perf/docker/run-server.sh new file mode 100755 index 000000000..cd03bffcc --- /dev/null +++ b/perf/docker/run-server.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +SERVICE=server +PERF_SERVER_ARGS="--keylog --listen 172.42.0.2:4433" + +LATENCY=0 +CAPTURE=0 +OPEN=0 + +function usage() { + echo "usage: $0 [-hco] [-l number]" + echo " -h display help" + echo " -c enable packet capture" + echo " -o open packet capture" + echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)" + exit 1 +} + +while getopts "hcl:o" opt; do + case $opt in + c) CAPTURE=1;; + o) OPEN=1;; + l) LATENCY=$OPTARG;; + h) usage;; + *) usage;; + esac +done + +mkdir -p ./work + +echo "Launching docker ${SERVICE}" +docker compose up -d --force-recreate ${SERVICE} +if [ ${LATENCY} -ne 0 ]; then + echo "Enforcing a latency of ${LATENCY}ms" + docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay ${LATENCY}ms +fi + + +# FIXME disable GSO due to this issue +# https://gitlab.com/wireshark/wireshark/-/issues/19109 +docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off + +if [ ${CAPTURE} -eq 1 ]; then + echo "Starting capture within docker" + docker compose exec -d ${SERVICE} tcpdump -ni eth0 -s0 -w /root/.local/share/quinn/${SERVICE}.pcap udp port 4433 +fi + +echo "Launching quinn perf server" +docker compose exec -d ${SERVICE} /root/perf_server ${PERF_SERVER_ARGS} + +echo "Press Ctrl-C to stop server" +( trap exit SIGINT ; read -r -d '' _ Date: Wed, 6 Sep 2023 10:02:11 +0200 Subject: [PATCH 2/3] Make script more robust --- perf/docker/build.sh | 2 +- perf/docker/run-client.sh | 2 +- perf/docker/run-server.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/perf/docker/build.sh b/perf/docker/build.sh index 2f27aa3ca..cac2a3817 100755 --- a/perf/docker/build.sh +++ b/perf/docker/build.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env -S bash -eu CURDIR=$(pwd) diff --git a/perf/docker/run-client.sh b/perf/docker/run-client.sh index a35c94a1e..6d525fea6 100755 --- a/perf/docker/run-client.sh +++ b/perf/docker/run-client.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env -S bash -eu SERVICE=client PERF_CLIENT_ARGS="--keylog --duration 5 172.42.0.2:4433" diff --git a/perf/docker/run-server.sh b/perf/docker/run-server.sh index cd03bffcc..3028a5e9f 100755 --- a/perf/docker/run-server.sh +++ b/perf/docker/run-server.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env -S bash -eu SERVICE=server PERF_SERVER_ARGS="--keylog --listen 172.42.0.2:4433" From 43318fb334779146bd8de433606c7c2d11bcad6f Mon Sep 17 00:00:00 2001 From: Damien Deville Date: Wed, 6 Sep 2023 10:03:22 +0200 Subject: [PATCH 3/3] Add option to keep GSO enabled --- perf/docker/run-client.sh | 21 +++++++++++++-------- perf/docker/run-server.sh | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/perf/docker/run-client.sh b/perf/docker/run-client.sh index 6d525fea6..530a7f091 100755 --- a/perf/docker/run-client.sh +++ b/perf/docker/run-client.sh @@ -4,23 +4,26 @@ SERVICE=client PERF_CLIENT_ARGS="--keylog --duration 5 172.42.0.2:4433" LATENCY=0 +GSO=0 CAPTURE=0 OPEN=0 function usage() { - echo "usage: $0 [-hco] [-l number]" - echo " -h display help" + echo "usage: $0 [-cgho] [-l number]" echo " -c enable packet capture" - echo " -o open packet capture" + echo " -g enable GSO (default: disabled)" + echo " -h display help" echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)" + echo " -o open packet capture" exit 1 } -while getopts "hcl:" opt; do +while getopts "cghl:o" opt; do case $opt in c) CAPTURE=1;; - o) OPEN=1;; + g) GSO=1;; l) LATENCY=$OPTARG;; + o) OPEN=1;; h) usage;; *) usage;; esac @@ -35,9 +38,11 @@ if [ ${LATENCY} -ne 0 ]; then docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay ${LATENCY}ms fi -# FIXME disable GSO due to this issue -# https://gitlab.com/wireshark/wireshark/-/issues/19109 -docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off +if [ ${GSO} -eq 0 ]; then + # FIXME disable GSO due to this issue + # https://gitlab.com/wireshark/wireshark/-/issues/19109 + docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off +fi if [ ${CAPTURE} -eq 1 ]; then echo "Starting capture within docker" diff --git a/perf/docker/run-server.sh b/perf/docker/run-server.sh index 3028a5e9f..e4330df5e 100755 --- a/perf/docker/run-server.sh +++ b/perf/docker/run-server.sh @@ -4,23 +4,26 @@ SERVICE=server PERF_SERVER_ARGS="--keylog --listen 172.42.0.2:4433" LATENCY=0 +GSO=0 CAPTURE=0 OPEN=0 function usage() { - echo "usage: $0 [-hco] [-l number]" - echo " -h display help" + echo "usage: $0 [-cgho] [-l number]" echo " -c enable packet capture" - echo " -o open packet capture" + echo " -g enable GSO (default: disabled)" + echo " -h display help" echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)" + echo " -o open packet capture" exit 1 } -while getopts "hcl:o" opt; do +while getopts "cghl:o" opt; do case $opt in c) CAPTURE=1;; - o) OPEN=1;; + g) GSO=1;; l) LATENCY=$OPTARG;; + o) OPEN=1;; h) usage;; *) usage;; esac @@ -35,10 +38,11 @@ if [ ${LATENCY} -ne 0 ]; then docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay ${LATENCY}ms fi - -# FIXME disable GSO due to this issue -# https://gitlab.com/wireshark/wireshark/-/issues/19109 -docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off +if [ ${GSO} -eq 0 ]; then + # FIXME disable GSO due to this issue + # https://gitlab.com/wireshark/wireshark/-/issues/19109 + docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off +fi if [ ${CAPTURE} -eq 1 ]; then echo "Starting capture within docker"