Skip to content

Commit bc96dbc

Browse files
Merge pull request #2012 from jasonrandrews/review
Tech review of iperf3 Learning Path
2 parents 831570c + 699c56b commit bc96dbc

6 files changed

Lines changed: 104 additions & 53 deletions

File tree

content/learning-paths/servers-and-cloud-computing/microbenchmark-network-iperf3/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ learning_objectives:
1515

1616
prerequisites:
1717
- Foundational understanding of networking principles such as TCP/IP and UDP.
18-
- Access to two Arm-based cloud instances or local Arm Linux systems.
18+
- Access to two [Arm-based cloud instances](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/).
1919

2020
author: Kieran Hejmadi
2121

content/learning-paths/servers-and-cloud-computing/microbenchmark-network-iperf3/basic-microbenchmarking.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
---
2-
title: Microbenchmark Existing Network Connection
2+
title: Microbenchmark the network connection
33
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Microbenchmark TCP Connection
9+
## Microbenchmark the TCP connection
1010

11+
You can microbenchmark the bandwidth between the client and server.
1112

12-
First we will microbenchmark the bandwidth between the client and server. First start the `iperf` server on the server node with the following command.
13+
First, start `iperf` in server mode on the server system with the following command:
1314

1415
```bash
1516
iperf3 -s
1617
```
1718

19+
You see the output, indicating the server is ready:
20+
1821
```output
1922
-----------------------------------------------------------
2023
Server listening on 5201 (test #1)
2124
-----------------------------------------------------------
2225
23-
2426
```
25-
By default, the server listens on port 5201. Use the `-p` flag to specify another port if it is in use.
27+
28+
The default server port is 5201. Use the `-p` flag to specify another port if it is in use.
2629

2730
{{% notice Tip %}}
2831
If you already have an `iperf3` server running, you can manually kill the process with the following command.
@@ -31,13 +34,14 @@ If you already have an `iperf3` server running, you can manually kill the proces
3134
```
3235
{{% /notice %}}
3336

34-
3537
Next, on the client node, run the following command to run a simple 10-second microbenchmark using the TCP protocol.
3638

3739
```bash
3840
iperf3 -c SERVER -V
3941
```
4042

43+
The output is similar to:
44+
4145
```output
4246
...
4347
[ 5] local 10.248.213.97 port 42176 connected to 10.248.213.104 port 5201
@@ -65,27 +69,27 @@ rcv_tcp_congestion cubic
6569
iperf Done.
6670
```
6771

68-
- The`Cwnd` stands for the control window size and corresponds to the allowed number of TCP transactions inflight before receiving an acknowledgment `ACK` from the server. This adjusts dynamically to not overwhelm the receiver and adjust for variable link connection strengths.
72+
- The`Cwnd` column prints the control window size and corresponds to the allowed number of TCP transactions inflight before receiving an acknowledgment `ACK` from the server. This adjusts dynamically to not overwhelm the receiver and adjust for variable link connection strengths.
6973

70-
- The `CPU Utilization` row shows both the usage on the sender and receiver. If you are migrating your workload to a different platform, such as from `x86` to `AArch64`, there may be subtle variations.
74+
- The `CPU Utilization` row shows both the usage on the sender and receiver. If you are migrating your workload to a different platform, such as from x86 to Arm, there may be variations.
7175

7276
- The `snd_tcp_congestion cubic` abd `rcv_tcp_congestion cubic` variables show the congestion control algorithm used.
7377

74-
- This `bitrate` shows the throughput achieved under this microbenchmark. As we can see from the above, we have saturated the 5 Gbps bandwidth available to our `t4g.xlarge` AWS instance.
78+
- This `bitrate` shows the throughput achieved under this microbenchmark. As you can see, the 5 Gbps bandwidth available to the `t4g.xlarge` AWS instance is saturated.
7579

7680
![instance-network-size](./instance-network-size.png)
7781

7882
### Microbenchmark UDP connection
7983

80-
We can also microbenchmark the `UDP` protocol with the `-u` flag. As a reminder, UDP does not guarantee packet delivery with some packets being lost. As such we need to observe the statistics on the server side to see the % of packet lost and the variation in packet arrival time (jitter). The UDP protocol is widely used in applications that need timely packet delivery, such as online gaming on video calls.
84+
You can also microbenchmark the `UDP` protocol with the `-u` flag. As a reminder, UDP does not guarantee packet delivery with some packets being lost. As such you need to observe the statistics on the server side to see the percent of packets lost and the variation in packet arrival time (jitter). The UDP protocol is widely used in applications that need timely packet delivery, such as online gaming and video calls.
8185

8286
Run the following command from the client to send 2 parallel UDP streams with the `-P 2` option.
8387

8488
```bash
8589
iperf3 -c SERVER -V -u -P 2
8690
```
8791

88-
Looking at the server output we can observe 0% of packets where lost for our short test.
92+
Looking at the server output you observe 0% of packets where lost for the short test.
8993

9094
```output
9195
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
@@ -94,7 +98,7 @@ Looking at the server output we can observe 0% of packets where lost for our sho
9498
[SUM] 0.00-10.00 sec 2.51 MBytes 2.10 Mbits/sec 0.015 ms 0/294 (0%) receiver
9599
```
96100

97-
Additionally on the client side, our 2 streams saturated 2 of our 4 cores in the local node.
101+
Additionally on the client side, the 2 streams saturated 2 of the 4 cores in the system.
98102

99103
```output
100104
CPU Utilization: local/sender 200.3% (200.3%u/0.0%s), remote/receiver 0.2% (0.0%u/0.2%s)
Binary file not shown.
Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,72 @@
11
---
2-
title: Setup
2+
title: Prepare for network performance testing
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
### Setup
9+
## Configure two Arm-based Linux computers
1010

