gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/benchmarks/tcp/README.md (about) 1 # TCP Benchmarks 2 3 This directory contains a standardized TCP benchmark. This helps to evaluate the 4 performance of netstack and native networking stacks under various conditions. 5 6 ## `tcp_benchmark` 7 8 This benchmark allows TCP throughput testing under various conditions. The setup 9 consists of an iperf client, a client proxy, a server proxy and an iperf server. 10 The client proxy and server proxy abstract the network mechanism used to 11 communicate between the iperf client and server. 12 13 The setup looks like the following: 14 15 ``` 16 +--------------+ (native) +--------------+ 17 | iperf client |[lo @ 10.0.0.1]------>| client proxy | 18 +--------------+ +--------------+ 19 [client.0 @ 10.0.0.2] 20 (netstack) | | (native) 21 +------+-----+ 22 | 23 [br0] 24 | 25 Network emulation applied ---> [wan.0:wan.1] 26 | 27 [br1] 28 | 29 +------+-----+ 30 (netstack) | | (native) 31 [server.0 @ 10.0.0.3] 32 +--------------+ +--------------+ 33 | iperf server |<------[lo @ 10.0.0.4]| server proxy | 34 +--------------+ (native) +--------------+ 35 ``` 36 37 Different configurations can be run using different arguments. For example: 38 39 * Native test under normal internet conditions: `tcp_benchmark` 40 * Native test under ideal conditions: `tcp_benchmark --ideal` 41 * Netstack client under ideal conditions: `tcp_benchmark --client --ideal` 42 * Netstack client with 5% packet loss: `tcp_benchmark --client --ideal --loss 43 5` 44 45 Use `tcp_benchmark --help` for full arguments. 46 47 This tool may be used to easily generate data for graphing. For example, to 48 generate a CSV for various latencies, you might do: 49 50 ``` 51 rm -f /tmp/netstack_latency.csv /tmp/native_latency.csv 52 latencies=$(seq 0 5 50; 53 seq 60 10 100; 54 seq 125 25 250; 55 seq 300 50 500) 56 for latency in $latencies; do 57 read throughput client_cpu server_cpu <<< \ 58 $(./tcp_benchmark --duration 30 --client --ideal --latency $latency) 59 echo $latency,$throughput,$client_cpu >> /tmp/netstack_latency.csv 60 done 61 for latency in $latencies; do 62 read throughput client_cpu server_cpu <<< \ 63 $(./tcp_benchmark --duration 30 --ideal --latency $latency) 64 echo $latency,$throughput,$client_cpu >> /tmp/native_latency.csv 65 done 66 ``` 67 68 Similarly, to generate a CSV for various levels of packet loss, the following 69 would be appropriate: 70 71 ``` 72 rm -f /tmp/netstack_loss.csv /tmp/native_loss.csv 73 losses=$(seq 0 0.1 1.0; 74 seq 1.2 0.2 2.0; 75 seq 2.5 0.5 5.0; 76 seq 6.0 1.0 10.0) 77 for loss in $losses; do 78 read throughput client_cpu server_cpu <<< \ 79 $(./tcp_benchmark --duration 30 --client --ideal --latency 10 --loss $loss) 80 echo $loss,$throughput,$client_cpu >> /tmp/netstack_loss.csv 81 done 82 for loss in $losses; do 83 read throughput client_cpu server_cpu <<< \ 84 $(./tcp_benchmark --duration 30 --ideal --latency 10 --loss $loss) 85 echo $loss,$throughput,$client_cpu >> /tmp/native_loss.csv 86 done 87 ```