Combining psexec and iperf for CLI measuring LAN bandwidth

The site hosting iperf2 binaries for Windows is now gone. Current iperf3 version doesn’t officially support Windows or provide binaries.

script I had unexpected amount of trouble once when I was given task to measure bandwidth between server and lots of points in LAN. Googling showed that a lot of people care a great deal about their Internet bandwidth (I do understand them :) )  but very few care about exact numbers for their LAN bandwidth.

In the end I used Passmark PerformanceTest that worked excellent, but it was taking a lot of time to set up for every point. I had to call remote user, kick him off PC, connect to his desktop, copy PerformanceTest there, launch it in listening mode and only then start test from server side.

So when I had read about two utilities (NetCPS and iperf) for exactly that purpose while being command-line in design on gHacks it sparked my interest again.


I couldn’t get NetCPS (site was down) so iperf it is.

Main problem is that any bandwidth testing program must be run on both ends, so for desired goal (easy and fast setup) this must be executed without disturbing remote user’s desktop session. iperf is capable of running as system service, but distributing it to all PCs and keeping in autorun weren’t needed.

So psexec it is. psexec is very good command line utility from Sysinternals that allows to execute remote commands on network computers (if you have security rights to do so).

Additionally I need to cleanup remote side so pskill is needed as well. pskill is even better utility from same source that allows to kill remote proccesses. :) Effect of carpet bombing whole LAN with name of latest popular game is way too much fun! Oops, got sidetracked… :)

Basic setup is following (I called my folder iperf):

D:\iperf\iperf.exe
D:\iperf\psexec.exe
D:\iperf\pskill.exe

This folder must be shared, let’s assume that it has following network path:

\\cutepc\iperf\

After bit of tinkering I ended up with following script

@echo off
psexec \\%1 -s -d "\\cutepc\iperf\iperf.exe" -s
cls
iperf -c %1
echo.
pause
pskill \\%1 iperf.exe

which I saved as text file

D:\iperf\bandwidth.cmd

So command for actual test is going to be (assuming we are testing bandwidth to computer named “targetpc”)

D:\iperf\bandwidth targetpc

Line by line analysis:

  1. disables echo (output of commands to screen)
  2. launches iperf in listening mode on remote PC. “%1” is parameter that gets replaced with “targetpc” in my example. Note that there are two “-s”, it’s not mistake – one is parameter for psexec (runs process as SYSTEM), other is for iperf (start as server)
  3. clears screen
  4. launches local copy of iperf and starts test
  5. outputs empty line
  6. pauses after results
  7. kills remote iperf

Result looks like this:

------------------------------------------------------------
Client connecting to targetpc, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[1908] local 10.73.186.97 port 1461 connected with 10.73.186.140 port 5001
[ ID] Interval       Transfer     Bandwidth
[1908]  0.0-10.4 sec   568 KBytes   448 Kbits/sec

By default test runs for 10 seconds, for further tweaking (you might need to correct psexec parameters as well if LAN security setup is different from mine) read:

iperf --help

and

psexec /?

PS No! My computer is not called “cutepc”! Honestly! :)

psexec home&download page http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
pskill home&download page http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx

Sysinternal Suite (which contains psexec, pskill and plenty of other utilities) home&download page http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx

iperf home page software.es.net/iperf

via gHacks

Related Posts

4 Comments

  • […] Iperf was one of the earliest apps covered at this blog (second only to Opera) and I still happily use it. Strangely, until recently I had completely missed JPerf utility that equips Iperf with graphical interface to escape horrors of command line setup. […]

  • Nice script, just a few things: you misspelled bandwidth in your script name and the psexec command is missing -c to copy the iperf exe to the target PC. It should read like this:

    @echo off
    psexec \\%1 -s -d -c “C:\Windows\System32\iperf.exe” -s
    cls
    iperf -c %1
    echo.
    pause
    pskill \\%1 iperf.exe

  • @Sean

    Typo fixed. :)

    As for copy to remote, my version was setup to simply run executable from shared folder (accessible to remote machine). Copying is needed if you are sending up local file, like in your example.

Comments are closed.