11-
For this demonstration I will be using instances available from AWS within a virtual private cloud (VPC)
11+
To perform network performance testing you need two Linux computers. You can use AWS EC2 instances with Graviton processors or any other Linux virtual machines from another cloud service provider.
1212

13-
Create 2 Arm-based linux instances, 1 to act as the server and the other to act as the client. In this tutorial I will be using two `t4g.xlarge` instance running Ubuntu 22.04 LTS.
13+
You will also experiment with a local computer and a cloud instance to learn the networking performance differences compared to two cloud instances.
1414

15+
The instructions below use EC2 instances from AWS connected in a virtual private cloud (VPC).
1516

16-
### Install dependencies
17+
To get started, create two Arm-based Linux instances, one system to act as the server and the other to act as the client. The instructions below use two `t4g.xlarge` instances running Ubuntu 24.04 LTS.
1718

18-
Run the following command to install the microbenchmark tool, `iperf3`.
19+
### Install software dependencies
20+
21+
Use the commands below to install `iperf3`, a powerful and flexible open-source command-line tool used for network performance measurement and tuning. It allows network administrators and engineers to actively measure the maximum achievable bandwidth on IP networks.
22+
23+
Run the following on both systems:
1924

2025
```bash
2126
sudo apt update
2227
sudo apt install iperf3 -y
2328
```
2429

30+
{{% notice Note %}}
31+
If you are prompted to start `iperf3` as a daemon you can answer no.
32+
{{% /notice %}}
2533

26-
### Update Security Rules
34+
## Update Security Rules
2735

28-
Next, we need to update the default security rules to enable specific inbound and outbound protocols. From the AWS console, navigate to the security tab. Edit the inbound rules to enable `ICMP`, `UDP` and `TCP` traffic to enable communication between the client and server
36+
If you are working in a cloud environment like AWS, you need to update the default security rules to enable specific inbound and outbound protocols.
2937

38+
From the AWS console, navigate to the security tab. Edit the inbound rules to enable `ICMP`, `UDP` and `TCP` traffic to enable communication between the client and server systems.
3039

3140
![example_traffic](./example_traffic_rules.png)
3241

3342
{{% notice Note %}}
34-
For security set the source and port ranges to those that are being used
43+
For additional security set the source and port ranges to the values being used. A good solution is to open TCP port 5201 and all UDP ports and use your security group as the source. This doesn't open any traffic from outside AWS.
3544
{{% /notice %}}
3645

46+
## Update the local DNS
3747

38-
### Update local DNS
48+
To avoid using IP addresses directly, add the IP address of the other system to the `/etc/hosts` file.
3949

40-
For readability, we will add the server IP address and an alias to the local DNS cache in `/etc/hosts`. The local IP address of the server and client can be found in the AWS dashboard.
50+
The local IP address of the server and client can be found in the AWS dashboard. You can also use commands like `ifconfig`, `hostname -I`, or `ip address` to find your local IP address.
4151

42-
On the client, add the IP address of the server to the `/etc/hosts` file. Likewise on the server add the IP address of the client to the `/etc/hosts` file.
52+
On the client, add the IP address of the server to the `/etc/hosts` file with name `SERVER`.
4353

44-
![server-ip](./server-ip.png).
54+
```output
55+
127.0.0.1 localhost
56+
10.248.213.104 SERVER
57+
```
4558

46-
### Confirm server is reachable
59+
Repeat the same thing on the server and add the IP address of the client to the `/etc/hosts` file with the name `CLIENT`.
4760

