-
-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow running perf client and server within dockers
- Loading branch information
1 parent
20dff91
commit 6419ae6
Showing
7 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ Cargo.lock | |
.idea | ||
.DS_Store | ||
.vscode | ||
|
||
perf/docker/work/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
while :; do sleep 10; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '' _ </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 |