Skip to content

Commit 6b4465d

Browse files
Allow running perf client and server within dockers
1 parent f5632ce commit 6b4465d

File tree

7 files changed

+211
-0
lines changed

7 files changed

+211
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99

1010
cargo-test-*
1111
tarpaulin-report.html
12+
13+
perf/docker/work/
14+

perf/docker/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# https://hub.docker.com/_/debian
2+
FROM debian:bookworm-slim
3+
4+
RUN apt-get update && apt-get install -y procps iputils-ping iproute2 ethtool tcpdump
5+
6+
WORKDIR /root
7+
8+
RUN mkdir -p .local/share/quinn
9+
10+
COPY ./entrypoint.sh .
11+
12+
COPY ./target/perf .
13+
14+
ENTRYPOINT [ "/root/entrypoint.sh" ]

perf/docker/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env -S bash -eu
2+
3+
CURDIR=$(pwd)
4+
5+
mkdir -p ./target
6+
7+
cd ../..
8+
cargo build -p perf --release
9+
cp -au ./target/release/perf ${CURDIR}/target
10+
11+
cd ${CURDIR}
12+
docker compose build

perf/docker/docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
networks:
2+
quinn-perf:
3+
ipam:
4+
config:
5+
- subnet: 172.42.0.0/16
6+
7+
services:
8+
server:
9+
build: .
10+
image: quinn_perf
11+
networks:
12+
quinn-perf:
13+
ipv4_address: 172.42.0.2
14+
volumes:
15+
- ./work:/root/.local/share/quinn
16+
cap_add:
17+
- NET_ADMIN
18+
environment:
19+
- SSLKEYLOGFILE=/root/.local/share/quinn/server.key
20+
21+
client:
22+
image: quinn_perf
23+
networks:
24+
quinn-perf:
25+
ipv4_address: 172.42.0.3
26+
volumes:
27+
- ./work:/root/.local/share/quinn
28+
cap_add:
29+
- NET_ADMIN
30+
environment:
31+
- SSLKEYLOGFILE=/root/.local/share/quinn/client.key

perf/docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
while :; do sleep 10; done

perf/docker/run-client.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env -S bash -eu
2+
3+
SERVICE=client
4+
PERF_CLIENT_ARGS="--keylog --duration 5 172.42.0.2:4433"
5+
6+
LATENCY=0
7+
LOSS=0
8+
GSO=0
9+
CAPTURE=0
10+
OPEN=0
11+
12+
function usage() {
13+
echo "usage: $0 [-cgho] [-l number]"
14+
echo " -c enable packet capture"
15+
echo " -g enable GSO (default: disabled)"
16+
echo " -h display help"
17+
echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)"
18+
echo " -L number specify simulated packet loss in percentage (default: ${LOSS}%)"
19+
echo " -o open packet capture"
20+
exit 1
21+
}
22+
23+
while getopts "cghl:L:o" opt; do
24+
case $opt in
25+
c) CAPTURE=1;;
26+
g) GSO=1;;
27+
l) LATENCY=$OPTARG;;
28+
L) LOSS=$OPTARG;;
29+
o) OPEN=1;;
30+
h) usage;;
31+
*) usage;;
32+
esac
33+
done
34+
35+
mkdir -p ./work
36+
37+
echo "Launching docker ${SERVICE}"
38+
docker compose up -d --force-recreate ${SERVICE}
39+
if [ "${LATENCY}" -ne "0" ] || [ "${LOSS}" -ne "0" ]; then
40+
echo "Enforcing a latency of ${LATENCY}ms and a packet loss of ${LOSS}%"
41+
docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay "${LATENCY}ms" loss "${LOSS}%"
42+
fi
43+
44+
if [ ${GSO} -eq 0 ]; then
45+
# FIXME disable GSO due to this issue
46+
# https://gitlab.com/wireshark/wireshark/-/issues/19109
47+
docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off
48+
fi
49+
50+
if [ ${CAPTURE} -eq 1 ]; then
51+
echo "Starting capture within docker"
52+
docker compose exec -d ${SERVICE} tcpdump -ni eth0 -s0 -w /root/.local/share/quinn/${SERVICE}.pcap udp and port 4433
53+
fi
54+
55+
echo "Launching quinn perf client"
56+
docker compose exec -it ${SERVICE} /root/perf client ${PERF_CLIENT_ARGS}
57+
58+
if [ ${CAPTURE} -eq 1 ]; then
59+
echo "Stopping capture within docker"
60+
docker compose exec -it ${SERVICE} killall -STOP tcpdump
61+
fi
62+
63+
if [ "${LATENCY}" -ne "0" ] || [ "${LOSS}" -ne "0" ]; then
64+
echo "Dumping QOS stats"
65+
docker compose exec -it ${SERVICE} tc -s qdisc ls dev eth0
66+
fi
67+
68+
if [ ${CAPTURE} -eq 1 ] && [ ${OPEN} -eq 1 ]; then
69+
wireshark -o tls.keylog_file:./work/${SERVICE}.key ./work/${SERVICE}.pcap
70+
fi