48-
Finally, confirm the client can reach the server with the ping command below. As a reference we also ping the localhost.
61+
## Confirm server is reachable
62+
63+
Finally, confirm the client can reach the server with the ping command below. As a reference you can also ping the localhost.
4964

5065
```bash
5166
ping SERVER -c 3 && ping 127.0.0.1 -c 3
5267
```
5368

54-
The output below shows that both SERVER and localhost (127.0.0.1) are reachable. Naturally, on this system local host response tile is ~10x faster than the server. Your results will vary depending on geographic colocation and other networking factors.
69+
The output below shows that both SERVER and localhost (127.0.0.1) are reachable. Naturally, the local host response time is ~10x faster than the server. Your results will vary depending on geographic location of the systems and other networking factors.
5570

5671
```output
5772
PING SERVER (10.248.213.104) 56(84) bytes of data.
@@ -70,6 +85,6 @@ PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
7085
--- 127.0.0.1 ping statistics ---
7186
3 packets transmitted, 3 received, 0% packet loss, time 2046ms
7287
rtt min/avg/max/mdev = 0.022/0.027/0.032/0.004 ms
73-
7488
```
7589

90+
Continue to the next section to learn how to measure the network bandwidth between the systems.

content/learning-paths/servers-and-cloud-computing/microbenchmark-network-iperf3/simulating-network-conditions.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
---
2-
title: Simulating Different Network Conditions
2+
title: Simulating different network conditions
33
weight: 4
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Adding a delay to a TCP connection
9+
## Add a delay to the TCP connection
1010

11-
The linux `tc` utility can be used to manipulate traffic control settings. First, find the name of interface with the following command.
11+
The Linux `tc` utility can be used to manipulate traffic control settings.
12+
13+
First, on the client system, find the name of network interface with the following command:
1214

1315
```bash
1416
ip addr show
@@ -32,14 +34,21 @@ The output below shows the `ens5` network interface device (NIC) is the device w
3234
3335
```
3436

35-
Run the following command to add an emulated delay of 10ms on `ens5`.
37+
Run the following command on the client system to add an emulated delay of 10ms on `ens5`.
3638

3739
```bash
3840
sudo tc qdisc add dev ens5 root netem delay 10ms
3941
```
4042

41-
Rerunning the basic TCP test (`iperf3 -c SERVER -V`) with a delay we observe the `Cwnd` size has grew larger to compensate for the longer response time. Additionally, the bitrate has dropped from ~4.9 to ~2.3 `Gbit/sec`.
43+
Rerun the basic TCP test as before on the client:
44+
45+
```bash
46+
iperf3 -c SERVER -V
47+
```
4248

49+
Observe that the `Cwnd` size has grew larger to compensate for the longer response time.
50+
51+
Additionally, the bitrate has dropped from ~4.9 to ~2.3 `Gbit/sec`.
4352

4453
```output
4554
[ 5] local 10.248.213.97 port 43170 connected to 10.248.213.104 port 5201
@@ -67,25 +76,30 @@ rcv_tcp_congestion cubic
6776
iperf Done.
6877
```
6978

70-
### Simulating Packet Loss
79+
### Simulate packet loss
80+
81+
To test the resiliency of a distributed application you can add a simulated packet loss of 1%. As opposed to a 10ms delay, this will result in no acknowledgment being received for 1% of packets. Given TCP is a lossless protocol a retry must be sent.
7182

72-
To test the resiliency of a distributed application we can add a simulated packet loss of 1%. As opposed to a 10ms delay, this will result in no acknowledgment being received for 1% of packets. Given TCP is a lossless protocol a retry must be sent.
83+
Run these commands on the client system:
7384

7485
```bash
7586
sudo tc qdisc del dev ens5 root
7687
sudo tc qdisc add dev ens5 root netem loss 1%
7788
```
7889

79-
Rerunning the basic TCP test we observe an increased number of retries (`Retr`) and a corresponding drop in bitrate.
90+
Rerunning the basic TCP test you see an increased number of retries (`Retr`) and a corresponding drop in bitrate.
8091

8192
```bash
8293
iperf3 -c SERVER -V
8394
```
95+
96+
The output is now:
97+
8498
```output
8599
Test Complete. Summary Results:
86100
[ ID] Interval Transfer Bitrate Retr
87101
[ 5] 0.00-10.00 sec 4.41 GBytes 3.78 Gbits/sec 5030 sender
88102
[ 5] 0.00-10.00 sec 4.40 GBytes 3.78 Gbits/sec receiver
89103
```
90104

