]> git.meshlink.io Git - utcp/blob - benchmark
Use flightsize instead of cwnd to set ssthresh.
[utcp] / benchmark
1 #!/bin/bash
2 set -e
3
4 # Configuration
5 LOG_PREFIX=/dev/shm/benchmark-log
6 SIZE=10000000
7 RATE=100mbit
8 DELAY=10ms
9 JITTER=1ms
10 LOSS=0.1%
11
12 # Require root permissions
13 if [ "$USER" != "root" ]; then
14         exec sudo "$0" "$@"
15 fi
16
17 # Remove old log files
18 rm -f $LOG_PREFIX-* 2>/dev/null
19
20 # Clean up old namespaces
21 ip link del utcp-left 2>/dev/null || true
22 ip link del utcp-right 2>/dev/null || true
23 ip netns delete utcp-left 2>/dev/null || true
24 ip netns delete utcp-right 2>/dev/null || true
25
26 # Set up the left namespace
27 ip netns add utcp-left
28 ip link add name utcp-left type veth peer name utcp-right
29 ip link set utcp-left netns utcp-left
30
31 ip netns exec utcp-left ethtool -K utcp-left tso off
32 ip netns exec utcp-left ip link set dev lo up
33 ip netns exec utcp-left ip addr add dev utcp-left 192.168.1.1/24
34 ip netns exec utcp-left ip link set utcp-left up
35
36 #ip netns exec utcp-left tc qdisc del dev utcp-left root
37 ip netns exec utcp-left tc qdisc add dev utcp-left root netem rate $RATE delay $DELAY $JITTER loss random $LOSS
38
39 # Set up the right namespace
40 ip netns add utcp-right
41 ip link set utcp-right netns utcp-right
42
43 ip netns exec utcp-right ethtool -K utcp-right tso off
44 ip netns exec utcp-right ip link set dev lo up
45 ip netns exec utcp-right ip addr add dev utcp-right 192.168.1.2/24
46 ip netns exec utcp-right ip link set utcp-right up
47
48 #ip netns exec utcp-right tc qdisc del dev utcp-right root
49 ip netns exec utcp-right tc qdisc add dev utcp-right root netem rate $RATE delay $DELAY $JITTER loss random $LOSS
50 # Test using kernel TCP
51 ip netns exec utcp-right tcpdump -i utcp-right -w $LOG_PREFIX-socat.pcap port 9999 2>/dev/null &
52 ip netns exec utcp-left socat TCP4-LISTEN:9999 - >/dev/null &
53 sleep 0.1
54 head -c $SIZE /dev/zero | ip netns exec utcp-right time socat - TCP4:192.168.1.1:9999 2>$LOG_PREFIX-socat-client.txt >/dev/null
55 sleep 0.1
56 kill $(jobs -p) 2>/dev/null
57
58 # Test using UTCP
59 ip netns exec utcp-right tcpdump -i utcp-right -w $LOG_PREFIX-utcp.pcap udp port 9999 2>/dev/null &
60 ip netns exec utcp-left ./test 9999 2>$LOG_PREFIX-server.txt >/dev/null &
61 sleep 0.1
62 head -c $SIZE /dev/zero | ip netns exec utcp-right time ./test 192.168.1.1 9999 2>$LOG_PREFIX-client.txt >/dev/null
63 sleep 0.1
64 kill $(jobs -p) 2>/dev/null
65
66 # Print timing statistics
67 echo "Regular TCP:"
68 tail -2 $LOG_PREFIX-socat-client.txt
69
70 echo
71 echo "UTCP:"
72 tail -2 $LOG_PREFIX-client.txt
73
74 # If sudo was used, ensure the log files can be read by the user
75 if [ -n "$SUDO_USER" ]; then
76         chown $SUDO_USER $LOG_PREFIX-*
77 fi