How to Fix Bugs on a Permanent iPerf Server

iPerf Segmentation FaultRecently I discovered a bug in iPerf. iPerf is a very useful tool to test and measure bandwidth performance between an iPerf server and a client. In most cases, you run the bandwidth test only once between the two. The other option is to set up an iPerf server to run permanently on a host and then target that host to get iPerf measurements from several locations or hosts, which is more convenient because you don’t have to manage two hosts each time you want to run a test. But here is where the problems start…

This works as follows: On one machine, we run the command iperf -s -D This starts the iPerf server (option -s) and puts it in daemon mode (option -D), which means the server will keep running even if we logout of the machine. Then, we run iperf -c [IP of iperf server] from another machine.

The first time I tried this, it worked well initially, i.e., multiple iPerf tests could run by using the same iPerf server running as daemon. I noticed that after a day or two, the iPerf server wouldn’t respond and error messages (even a segmentation fault) appeared on the iPerf client side. By checking the processes on the iPerf server, it appeared that the process iperf -s -D was running on the host, but it wouldn’t accept any traffic. If I killed and restarted the iPerf server process, it would run for a day or two until it crashed again.

To overcome this problem, I wrote this script to restart the process:

Save this script in the file /home/panos/restart_iperf.sh and make it executable with chmod +x /home/panos/restart_iperf.sh Finally run the test every hour on the 25th minute by saving the following file in /etc/cron.d/restart_iperf_cron

When the iperf_restart.sh script runs, it first checks if the iPerf daemon is running. If not, it starts the daemon and exits. If it’s running, it kills the existing process and restarts a new one. In addition, it checks whether there is an established iPerf test connection, and makes sure that it doesn’t interrupt it.

This is a bug in iPerf version 2 that I’m sure others have come across and wondered why their tests were failing. I haven’t noticed the same problem with iPerf version 3. Although iPerf version 2 is older, it is much more widespread, and until everybody switches to version 3, this script might be helpful.

  • What version of iperf?
    Are you running iperf 2.x.x?
    Have you tried the latest version of iperf3?
    http://software.es.net/iperf/

    • Sorry, I replied before I read the last paragraph.
      Good job. Nice post.

      • Panagiotis Vouzis

        Thank you Alex