Thursday, 9 March 2017

Building an automated iPerf3 server with Ubuntu on Odroid C1+

The Odroid devices make great iPerf servers for portable use as they can be powered by 5V micro USB and have a Gigabit Ethernet adapter on its own bus so they don’t have the limitations the Raspberry Pi’s do. OK, let’s get started.

We are going to assume that you already have Ubuntu 16.04 up and running but if not, you can download official images here http://odroid.com/dokuwiki/doku.php?id=en:c1_release_linux_ubuntu. Extract the downloaded image and burn it to a SD Card using Win32 Disk Imager. I only used a 2GB card and it works fine. First boot might take a minute or two. After it’s booted, scan your network (Fing) to find your device IP. It should show up as a device by JF Light Industries with the MAC vendor as Wibrain.

Launch a SSH session (root:odroid for the Ubuntu 16.04 minimal image) and type:
sudo apt-get install iperf3

Once installed, you can run:
sudo iperf3 -s (CTRL + C to exit)

The -s switch starts iperf3 in server mode. However, I was interested in automating this a bit more. I wanted to be able to have iperf3 start up when the server did, with no interaction necessary. This allows for any of our engineers to use iperf3 without worrying if it has been started up. To do this, run the following commands:

sudo touch /etc/init.d/iperf3
sudo chmod +x /etc/init.d/iperf3

These two commands create a script called iperf3 and make it executable. Next, we’ll load the script in nano:
sudo nano /etc/init.d/iperf3

and add the following lines:

#!/bin/bash
/usr/bin/iperf3 -s &

then save the file. You can add any switch you would like. Run iperf3 –help to see a full list of switches. Finally, we need to tell Ubuntu when we want iperf3 to run during the boot sequence:
sudo update-rc.d iperf3 defaults

Ok, our server should be setup. To recap, we installed iperf3 from the default Ubuntu repos and automated its start up. The service should be running after a reboot. Type sudo reboot to reboot your Odroid and see if iPerf is running.

To test, run an instance of iPerf3 in client mode on your MAC, PC or phone with something like this
Upload
iperf3.exe -c <ip.of.your.Odroid> -w 640k -P 5 -t 60

Download
iperf3.exe -c <ip.of.your.Odroid> -w 640k -P 5 -t 60 -R

-w, --window n[KM]     Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. (this gets sent to the server and used on that side too)
-P, --parallel n     The number of simultaneous connections to make to the server. Default is 1.
-t, --time n     The time in seconds to transmit for. Default is 10 seconds.
-R, --reverse     Run in reverse mode (server sends, client receives).

From my Gigabit connected Lenovo X220 I get the following under test with the Odroid C1+ also connected to Ethernet.
image 


If you want to run iPerf2 instead, simply remove all the instances of the numeral ‘3’ from the code above.

Good luck.