Lab 4 Emulating WAN With NETEM II Packet Loss Duplication Reordering and Corruption
Lab 4 Emulating WAN With NETEM II Packet Loss Duplication Reordering and Corruption
Award 1829698
“CyberTraining CIP: Cyberinfrastructure Expertise on High-throughput
Networks for Big Science Data Transfers”
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Contents
Overview ............................................................................................................................. 3
Objectives............................................................................................................................ 3
Lab settings ......................................................................................................................... 3
Lab roadmap ....................................................................................................................... 3
1 Introduction to network emulators and NETEM ........................................................ 3
2 Lab topology................................................................................................................ 5
2.1 Testing connectivity between two hosts ............................................................. 6
3 Adding/changing packet loss ...................................................................................... 7
3.1 Identify interface of host h1 and host h2............................................................. 8
3.2 Add packet loss to the interface connecting to the WAN ................................... 9
3.3 Restore default values........................................................................................ 12
3.4 Add correlation value for packet loss to interface connecting to WAN ............ 13
4 Adding packet corruption ......................................................................................... 14
4.1 Add packet corruption to an interface connected to the WAN ......................... 14
5 Add packet reordering .............................................................................................. 16
6 Add packet duplication ............................................................................................. 17
References ........................................................................................................................ 18
Page 2
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Overview
This lab continues the description of NETEM and how to use it to emulate Wide Area
Networks (WANs). Besides delay, this lab focuses on other parameters such as packet loss,
packet duplication, reordering, and packet corruption. These parameters affect the
performance of protocols and networks.
Objectives
Lab settings
The information in Table 1 provides the credentials of the machine containing Mininet.
Lab roadmap
Part I of Emulating WAN with NETEM described how to use NETEM to emulate WANs
characterized by long delays. Part I also explained how the end-to-end delay can be
Page 3
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
dominated by the WAN’s propagation delay and how the Round-Trip Time (RTT)
estimates this delay.
In addition to delay, many WANs and LANs are subject to packet loss, reordering,
corruption, and duplication.
WAN
h1 h2
1. Packet loss: a condition that occurs when a packet travelling across a network fails
to reach its destination. Packet loss may have a large impact on high-throughput
high-latency networks. A common cause of packet loss is the inability of routers
to hold packets arriving at a rate higher than the departure rate. Even in cases
where the high packet arrival rate is only temporary (e.g., short-term traffic
bursts), the router is limited by the amount of buffer memory used to momentarily
store packets. When packet loss occurs, TCP reduces the congestion window and
consequently the throughput by half. Packet loss must be mitigated by using best-
practice network designs, such as Science DMZ.
2. Packet reordering: a condition that occurs when packets are received in a different
order from which they were sent. Packet reordering, also known as out-of-order
packet delivery, is typically the result of packets following different routes to reach
their destination. Packet reordering may deteriorate the throughput of TCP
connections in high-throughput high-latency networks. For each segment
received out of order, a TCP receiver sends an acknowledgement (ACK) for the last
correctly received segment. Once the TCP sender receives three
acknowledgements for the same segment (triple duplicate ACK), the sender
considers that the receiver did not correctly receive the packet following the
packet that is being acknowledged three times. It then proceeds to reduce the
congestion window and throughput by half.
Page 4
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Packet loss, reordering, and corruption (the last two are interpreted as packet loss also
by the TCP sender) lead to a drastic reduction of throughput. In this lab, we will use the
NETEM tool to emulate these situations affecting end-to-end performance.
2 Lab topology
Let’s get started with creating a simple Mininet topology using MiniEdit. The topology
uses 10.0.0.0/8 which is the default network assigned by Mininet.
Step 2. On MiniEdit’s menu bar, click on File then Open to load the lab’s topology. Locate
the Lab 4.mn topology file and click on Open.
Page 5
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Step 3. Before starting the measurements between host h1 and host h2, the network
must be started. Click on the Run button located at the bottom left of MiniEdit’s window
to start the emulation.
The above topology uses 10.0.0.0/8 which is the default network assigned by Mininet.
Step 1. Hold the right-click on host h1 and select Terminal. This opens the terminal of
host h1 and allows the execution of commands on host h1.
Page 6
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Step 2. Test connectivity between the end-hosts using the ping command. On host h1,
type the command ping 10.0.0.2 . This command tests the connectivity between host
h1 and host h2. To stop the test, press Ctrl+c . The figure below shows a successful
connectivity test.
The figure above indicates that there is connectivity between host h1 and host h2. Thus,
we are ready to start the throughput measurement process.
The user invokes NETEM using the command line utility called tc 4, 5. With no additional
parameters, NETEM behaves as a basic FIFO queue with no delay, loss, duplication, or
reordering of packets. The basic tc syntax used with NETEM is as follows:
• sudo : enable the execution of the command with higher security privileges.
• tc : command used to interact with NETEM.
• qdisc : a queue discipline (qdisc) is a set of rules that determine the order in which
packets arriving from the IP protocol output are served. The queue discipline is
applied to a packet queue to decide when to send each packet.
Page 7
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
• [add | del | replace | change | show] : this is the operation on qdisc. For
example, to add delay on a specific interface, the operation will be add . To change
or remove delay on the specific interface, the operation will be change or del .
• dev_id : this parameter indicates the interface to be subject to emulation.
• opts :this parameter indicates the amount of delay, packet loss, duplication,
corruption, and others.
Step 1. On host h1, type the command ifconfig to display information related to its
network interfaces and their assigned IP addresses.
The output of the ifconfig command indicates that host h1 has two interfaces: h1-eth0
and lo. The interface h1-eth0 at host h2 is configured with IP address 10.0.0.1 and subnet
mask 255.0.0.0. This interface must be used in tc when emulating the WAN.
Page 8
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
The output of the ifconfig command indicates that host h2 has two interfaces: h2-eth0
and lo. The interface h2-eth0 at host h1 is configured with IP address 10.0.0.2 and subnet
mask 255.0.0.0. This interface must be used in tc when emulating the WAN.
In a network, packets may be lost during transmission due to factors such as bit errors
and network congestion. The rate of packets that are lost is often measured as a
percentage of lost packets with respect to the number of sent packets. In this section, you
will use netem command to insert packet loss on a network interface.
Figure 10. Adding 10% packet loss to host h1’s interface h1-eth0.
The above command adds a 10% packet loss to host h1’s interface h1-eth0.
Step 2. The user can verify now that the connection from host h1 to host h2 has packet
losses by using the ping command from host h1’s terminal. The -c option specifies the
total number of packets to send.
Page 9
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
In the figure 11, host h1 sends 200 ping packets to host h2. Note the icmp_seq values
demonstrated in the figure above.
You can see that icmp_seq=2, 6, 10 and 17 are missing due to packet losses. Resulting
packet loss will likely vary in each emulation.
Figure 12 shows the summary report of the previous command. By default, ping reports
the percentage of packet loss after finishing the transmission. In our test, ping reported a
packet loss rate of 10%. The measured packet loss rate will tend to become closer to the
configured loss rate as more trials are performed.
Note that the above scenario emulates 10% packet loss on the unidirectional link from
host h1 to host h2. If we want to emulate packet loss on both directions, a packet loss of
10% must also be added to host h2.
Page 10
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Figure 13. Adding 10% packet loss to host h2’s interface h2-eth0.
Step 4. The user can verify now that the connection between host h1 and host h2 has
more packets losses (10% from host h1 + 10% from host h2) by retyping the ping
command on host h1’s terminal:
In the figure 14, host h1 sends 200 ping packets to host h2. Note the icmp_seq values
demonstrated in the figure above.
You can see that icmp_seq=3, 6, 10, 14, 23 and 27 are missing due to packet losses.
Resulting packet loss will likely vary in each emulation.
Figure 14 shows the summary report of the previous command. By default, ping reports
the percentage of packet loss after finishing the transmission. In our test, ping reported a
packet loss rate of 10%. The measured packet loss rate will tend to become closer to the
configured loss rate as more trials are performed.
Page 11
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
The result above indicates that 159 out of 200 packets were received successfully (20.5%
packet loss).
To remove the packet loss added in Section 3.2 and restore the default configuration, you
must delete the rules of the interfaces on host h1 and host h2.
Step 2. Apply the same steps to remove rules on host h2. In host h2’s terminal, type the
following command:
As a result, the tc queueing discipline will restore its default values of the device h2-eth0.
Step 3. Now, the user can verify that the connection from host h1 to host h2 has no
explicit packet loss configured by using the ping command from host h1’s terminal, press
Ctrl+c to stop the test:
ping 10.0.0.2
Page 12
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Figure 18. Verifying latency after deleting all rules on both devices.
The result above indicates that all five packets were received successfully (0% packet loss)
and that the minimum, average, maximum, and standard deviation of the Round-Trip
Time (RTT) were 0.043, 0.112, 0.357, and 0.122 milliseconds respectively.
3.4 Add correlation value for packet loss to interface connecting to WAN
An optional correlation may be added. Adding correlation causes the random number
generator to be less random and can be used to emulate packet burst losses 1.
sudo tc qdisc add dev h1-eth0 root netem loss 50% 50%
Figure 19. Verifying latency after deleting all rules on both devices.
The above command introduces a packet loss rate of 50%, and each successive probability
depends 50% on the last one1. Note that a packet loss rate this high is unlikely.
Step 2. The user can verify now that the connection from host h1 to host h2 has packet
losses by using the ping command from host h1’s terminal.
ping 10.0.0.2 -c 50
Page 13
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
The result above shows an example where successive packets were dropped: [3, 4, 6, 10,],
[13, 14, 16, 17, 20, 21], etc.
Step 3. In host h1’s terminal, type the following command to delete previous
configurations:
The new value added here represents packet corruption percentage (0.01%).
Page 14
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Step 2. The user can now verify the previous configuration by using the iperf3 tool to
check the retransmissions. To launch iPerf3 in server mode, run the command iperf3 -
s in host h2’s terminal.
iperf3 -s
Step 3. To launch iPerf3 in client mode, run the command iperf3 -c 10.0.0.2 in host
h1’s terminal.
iperf3 -c 10.0.0.2
The figure above shows the retransmission values on each time interval (1 second). The
total number of retransmitted packets, due to packet corruption, is 3710. This verifies
that packet corruption was indeed, applied to the interface on host h1.
Step 4. In host h1’s terminal, type the following command to delete previous
configurations:
Page 15
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
Step 5. In order to stop the server, press Ctrl+c in host h2’s terminal. The user can see
the throughput results in the server side too. The summarized data on the server is similar
to that of the client side’s and must be interpreted in the same way.
Packets are sometimes not delivered in the same order they were sent. In order to
emulate reordering in NETEM, the reorder option is used. Proceed with the steps below.
sudo tc qdisc add dev h1-eth0 root netem delay 10ms reorder 25% 50%
In this command, 25% of the packets (with a correlation value of 50%) will be sent
immediately, while the remainder 75% will be delayed by 10ms.
Step 2. The user can verify the effect of packet reorder by using the ping command on
host h1’s terminal, press Ctrl+c to stop the test:
ping 10.0.0.2
Consider the first four packets of the figure above. The first and second packets did not
experience delay (one out of four, or 25%), while the next three packets experienced a
delay of ~10 milliseconds (three out of four, or 75%). The measured reordering rate will
tend to become closer to the configured reordering rate as more trials are performed.
Page 16
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
It is possible that your first packet will experience delay, but this effect will eventually
occur in future tests.
Step 3. In host h1’s terminal, type the following command to delete previous
configurations:
The above command will produce a duplication of 50% (i.e., 50% of the packets will be
received twice at the destination).
Step 2. The user can verify the effect of packet duplication by using the ping command
on host h1’s terminal, press Ctrl+c to stop the test:
ping 10.0.0.2
Page 17
Lab 4: Emulating WAN with NETEM II: Packet Loss, Duplication, Reordering, and Corruption
The result above indicates that five duplicate packets were received. Duplicate packets
are also marked with (DUP!). The measured rate of duplicate packets will tend to become
closer to the configured rate as more trials are performed.
Step 3. In host h1’s terminal, type the following command to delete previous
configurations:
This concludes Lab 4. Stop the emulation and then exit out of MiniEdit.
References
Page 18