Tutorials

Low-Cost Internet Connection Testing Box with Raspberry Pi

I have been thinking about writing tutorial-type posts for a while now, and this will be my first crack at it. Feedback would be much appreciated.

This tutorial will discuss how you can create a simple, cost-effective setup that will allow you to test your Internet connection. You will be able to test different kinds of connection types, a wired (Ethernet) connection or a 3G connection (via USB dongle). I would not recommend testing a connection through a WiFi router as it may prove to generate incorrect results.

The device used in this tutorial is a Raspberry Pi computer; it is a compact (credit card size) computer that runs a Linux-based OS. The Pi has many connections such as USB ports, HDMI, Ethernet, and others which make it appealing since it is portable; you can use it as a mobile connection testing box. However, if you are not able to get your hands on one your personal computer will do.

8498072730_fb01d51b1b_o
Raspberry Pi in a Case – image courtesy of Russ Sanderlin’s Flickr account

The software used to test the Internet connections is a lightweight open source program called the Net Neutrality Bot or Neubot for short. The program runs in the background and periodically performs transmission tests with test servers, it is hosted by the distributed Measurements Lab (M-Lab) platform. Transmission tests probe the Internet using various application level protocols and test results are saved both locally and on the test servers. The results dataset contains samples from various tests and is published on the web, allowing anyone to analyze the data for research purposes.

What you will need:

  1. An Internet connection
  2. Raspberry Pi, with adequate power and input-output devices

Some assumptions and remarks:

  1. This tutorial assumes you have your Raspberry Pi setup with an operating system. If you have not done this there are many resources for it online, I would recommend this from the Raspberry Pi website.
  2. The tutorial assumes that you have a working knowledge of UNIX shell (Bash) including installing packages, unpacking archives, moving/copying files, compiling, and executing commands. The web is full of tutorials on how to using the command line in Linux, this is one.
  3. Neubot is software that runs in the background while you work on the machine. It will gather data about your Internet connection and upload it along with your IP address to the Measurements Lab.

Run Neubot on the Raspberry Pi (Linux-based OS)

The steps here were executed on a Raspberry Pi running the Raspbian OS, but they can be executed on any Debian OS. To run Neubot on the Raspberry Pi, I recommend compiling it from source. This means that you can download the source code for Neubot and then compile it to create a running application on the Pi.

You can download the source files from here. To compile the source file follow the steps below.

First make sure that Python >= 2.5 by running the following command in terminal
$ python -V
This command should output something like: Python 2.6.5. If Python is not installed you should manage to install it using the proper tools of your Unix distribution (apt-get).

1. Unpack the sources archive:
$ tar -xzf neubot-0.4.tar.gz

2. Enter the sources directory:
$ cd neubot-0.4

3. Become root:
$ su or sudo -s
The right command to become root depends on the policy of your Unix distribution. The traditional command to become root has always been su. But Ubuntu, and MacOsX (and possibly others) require you to use sudo.

4. Install neubot:
$ make install

5. Add neubot group:
$ groupadd -r _neubot

6. Add neubot user:
$ useradd -r -d/ -g_neubot -s/usr/sbin/nologin _neubot

7. Start neubot daemon:
$ /usr/local/bin/neubot start
Neubot will become a daemon, will drop root privileges, and will run on behalf of the _neubot user and group, periodically performing transmission tests. You will have to do this every time you power up the Pi, to avoid this make the daemon automatically start as in step 8. 

8. Automatically start neubot daemon at startup.  For this you need to check were python is located on your Pi, mine was at /usr/local/bin/python, so I added the following line to /etc/rc.local:
/usr/local/bin/python /usr/local/bin/neubot start
You will have to correctly point to were python is located on your device by changing the /usr/local/bin/python to what it is on yours. 

Now that you have installed Neubot and configured it to start automatically on startup your Internet connection testing box using the Pi is ready. You can check out the user web interface from a web browser by typing the following into the address bar
http://127.0.0.1:9774/
This will load the Neubot web interface. In the “Privacy” tab you can enable the bot to start testing and uploading data to the M-Lab.

So there you have it. You now have a portable Internet connection testing box, just plug it into a network and start testing. You can then analyze the data recorded onto the Pi. Also remember that you will be contributing to the online database on the M-Lab that can help consumers, researchers, and policy makers understand the Internet and make decisions. I will leave you with a video on how M-Lab is working on bettering the Internet.

Leave a Reply

Your email address will not be published. Required fields are marked *