Skip to content

Commit 136f17a

Browse files
committed
feat: testing scripts used
1 parent 81402f6 commit 136f17a

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/target
22
Cargo.lock
33
*.pcap
4-
/scripts
54
/*.md
65
*.log

scripts/cleanup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/bash
2+
3+
sudo ip link delete dev tap0
4+
sudo ip link delete dev tap1
5+
sudo ip link delete dev br0

scripts/emulate_setup.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/bash
2+
3+
# Set up tap0
4+
sudo ip tuntap add name tap0 mode tap user $USER
5+
sudo ip link set tap0 up
6+
sudo ip addr add 192.168.69.1/24 dev tap0
7+
8+
# Set up tap1
9+
sudo ip tuntap add name tap1 mode tap user $USER
10+
sudo ip link set tap1 up
11+
sudo ip addr add 192.168.69.2/24 dev tap1
12+
13+
# Create a bridge
14+
sudo ip link add name br0 type bridge
15+
16+
# Add both TAP interfaces to the bridge
17+
sudo ip link set tap0 master br0
18+
sudo ip link set tap1 master br0
19+
20+
# Bring up the bridge
21+
sudo ip link set br0 up
22+
23+
# Network emulation parameters (customize these!)
24+
DELAY="10ms" # One-way delay (RTT will be 2x this)
25+
BANDWIDTH="400mbit" # Bandwidth limit
26+
BUFFER_PACKETS="4000" # Buffer size in packets (router queue)
27+
MTU=1500 # Maximum transmission unit
28+
NETEM_LIMIT="4000" # Netem queue limit in packets (must be large for high BDP!)
29+
30+
# Calculate buffer size in bytes
31+
BUFFER_BYTES=$((BUFFER_PACKETS * MTU))
32+
33+
# Calculate burst size (should be at least rate/HZ, typically rate/10 for smoother shaping)
34+
# For 10mbit: 10000000/8/10 = 125000 bytes
35+
BURST=$((10 * MTU))
36+
37+
# Apply traffic control on tap0 (server side)
38+
# netem for delay with large buffer to handle BDP
39+
sudo tc qdisc add dev tap0 root handle 1: netem delay $DELAY limit $NETEM_LIMIT
40+
# tbf for bandwidth limiting with tail-drop
41+
sudo tc qdisc add dev tap0 parent 1:1 handle 10: tbf rate $BANDWIDTH burst $BURST limit $BUFFER_BYTES
42+
43+
# Apply traffic control on tap1 (client side)
44+
sudo tc qdisc add dev tap1 root handle 1: netem delay $DELAY limit $NETEM_LIMIT
45+
sudo tc qdisc add dev tap1 parent 1:1 handle 10: tbf rate $BANDWIDTH burst $BURST limit $BUFFER_BYTES
46+
47+
echo "Network emulation setup complete:"
48+
echo " - Delay: $DELAY per direction (RTT: ~$((2 * ${DELAY%ms}))ms)"
49+
echo " - Bandwidth: $BANDWIDTH"
50+
echo " - Buffer: $BUFFER_PACKETS packets ($BUFFER_BYTES bytes)"
51+
echo " - Loss: Only on buffer overflow (tail-drop)"
52+
echo ""
53+
echo "BDP calculation for reference:"
54+
BDP_BYTES=$((${BANDWIDTH%mbit} * 1000000 / 8 * ${DELAY%ms} / 1000))
55+
BDP_PACKETS=$((BDP_BYTES / MTU))
56+
echo " - Bandwidth-Delay Product: ~$BDP_PACKETS packets ($BDP_BYTES bytes)"
57+
if [ $BUFFER_PACKETS -lt $BDP_PACKETS ]; then
58+
echo " ⚠ Warning: Buffer < BDP, expect losses even at full link utilization"
59+
else
60+
echo " ✓ Buffer >= BDP, good for testing"
61+
fi

scripts/perf_client_run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/bash
2+
3+
# Usage: ./scripts/perf_client_run.sh [bbr|cubic|reno|none]
4+
# Default is bbr
5+
6+
ALGO=${1:-bbr}
7+
8+
SMOLTCP_IFACE_MAX_ADDR_COUNT=3 ./target/release/examples/perf_client --tap tap1 -c $ALGO -s 192.168.69.1 -p 8000

scripts/perf_server_run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/bash
2+
3+
# Usage: ./scripts/perf_server_run.sh [bbr|cubic|reno|none]
4+
# Default is bbr
5+
6+
ALGO=${1:-bbr}
7+
8+
SMOLTCP_IFACE_MAX_ADDR_COUNT=3 ./target/release/examples/perf_server --tap tap0 -c $ALGO

0 commit comments

Comments
 (0)