]> git.meshlink.io Git - utcp/blobdiff - benchmark
Handle channel closure during a receive callback when the ringbuffer wraps.
[utcp] / benchmark
index 9b7e67d51691984454270a3d22d43d6ba42eac01..008af3dd880c41f90eb25af6da86797e278c13a3 100755 (executable)
--- a/benchmark
+++ b/benchmark
@@ -4,15 +4,29 @@ set -e
 # Configuration
 LOG_PREFIX=/dev/shm/benchmark-log
 SIZE=10000000
+
+# Network parameters
+# Some realistic values:
+# - Gbit LAN connection: RATE=1gbit DELAY=0.4ms JITTER=0.04ms LOSS=0%
+# - Fast WAN connection: RATE=100mbit DELAY=50ms JITTER=3ms LOSS=0%
+# - 5GHz WiFi connection: RATE=90mbit DELAY=5ms JITTER=1ms LOSS=0%
 RATE=100mbit
 DELAY=10ms
-JITTER=0ms
+JITTER=1ms
+LOSS=0.1%
+
+# Maximum achievable bandwidth is limited to BUFSIZE / (2 * DELAY)
+# The Linux kernel has a default maximum send buffer of 4 MiB
+#export BUFSIZE=4194304
 
 # Require root permissions
 if [ "$USER" != "root" ]; then
        exec sudo "$0" "$@"
 fi
 
+# Remove old log files
+rm -f $LOG_PREFIX-* 2>/dev/null
+
 # Clean up old namespaces
 ip link del utcp-left 2>/dev/null || true
 ip link del utcp-right 2>/dev/null || true
@@ -30,7 +44,7 @@ ip netns exec utcp-left ip addr add dev utcp-left 192.168.1.1/24
 ip netns exec utcp-left ip link set utcp-left up
 
 #ip netns exec utcp-left tc qdisc del dev utcp-left root
-ip netns exec utcp-left tc qdisc add dev utcp-left root netem rate $RATE delay $DELAY $JITTER
+ip netns exec utcp-left tc qdisc add dev utcp-left root netem rate $RATE delay $DELAY $JITTER loss random $LOSS
 
 # Set up the right namespace
 ip netns add utcp-right
@@ -42,8 +56,7 @@ ip netns exec utcp-right ip addr add dev utcp-right 192.168.1.2/24
 ip netns exec utcp-right ip link set utcp-right up
 
 #ip netns exec utcp-right tc qdisc del dev utcp-right root
-ip netns exec utcp-right tc qdisc add dev utcp-right root netem rate $RATE delay $DELAY $JITTER
-
+ip netns exec utcp-right tc qdisc add dev utcp-right root netem rate $RATE delay $DELAY $JITTER loss random $LOSS
 # Test using kernel TCP
 ip netns exec utcp-right tcpdump -i utcp-right -w $LOG_PREFIX-socat.pcap port 9999 2>/dev/null &
 ip netns exec utcp-left socat TCP4-LISTEN:9999 - >/dev/null &
@@ -66,7 +79,7 @@ tail -2 $LOG_PREFIX-socat-client.txt
 
 echo
 echo "UTCP:"
-tail -2 $LOG_PREFIX-client.txt
+tail -3 $LOG_PREFIX-client.txt
 
 # If sudo was used, ensure the log files can be read by the user
 if [ -n "$SUDO_USER" ]; then