Share via


iperf like network test using Powershell or other 'native' windows functions

Question

Friday, July 10, 2015 9:47 AM

Hi,

I would really like to test a network connection between 2 servers in a 'raw TCP throughput style' i.e. no other bottlenecks like file I/O being part of the measurement.

The internets recommend IPERF strongly and this looks ideal, unfortunately the environment I need to test is very strict on ANY 'foreign' software being installed, even sysadmin style tools.

I imagined Powershell or by extension .NET would be ideal for this, setting up a 'listener' on one machine, then a 'client' on another and trying to max out the link.

Is this possible in a simple fashion, or am I completely mad thinking this can be done with local tools only?

Thanks!

All replies (3)

Friday, July 10, 2015 9:57 AM âś…Answered

Hi,

actually, this should well be doable. It would require you to read up on the mechanics used for something like this, however the individual components would be simple, not complex. Even better, with powershell it's very easy to remote deploy the other endpoint, meaning it would also be user-friendly.

Cheers,
Fred

There's no place like 127.0.0.1


Thursday, July 16, 2015 1:01 PM

Hi Sir,

Is there any update ?

Best Regards,

Elton JI

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .


Tuesday, July 16, 2019 3:56 PM

Made this script the other day, just put iperf in the source folder and update the script. The script will start the server on the remote endpoint. Verified on win 8.1/server 2012 and up.

#IPerf3 Remote

#Variables
$repeat = "StartOver"
$iperf_folder = "C:\XXXX\iperf"
$iperf_exe = "C:\XXXX\iperf3.exe"

#Fucntions 
 
    function copyto-client {
    #Copy to Target computer
    Copy-Item -Path $iperf_folder -Recurse -Destination \$target_computer\c$\windows\iperf -ErrorAction SilentlyContinue}

    function start-remote-iperf {
    #Start Remote iPerf Server
    sleep 2
    Invoke-Command -ComputerName $target_computer -ScriptBlock {cmd.exe /c c:\windows\iperf\iperf3.exe -s} -AsJob}

    function create-fwrule {
    #Create iPerf Firewall rule
    Invoke-Command -ComputerName $target_computer -ScriptBlock {New-NetFirewallRule -Name "Temp iPerf Rule" -Enabled True -Direction Inbound -LocalPort 5201 -DisplayName "Temp iPerf Policy" -Protocol TCP} -AsJob}

    function invoke-test {
    #Invoke test
    Invoke-Command {cmd /c $iperf_exe -c $target_computer}}

    function stop-iperfserver {
    #Stop Remote iPerf Server
    Invoke-Command -ComputerName $target_computer -ScriptBlock {Get-Process *iperf* | Stop-Process}}

    function cleanup-iperfrun {
    #Remove iPerf Files
    Invoke-Command -ComputerName $target_computer -ScriptBlock {Remove-Item c:\windows\iperf -Recurse -ErrorAction SilentlyContinue -Force}
    
    #Remove iPerf Firewall Rule
    Invoke-Command -ComputerName $target_computer -ScriptBlock {Get-NetFirewallRule -Name "Temp iPerf Rule" | Remove-NetFirewallRule}}

#Loop + IF Statements

#Top Loop
Do {
    #Status if statement
    if($repeat -eq 'StartOver') {
    'Start from the top'
    #Target Computer
    $target_computer = Read-Host -Prompt "Target Computer"
    copyto-client
    start-remote-iperf
    sleep 2
    create-fwrule
    invoke-test
    } 

    #If Statement for Repeat
    if($repeat -eq 'Repeat') {
    'Run last host'
    invoke-test
    }
    
    #Collect Next Action  
    $repeat = Read-Host -Prompt "Repeat/StartOver/Exit"

    #If statement for Starting Over
    if($repeat -eq 'StartOver') {
    'Iniate Cleanup for new Run'
    stop-iperfserver
    cleanup-iperfrun
    } 

    #If Statement for Exit
    if($repeat -eq 'Exit') {
    'Iniate Cleanup for Exit'
    stop-iperfserver
    cleanup-iperfrun
    exit
    }

} While ($true -eq $true)