User Tools

Site Tools


networking:tcp_testing

tcp_testing

TCP testing in Linux is an continuous process. These tests are concerned with the behavior and correctness of the TCP protocol in the Linux kernel.

More will be added to this page soon.

Contents

Tools

Many tools are available for building TCP tests, but some of the basic ones are:

  • a simple client/server test application.
  • kernel module that creates a way to see TCP endpoint state changes
  • emulate long delays, packet loss etc.

Tuning

When running TCP experiments over high Bandwidth Delay Product (BDP) you probably want to change the maximum available TCP window size. TCP tuning is done via wikipedia:sysctl parameters documented in Net:Ip-sysctl (or Documentation/networking/ip-sysctl.txt) see for more info. At a minimum increase tcp_rmem[2] for receiver and tcp_wmem[2] for sender to twice the BDP.

If the test involves repeated connections, you should also turn off the route metrics:

 sysctl -w net.ipv4.tcp_no_metrics_save=1

Normally Linux will remember the last slow start threshold (ssthresh). This modifies the result of the second test, and causes errors.

Experiments

Congestion Control

The purpose of congestion control tests is to observe how the congestion window changes with different network conditions. These tests have lots of possible variables and there is no one “right answer”.

Example

A basic test would be:

  1. Start iperf server on the receiver
 iperf -s
  1. Insert tcp_probe module (as root) on sending machine and filter for iperf port. You can change the mode to allow non-root user access
 modprobe tcp_probe port=5001
 chmod 444 /proc/net/tcpprobe
  1. Capture tcp probe output (on sender) and place in background
 cat /proc/net/tcpprobe >/tmp/tcpprobe.out &
 TCPCAP=$!
  1. Run iperf test on sender for 15minutes
 iperf -i 10 -t 300 -c //receiver//
  1. Kill capture process
  kill $TCPCAP

The tcp probe capture file will contain one line for each packet sent.

 0.073678 10.8.0.54:38644 192.168.1.42:5001 24 0xb6b19bb 0xb6b19bb 2 2147483647 5792
 ^        ^               ^                 ^  ^         ^         ^ ^          ^
 |        |               |                 |  |         |         | |          +- [9] Send window
 |        |               |                 |  |         |         | +------------ [8] Slow start threshold
 |        |               |                 |  |         |         +-------------- [7] Congestion window
 |        |               |                 |  |         +------------------------ [6] Unacknowledged sequence #
 |        |               |                 |  +---------------------------------- [5] Next send sequence #
 |        |               |                 +------------------------------------- [4] Bytes in packet
 |        |               +------------------------------------------------------- [3] Receiver address:port
 |        +----------------------------------------------------------------------- [2] Sender address:port
 +-------------------------------------------------------------------------------- [1] Time seconds
 
 * The value of slow start threshold here is (-1) which means it hasn't been determined yet
 * Time since Tcp probe was loaded.

This text file can be easily filtered and modified with standard tools such as awk and perl. A common usage is to make a plot of congestion window and slow start threshold over time using gnuplot.

 $ gnuplot -persist <<"EOF"
 set data style linespoints
 show timestamp
 set xlabel "time (seconds)"
 set ylabel "Segments (cwnd, ssthresh)"
 plot "/tmp/tcpprobe.out" using 1:7 title "snd_cwnd", \
      "/tmp/tcpprobe.out" using 1:($8>=2147483647 ? 0 : $8) title "snd_ssthresh"
 EOF

The result should look something like this:

A set of scripts to run test like this and plot are available [1]

Variations

There are many possible factors that can be evaluated in any test. For a good discussion of the issues see the paper:On the effective evaluation of TCP and Experimental evaluation of TCP protocols for high-speed networks.

  • Algorithim 
  • Linux provides many congestion control algorithms now.
  • BDP 
  • TCP needs to adapt to a wide range of band-width delay products
  • Loss 
  • TCP should recover from moderate loss, but since most congestion control algorithms use loss to estimate BDP; they have trouble distinguishing random packet loss from router queue overflow packet drop.
  • Fairness 
  • Define fairness and how to measure it
  • Background traffic
  • Describe how to add background traffic via harpoon here

Performance

On Linux TCP should be able to fully saturate the network given a sufficiently fast CPU and bus for a single connection. Some useful tools are:

  • netperf allow for measuring CPU utilization
  • Apache benchmark for measuring lots of web connections
  • curl-loader web traffic generation (HTTP/S, FTP/S) with 10-20K and more real HTTP sessions

See also Performance Testing .

Protocol Conformance

There are (expensive) TCP protocol validation suites.

Fuzz testing is a useful way to find unexpected bugs in the TCP processing.ISIC is a suite of utilities to exercise the stability of an IP Stack and its component stacks (TCP, UDP, ICMP et. al.)


networking/tcp_testing.txt · Last modified: 2016/07/19 01:22 (external edit)