Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running perf client and server within dockers #1659

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Cargo.lock
.idea
.DS_Store
.vscode

perf/docker/work/
15 changes: 15 additions & 0 deletions perf/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
12 changes: 12 additions & 0 deletions perf/docker/build.sh
Ralith marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env -S bash -eu

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
33 changes: 33 additions & 0 deletions perf/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions perf/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

while :; do sleep 10; done
67 changes: 67 additions & 0 deletions perf/docker/run-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env -S bash -eu

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 [-cgho] [-l number]"
echo " -c enable 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 "cghl:o" opt; do
case $opt in
c) CAPTURE=1;;
g) GSO=1;;
l) LATENCY=$OPTARG;;
o) OPEN=1;;
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

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"
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
75 changes: 75 additions & 0 deletions perf/docker/run-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env -S bash -eu

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 [-cgho] [-l number]"
echo " -c enable 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 "cghl:o" opt; do
case $opt in
c) CAPTURE=1;;
g) GSO=1;;
l) LATENCY=$OPTARG;;
o) OPEN=1;;
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

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"
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 '' _ </dev/tty )

echo "Stopping server"
docker compose exec -it ${SERVICE} killall -STOP perf_${SERVICE}

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

docker compose down

if [ ${CAPTURE} -eq 1 ] && [ ${OPEN} -eq 1 ]; then
wireshark -o tls.keylog_file:./work/${SERVICE}.key ./work/${SERVICE}.pcap
fi