Packet loss and round-trip time are two important network performance metrics that affect the throughput of TCP connections. Real-time monitoring these two values across a Wide Area Network or WiFi can help you quickly identify slowness experienced by the end-users and applications. In this article I will show a demonstration on how packet loss and round-trip time impact the TCP throughput.
Packet Loss is calculated as the percentage of packets that are received malformed or not received at all. This key performance metric is a good measurement of network quality because it accurately reflects the reliability of a network. Packet loss is caused by malformed packets being received by the destination, or worse, no packets being received at all.
Round-Trip Time represents the time that it takes for a data packet to go back and forth to a specific destination. The round-trip time value depends on the length of all network links traversed, plus the latency that is incurred at each hop, including the destination host.
Throughput and The Mathis Equation
Throughput is the amount of data successfully transferred between a source and a destination host. This value should not be confused with bandwidth or the data rate. Bandwidth, like data rate, is the maximum throughput achievable on a network, or link, and is generally established by the media and encoding technologies. Throughput is the actual transfer rate achieved between a sender and a receiver.
Since the TCP protocol is widely used to browse Internet websites and to download files, the network performance metrics that dictate its performance are very important to capture the end-user experience.
The Mathis Equation
There are three core metrics that affect the throughput of a TCP connection: round-trip time (RTT), packet loss (p), and the maximum segment size (MSS). A good model that describes the relationship of these three throughput variables is the Mathis Equation. The Mathis Equation states that the maximum throughput achieved by a TCP connection can be calculated by dividing MSS by RTT and multiplying the result by 1 over the square root of p, where p represents the packet loss.
Lab scenario with packet loss
I recorded a video demonstration where I ran an iperf TCP test both with and without packet loss and compared the throughput that was returned (link below). You can skip to minute 1:48 of the video if you don’t want to go through the initial slide deck:
The TCP transfer without packet loss returned approximately 94 Mbps of throughput (minute 3:20 in the video). The TCP transfer with 10% returned a throughput of 2.88 Mbps (minute 5:35). This is a straightforward demonstration of Mathis equation.
Testing The Mathis Equation with iperf and tc
You may want to test the Mathis equation independently to see the impact of packet loss and increased round-trip time on the TCP throughput. To stage such lab, you’ll need two Linux hosts (you can also use vBox virtual machines on your laptop) with iperf installed to generate the TCP throughput between the two nodes and tc, the Linux traffic control utility, to introduce packet loss and increase the round-trip time on one of the two hosts (here we’ll pick the client).
To test the Matis equation you can run the following scenarios:
Test 1: TCP throughput without packet loss and no increased round-trip time. Test 2: TCP throughput with packet loss only. Test 3: TCP throughput with increased round-trip time only.
Test 1 – Run a simple TCP throughput test with iperf.
Run the iperf server on one Linux host with this command:iperf –s
Running the iperf client on the other linux host with this command:iperf –c SERVER_IP
Test 2 – Increase packet loss to 10% on the client
To increase packet loss on the iperf client just run the following command:tc qdisc add dev eth0 root netem loss 10%
Then run the iperf server and client as shown on test 1. Once the test is completed you can remove the rule with the following command:tc qdisc del dev eth0 root
Test 3 – Increase round-trip time on the client
To increase the round-trip time to 200ms on the iperf client just run the following command:tc qdisc add dev eth0 root netem delay 200ms
Then run the iperf server and client as shown on Test 1. Once the test is completed you can remove the rule with the following command:tc qdisc del dev eth0 root
Packet loss and round-trip time are two important network performance metrics that affect the throughput of TCP connections. Monitoring these two values on a wired and WiFi network is very important to detect issues that impact the end-users and applications experience.