91-
Please see the `tc` [user documentation](https://man7.org/linux/man-pages/man8/tc.8.html) for the different ways to simulate different perturbation and your systems resiliency to such events.
105+
Refer to the `tc` [user documentation](https://man7.org/linux/man-pages/man8/tc.8.html) for the different ways to simulate perturbation and check resiliency.
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
---
2-
title: Tuning Kernel Parameters
2+
title: Tuning kernel parameters
33
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
### Connecting from Local Machine
9+
### Connect from a local machine
1010

11-
Now we can observe ways to mitigate performance degradation due to events such as packet loss. In this example, I will connect to the AWS server node from my local machine to demonstrate a longer response time. Please check the `iperf3` installation guide on the [official documentation](https://iperf.fr/iperf-download.php) if you're not using Ubuntu. As the output below shows we have a larger round trip time in excess of 40ms.
11+
You can look at ways to mitigate performance degradation due to events such as packet loss.
1212

13-
```output
14-
5 packets transmitted, 5 packets received, 0.0% packet loss
15-
round-trip min/avg/max/stddev = 44.896/46.967/49.279/1.444 ms
13+
In this example, you will connect to the server node a local machine to demonstrate a longer response time. Check the `iperf3` [installation guide](https://iperf.fr/iperf-download.php) to install `iperf3` on other operating systems.
14+
15+
Make sure to set the server security group to accept the TCP connection from your local computer IP address. You will also need to use the public IP for the cloud instance.
16+
17+
Running `iperf3` on the local machine and connecting to the cloud server shows a longer round trip time, in this example more than 40ms.
18+
19+
On your local computer run:
20+
21+
```bash
22+
iperf3 -c <server-public-IP> -V
1623
```
1724

18-
Running a standard TCP client connection with the `iperf3 -c SERVER -V` command shows an average bitrate of 157 Mbps.
25+
Running a standard TCP client connection with `iperf3` shows an average bitrate of 157 Mbps compared to over 2 Gbps when the client and server are both in AWS.
1926

2027
```output
2128
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test, tos 0
@@ -26,13 +33,11 @@ Test Complete. Summary Results:
2633
[ 8] 0.00-10.03 sec 187 MBytes 156 Mbits/sec receiver
2734
```
2835

29-
30-
3136
### Modify kernel parameters
3237

33-
On the server, we can configure linux kernel runtime parameters with the `sysctl` command.
38+
On the server, your can configure Linux kernel runtime parameters with the `sysctl` command.
3439

35-
There are a plenthora of dials to tune that relate to performance and security. The following command can be used to list all available dials. The corresponding [kernel documentation](https://docs.kernel.org/networking/ip-sysctl.html#ip-sysctl) can provide a more detailed description of each parameter.
40+
There are a plenthora of values to tune that relate to performance and security. The following command can be used to list all available options. The [Linux kernel documentation](https://docs.kernel.org/networking/ip-sysctl.html#ip-sysctl) provides a more detailed description of each parameter.
3641

3742
```bash
3843
sysctl -a | grep tcp
@@ -45,15 +50,28 @@ net.ipv4.tcp_available_congestion_control = reno cubic
4550
```
4651
{{% /notice %}}
4752

53+
You can increase the read and write max buffer sizes of the kernel on the server to enable more data to be held. This tradeoff results in increased memory utilization.
4854

49-
We can increase the read and write max buffer sizes of the kernel on the server to enable more data to be held. This is at the tradeoff of increased memory utilisation. run the following commands from the server.
55+
To try it, run the following commands on the server:
5056

5157
```bash
5258
sudo sysctl net.core.rmem_max=134217728 # default = 212992
5359
sudo sysctl net.core.wmem_max=134217728 # default = 212992
5460
```
5561

56-
Restart the `iperf3` server. Run the `iperf3 -c SERVER -V` command from the client leads to significantly improved bitrate with no modification on the client side.
62+
Restart the `iperf3` server.
63+
64+
```bash
65+
iperf3 -s
66+
```
67+
68+
Run `iperf3` again on the local machine.
69+
70+
```bash
71+
iperf3 -c <server-public-IP> -V
72+
```
73+
74+
You see a significantly improved bitrate with no modification on the client side.
5775

5876
```output
5977
Test Complete. Summary Results:
@@ -63,4 +81,4 @@ Test Complete. Summary Results:
6381
6482
```
6583

66-
This learning path serves as an introduction to microbenchmarking and performance tuning. Which parameters to adjust depends on your own use case and non-functional performance requirements of your system.
84+
You now have an introduction to networking microbenchmarking and performance tuning.

0 commit comments

Comments
 (0)