perf/docker/run-server.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env -S bash -eu
2+
3+
SERVICE=server
4+
PERF_SERVER_ARGS="--keylog --listen 172.42.0.2:4433"
5+
6+
LATENCY=0
7+
LOSS=0
8+
GSO=0
9+
CAPTURE=0
10+
OPEN=0
11+
12+
function usage() {
13+
echo "usage: $0 [-cgho] [-l number]"
14+
echo " -c enable packet capture"
15+
echo " -g enable GSO (default: disabled)"
16+
echo " -h display help"
17+
echo " -l number specify simulated latency in ms (default: ${LATENCY}ms)"
18+
echo " -L number specify simulated packet loss in percentage (default: ${LOSS}%)"
19+
echo " -o open packet capture"
20+
exit 1
21+
}
22+
23+
while getopts "cghl:L:o" opt; do
24+
case $opt in
25+
c) CAPTURE=1;;
26+
g) GSO=1;;
27+
l) LATENCY=$OPTARG;;
28+
L) LOSS=$OPTARG;;
29+
o) OPEN=1;;
30+
h) usage;;
31+
*) usage;;
32+
esac
33+
done
34+
35+
mkdir -p ./work
36+
37+
echo "Launching docker ${SERVICE}"
38+
docker compose up -d --force-recreate ${SERVICE}
39+
if [ "${LATENCY}" -ne "0" ] || [ "${LOSS}" -ne "0" ]; then
40+
echo "Enforcing a latency of ${LATENCY}ms and a packet loss of ${LOSS}%"
41+
docker compose exec -it ${SERVICE} tc qdisc add dev eth0 root netem delay "${LATENCY}ms" loss "${LOSS}%"
42+
fi
43+
44+
if [ ${GSO} -eq 0 ]; then
45+
# FIXME disable GSO due to this issue
46+
# https://gitlab.com/wireshark/wireshark/-/issues/19109
47+
docker compose exec -it ${SERVICE} ethtool -K eth0 tx-udp-segmentation off
48+
fi
49+
50+
if [ ${CAPTURE} -eq 1 ]; then
51+
echo "Starting capture within docker"
52+
docker compose exec -d ${SERVICE} tcpdump -ni eth0 -s0 -w /root/.local/share/quinn/${SERVICE}.pcap udp port 4433
53+
fi
54+
55+
echo "Launching quinn perf server"
56+
docker compose exec -d ${SERVICE} /root/perf server ${PERF_SERVER_ARGS}
57+
58+
echo "Press Ctrl-C to stop server"
59+
( trap exit SIGINT ; read -r -d '' _ </dev/tty )
60+
61+
echo "Stopping server"
62+
docker compose exec -it ${SERVICE} killall -STOP perf
63+
64+
if [ ${CAPTURE} -eq 1 ]; then
65+
echo "Stopping capture within docker"
66+
docker compose exec -it ${SERVICE} killall -STOP tcpdump
67+
fi
68+
69+
if [ "${LATENCY}" -ne "0" ] || [ "${LOSS}" -ne "0" ]; then
70+
echo "Dumping QOS stats"
71+
docker compose exec -it ${SERVICE} tc -s qdisc ls dev eth0
72+
fi
73+
74+
docker compose down
75+
76+
if [ ${CAPTURE} -eq 1 ] && [ ${OPEN} -eq 1 ]; then
77+
wireshark -o tls.keylog_file:./work/${SERVICE}.key ./work/${SERVICE}.pcap
78+
fi

0 commit comments

Comments
 (0)