BonFIRE logo and link to main BonFIRE site

Table Of Contents

Previous topic

Managing BoD services via Experiment Descriptor

Next topic

BonFIRE Internal DNS

This Page

Network Impairment

0. Introduction

The purpose of this document is to show some easy ways how various network impairment mechanisms can be implemented by experimenters on the BonFIRE infrastructure.

The information given here is not specifc to BonFIRE. The examples shown in this document rely on standard Linux tools, most are using the tc tool, which is part of the iproute2 package and thus available for all major Linux distributions.

tc in turn controls the network emulation functionality of the Linux Kernel which is provided by the netem module. Many of the examples in this document were taken from its homepage.

Much of the information in this document is based on the formidable Linux Advanded Routing & Traffic Control HOWTO, which is highly recommended for further reading on this subject.

1. Requirements

The one requirement for following the examples shown here is obviously the previously mentioned iproute2 package. On BonFIRE VMs, this package can be installed by issuing the following command:

# apt-get install iproute

2. Examples

The examples below show how some simple network impairment scenarios can be realized by using the tc command in combination with the netem module. All of the example work by installing a queueing discipline (qdisc) on a network interface. qdiscs are the basic building blocks used to perform traffic control in Linux. Whenever the kernel needs to send a packet to an interface, it is enqueued to the qdisc configured for that interface. Immediately afterwards, the kernel tries to get as many packets as possible from the qdisc, for giving them to the network adaptor driver.

More specifically, we are using classless qdiscs in these examples, which can only be installed to the root of a network interface. The general syntax for adding a qdisc to the root of a network interface is this:

# tc qdisc add dev <interface> root <qdisc specification>

Note that these example assume that no queueing discipline has been installed previously. If that is not the case, an already installed qdisc can be changed with a slighlty altered syntax:

# tc qdisc change dev <interface> root <qdisc specification>

2.1 Static Delay

This example simply adds a fixed amount of delay to all packets going out of eth0.

# tc qdisc add dev eth0 root netem delay 100ms

2.2 Variable Delay

It is possible to add some random variation to the network delay (up to ±10ms in this case):

# tc qdisc add dev eth0 root netem delay 100ms 10ms

Network delay variation in real world scenarios isn’t purely random. To emulate that, a correlation value may be given as well:

# tc qdisc add dev eth0 root netem delay 100ms 10ms 25%

This causes the added delay to be 100ms ± 10ms with the next random element depending 25% on the last one. This isn’t true statistical correlation, but an approximation.

2.3 Packet Loss

tc allows us to easily create some random packet loss on a network interface by using the loss keyword. The amount of packet loss is specified in percent:

# tc qdisc add dev eth0 root netem loss 0.1%

An optional correlation may also be added. This causes the random number generator to be less random and can be used to emulate packet burst losses.

# tc qdisc change dev eth0 root netem loss 0.3% 25%