This is an old revision of the document!
Master Communications - Protocols and Networks
Details for traffic shaping are in .
Details regarding tcp testing are here: .
Setup Ubuntu installation for Network analysis
The network throughput analysis is done with a collection of tools.
- iperf Performance Measurement
- Wireshark Packet Tracing
- Network emulation
- tcp_probe Kernel module (see )
- tftp tiny file transfer protocol
- ethtool for network card settings
These tools are installed on top of installation form Ubuntu
sudo apt-get install git iperf wireshark gnuplot tftp ethtool
Live CD Creation
For the lab I have bootable usb sticks which contain the Ubuntu live system plus a persistent storage which already contains the additional installed packages and the home directory files.
Here is the guide for creating a usb live boot stick:
The steps to produce such a bootable usb stick are
- Create a FAT partition of approx. 4 GB size with the Ubuntu disk utility on the usb stick
- Start the graphical “Startup Disk Creator”, select the iso image and choose “Documents and Settings will be stored in reserved extra space” with size of approx. 1GB. Select the USB Device you have in the usb slot.
- Create the USB Stick with “Make Startup Disk”
- Eject the stick and inject it again. This will mount the stick and you can look at the file contents.
- You need to change the file /boot/grub/grub.cfg due to a bug. Add the word “persistent” to the linux parameter of “Try Ubuntu”. See below for the corrected part of grub.cfg.
- Now boot your computer with the stick. You should boot from a computer which is connected via ethernet such that you have internet connection.
- Install the packages you need and add the files you want to the home directory. I added the socket programming source files. These changes are persistently stored now.
Her is the corrected extract from the grub.cfg file:
... menuentry "Try Ubuntu without installing" { set gfxpayload=keep linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper persistent quiet splash -- initrd /casper/initrd.lz } ...
Copy the USB stick
In order to avoid problems with the USB stick copy step, the size of the initial FAT32 partition should be smaller than the maximum size of the USB stick. I selected 4 GB for the FAT 32 which includes the 1GB persistent caspar-rw file. The stick size is 16GB. I had success with copying the first 4 GB (in fact 5GB) from the stick to a file with
sudo dd if=/dev/sdb of=mscom.iso bs=1M count=5000
That produces an mscom.iso file with size 5,2 GB which is well above the 4 GB. Maybe count could have been smaller… Now you can copy that to a new USB stick with
sudo dd if=mscom.iso of=/dev/sdb bs=1M
IF YOUR USB STICK IS AT /dev/sdb AND NOT YOUR HARDDISK….
TCP Throughput test with iperf
Setup a server on one computer
iperf -s
Run a client on a second computer. The client will send data to the server.
iperf -c SERVERIP -i 1
Option -i will show intermediate bandwidth results every second.
Add netem network emulation traffic shaping to an ethernet device
In the following example an additional 100 ms delay to the outgoing traffic is added.
sudo tc qdisc add dev eth0 root netem delay 100ms
Show the current traffic shaper
tc qdisc show
Remove a traffic shaper
sudo tc qdisc del dev eth0 root
For limiting the bandwidth a token bucket shaper can be used. In the example below the packet is delayed by 100 ms with the netem shaper and the goes to the token bucket shaper. See .
sudo tc qdisc add dev eth0 root handle 1: netem delay 100ms sudo tc qdisc add dev eth0 parent 1:1 handle 10: tbf rate 256kbit buffer 1600 limit 300 tc -s qdisc
Analyzing and setting ethernet card parameters
Ethernet card parameters can be configured with ethtool.
fritz@ubuntu:~$ ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off Cannot get wake-on-lan settings: Operation not permitted Current message level: 0x00000007 (7) drv probe link Link detected: yes fritz@ubuntu:~$
ethtool DEVICENAME will show you the current settings of the ethernet card. In the example above the link speed is for example 1GBit/s. In order to modify the speed settings and set it to 100 MBit/s full duplex mode do:
sudo ethtool -s eth0 speed 100 duplex full
Modern network cards can do TCP segmentation in hardware. This is called TCP segmentation offloading (TSO), which offloads the packet segmentation from the cpu. To show the offload parameters do:
fritz@ubuntu:~$ ethtool -k eth0 Offload parameters for eth0: rx-checksumming: off tx-checksumming: on scatter-gather: on tcp-segmentation-offload: on udp-fragmentation-offload: off generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off receive-hashing: off fritz@ubuntu:~$
In the example above the tcp segmentation offloading is activated. This will result in wireshark showing longer TCP packets than allowed according to Maximum Transmit Unit size (MTU) which is typically 1500 Bytes. You can check the MTU value with “ifconfig”.
In order to switch TSO offloading off, you can do
sudo ethtool -K eth0 tso off