Network emulation
The main tool for network emulation is netem. The tc commands needs to be executed with root permissions. You can find information about tc and netem using "man tc", "man htb", "man tbf". The "official" netem webpage/FAQ can be found here.
tc/netem is undergoing changes all the time, and sadly the documentation is not updated. This means that several of the examples in the "official" page does not work on recent kernels. This page has examples that may solve some of the cases where things do not work as expected. If it still doesn't work, you're down to experimenting or googling (or if you're very persistent: "use the source"). To set a 100ms delay on a network interface, use
tc qdisc add dev eth0 root netem delay 100ms
To set a 100ms delay on a network interface (50ms in each direction), limit the speed of the interface to 10 Mbps and limit the queue size to 30000 bytes (20 packets with ~1500 MTU), you may use
tc qdisc del dev eth0 root
tc qdisc add dev eth0 handle 1: root tbf rate 10mbit burst 15000 limit 15000
tc qdisc add dev eth0 parent 1:1 handle 10: netem limit 20 delay 50ms
tc qdisc del dev eth1 root
tc qdisc add dev eth1 handle 1: root tbf rate 10mbit burst 15000 limit 15000
tc qdisc add dev eth1 parent 1:1 handle 10: netem limit 20 delay 50ms
The queue size are specified in the netem "limit" parameter in this setup. The parameter gives the number of packets to be queued using the system's MTU.
Changing Linux tcp congestion control
To find out which TCP congestion control modules are available, check out the available kernel modules:
ls /lib/modules/`uname -r`/kernel/net/ipv4/ | grep tcp_
More information on Linux pluggable congestion control can be found here.
The kernel modules listed can be loaded using modprobe. "reno" and "cubic" are compiled into the kernel, and are already be available. After the congestion control modules you need have been loaded, you can switch between them using sysctl:
sudo sysctl net.ipv4.tcp_congestion_control=reno
Packet traces
tcpdump -i {interface to capture from} -w {dump filename} -s {how much to capture from each packet} {filters}
Capture headers from traffic to HTTP web servers: sudo tcpdump -i wlan0 -s 100 -w test.pcap 'tcp && port 80'
This page has a lot of examples of tcpdump filters ranging from very simple to advanced.
Network measurement tools
To generate the traffic you need, and maybe also do some analysis, there is a wide range of network measurement tools for all platforms. Given the assignment specification, you're free to choose whatever tool that helps you complete the assignment.
Examples of tools for measuting throughput and controlling the parameters of network traffic over a connection:
- iperf
- netperf
Or you can use wget, scp or any other tool to move data over the connection.
Analysis
After gathering the data you need, you want to analyse them. How you do this depends on the problem you have decided to explore, but there are several tools that can be of aid.
For simple analysis, and inspection of each packet/header, wireshark may give you some help. This is a graphical tool that gives you a lot of the same filtering features as tcpdump, simple analysis and some semantic analysis of packets based on protocol properties.
For a wide range of different analysis options for pcap traces the tcptrace tool can help parsing the data.
For a collection of general information on a pcap trace: tcptrace -l dump.pcap
Here is the example presented on friday 26.08 that outputs the RTT measurements: tcptrace -Z dump.pcap
Check out these commands for a lot of pluggable tools for tcptrace:
tcptrace -hxargs
tcptrace -hfilter
If you would like to manually create statistics (may be necessary if you explore a topic that is not mainstream), you may need to traverse the dump manually and extract the relevant data. This can be done using libpcap.
We have prepared a simple, barebone, non-robust program example (in C++) that you can extend upon to fit your needs if you are feeling adventurous.
Note that you need libpcap (libpcap-dev) to compile this barebone analysis tool.
Virtual machine setup
To use a virtual machine environment, we have prepared a setup. The image is for VirtualBox, and can be downloaded from here (1.1GB). Username for login is "ubuntu" and the password is "INF5072". The VM is set up with 3 network interfaces: eth0: Connected to the virtual adapter on the 10.10.10.x network (clientnet) eth1: Connected to the virtual adapter on the 10.10.20.x network (servernet) eth2: Connected to the host network via NAT.
To create a test setup using virtual machines, the image can be cloned to create sender and receiver instances as shown below:
Sender --- 10.10.10.x --- Network_emulator --- 10.10.20.x --- Receiver
The sender and receiver only needs one virtual network interface, connected to each of the separate networks (10.10.10.x and 10.10.20.x). The network emulater will route packets between the networks. To change the emulation parameters (bandwidth, queue sizes etc.), we have placed a script in the home folder of the ubuntu user (/home/ubuntu/config-netem).
Log in to comment
Not UiO or Feide account?
Create a WebID account to comment