Iperf: Running as Windows Service

Created on 13 Sep 2016  ·  5Comments  ·  Source: esnet/iperf

I am attempting to get iperf3 to run as a windows service. I see notes in documentation about the -D command and the -R command for installing the service and for removing it.

I am able to run -D and it runs in the background of Windows but not as a Windows service under services.msc.

I have tested in Windows 2008R2, Windows 2012R2, and Windows 10.

Is it possible to run as a Windows Service? If so, what command should I run?

Here is what I am running: iperf3.exe -s -D

I tried with the latest build of iperf 2. Same behavior.

question

Most helpful comment

Install iperf3 as Windows service

  1. Requirements
  2. Installation
  3. Issues
  4. Related documents

Requirements

  1. Windows 2003 and above.
  2. Appropriate iperf3 version.
  3. srvany.exe from Windows Server 2003 Resource Kit Tools.

Installation

  1. Create a directory for iperf3: C:\iperf3.
  2. Download Windows Server 2003 Resource Kit Tools.
  3. Extract srvany.exe from downloaded pack and place it into iperf3 directory.
  4. Download appropriate iperf3 version.
  5. Unpack iperf3 files into iperf3 directory.
  6. Create a batch file:
    Install iperf3 as Windows service.cmd
::
:: Install iperf3 as Windows service
::
SET iperfdir=C:\iperf3
SET iperfprog=iperf3.exe
SET iperflog=iperf3-server-logs.txt
SET servicename=iperf3
SET start=auto
SET binpath=%iperfdir%\srvany.exe
SET iperfoptions=--server --daemon --port 5201 --version4 --format [m] --verbose --logfile %iperfdir%\%iperflog%
SET displayname=iPerf3 Service
SET description=iPerf3 Service provide a possibility to test network speed
::
::
sc.exe create %servicename% displayname= "%displayname%" start= %start% binpath= "%binpath%"
sc description %servicename% "%description%"
::
reg add HKLM\SYSTEM\CurrentControlSet\services\%servicename%\Parameters /v AppParameters /t REG_SZ /d "%iperfoptions%"
reg add HKLM\SYSTEM\CurrentControlSet\services\%servicename%\Parameters /v Application /t REG_SZ /d "%iperfdir%\%iperfprog%" /f
::
pause
::
  1. Run created Install iperf3 as Windows service.cmd file as administrator.
  2. Now you can start and stop iperf3 service:
net start iperf3
net stop iperf3

Issues

We noticed that some times, iperf3 in service mode, stop working and only service restart helps. As a simple workaround we created a simple batch file and scheduled it to run each day:
Restart-iperf3-service.cmd

::
:: Stop iperf3 service
net stop iperf3
::
:: Start iperf3 service
net start iperf3
::

Related documents

  1. iPerf 3 user documentation.
  2. How to Create a User-Defined Service.

All 5 comments

iperf3 is really designed for, and only supported on, UNIX-like operating systems.

Some people have made Windows variants, you should try contacting one of them, or perhaps someone will see this issue comment.

@bmah888 can you remove the reference to running iperf as a Windows service in the user docs? It's confusing since it's unsupported and doesn't work anymore. https://iperf.fr/iperf-doc.php#service

Hrm, thanks for the suggestion. I don't control the content on iperf.fr (and that section seems to apply to iperf2, whereas I maintain iperf3), but let me see if I can get your message to the right people.

Install iperf3 as Windows service

  1. Requirements
  2. Installation
  3. Issues
  4. Related documents

Requirements

  1. Windows 2003 and above.
  2. Appropriate iperf3 version.
  3. srvany.exe from Windows Server 2003 Resource Kit Tools.

Installation

  1. Create a directory for iperf3: C:\iperf3.
  2. Download Windows Server 2003 Resource Kit Tools.
  3. Extract srvany.exe from downloaded pack and place it into iperf3 directory.
  4. Download appropriate iperf3 version.
  5. Unpack iperf3 files into iperf3 directory.
  6. Create a batch file:
    Install iperf3 as Windows service.cmd
::
:: Install iperf3 as Windows service
::
SET iperfdir=C:\iperf3
SET iperfprog=iperf3.exe
SET iperflog=iperf3-server-logs.txt
SET servicename=iperf3
SET start=auto
SET binpath=%iperfdir%\srvany.exe
SET iperfoptions=--server --daemon --port 5201 --version4 --format [m] --verbose --logfile %iperfdir%\%iperflog%
SET displayname=iPerf3 Service
SET description=iPerf3 Service provide a possibility to test network speed
::
::
sc.exe create %servicename% displayname= "%displayname%" start= %start% binpath= "%binpath%"
sc description %servicename% "%description%"
::
reg add HKLM\SYSTEM\CurrentControlSet\services\%servicename%\Parameters /v AppParameters /t REG_SZ /d "%iperfoptions%"
reg add HKLM\SYSTEM\CurrentControlSet\services\%servicename%\Parameters /v Application /t REG_SZ /d "%iperfdir%\%iperfprog%" /f
::
pause
::
  1. Run created Install iperf3 as Windows service.cmd file as administrator.
  2. Now you can start and stop iperf3 service:
net start iperf3
net stop iperf3

Issues

We noticed that some times, iperf3 in service mode, stop working and only service restart helps. As a simple workaround we created a simple batch file and scheduled it to run each day:
Restart-iperf3-service.cmd

::
:: Stop iperf3 service
net stop iperf3
::
:: Start iperf3 service
net start iperf3
::

Related documents

  1. iPerf 3 user documentation.
  2. How to Create a User-Defined Service.

nssm is a much better option than srvany from the resource kit.

Was this page helpful?
0 / 5 - 0 ratings