1

I'm currently trying to launch a very long Iperf test on my infrastructure, so I'm developing some powershell script in order to do the tests.

To analyses the results, I want to have the hour/minutes/seconds of each new packet sends per lines on my output.

Currently, I'm using the -T argument like that on my script :

Start-Process -FilePath "C:\iperf3.exe" -Verb runAs -ArgumentList "-c",CLIENT_IP,"-t","86400","-p",5102,"-T","$(Get-Date -Format 'HH:mm:ss')","--logfile","C:\toto.txt"

But the output of the command just give me the current time when I launch the command like this:

03:40:56:  Connecting to host x.x.x.x, port 5201
03:40:56:  [  4] local x.x.x.x port 41674 connected to x.x.x.x port 5201
03:40:56:  [ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
03:40:56:  [  4]   0.00-1.00   sec   113 MBytes   946 Mbits/sec    0    208 KBytes       
03:40:56:  [  4]   1.00-2.00   sec   112 MBytes   943 Mbits/sec    0    208 KBytes       
03:40:56:  [  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0    210 KBytes       
03:40:56:  [  4]   3.00-4.00   sec   112 MBytes   942 Mbits/sec    0    210 KBytes       
03:40:56:  [  4]   4.00-5.00   sec   112 MBytes   940 Mbits/sec    0    210 KBytes

And I cannot find a way to increment the value with the current time without relaunching several times the command iperf3.exe.

Is there any solution to increment the value? I can't do it with a "for"/"while" loop (in my opinion) because it's running a lot of iperf3 instance and it's not what is expected.

For information, I use the last version of iperf3-3.1.3 on Windows.

Thanks in advance for your help.

Pieo
  • 17
  • 3
  • If you want to record a timestamp every time it outputs a new line, you'll have to invoke it differently: `& C:\iperf3.exe args go here |ForEach-Object { "$(Get-Date -Format 'HH:mm:ss'): ${_}"}` – Mathias R. Jessen Aug 22 '22 at 15:55

2 Answers2

2

Judging by iperf3's documentation:

  • -T (--title) is for defining a static prefix to prepend to each output line, due to passing expandable string "$(Get-Date -Format 'HH:mm:ss')" as an argument, a static string representing the time at the time of string expansion (interpolation) is used.

  • By contrast, what you're looking for is the --timestamps option, which causes a (true, event-related) timestamp to be prepended to each output line.

    • You can control the specific format of these timestamps via an optional argument, using a format string as used in the Unix strftime() library function.

    • These format strings are not compatible with .NET's date/time format strings (as used by Get-Date, for instance), so HH:mm:ss does not work; the strftime() equivalent is: %H:%M:%S

To put it all together:

Start-Process -FilePath 'C:\iperf3.exe' -Verb RunAs -ArgumentList @"
 -c $client_IP -t 86400 -p 5102 --logfile C:\toto.txt --timestamps=%H:%M:%S
"@

Note: I've substituted CLIENT_IP (which I assume was just a pseudo-code placeholder), with variable $client_IP - adjust as needed.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 1
    Hello @mklement0. Thanks for your response, it was the point ! Let me just had some clarification to help other people: I was trying to do this on Windows so i've download the last packet on https://iperf.fr. But the version here is not maintain anymore by the author so you need to go on the github page and get the package from here: https://github.com/esnet/iperf Also, if you want to have the new version of Iperf for windows, you need to download it from this page because the GitHub page provide a version only for linux: https://github.com/esnet/iperf/discussions/1258 – Pieo Aug 23 '22 at 08:11
  • Glad to hear it, @Pieo. Thanks for sharing the info on where to find the Windows version. – mklement0 Aug 23 '22 at 12:51
0

Did you try using the --interval or --verbose (for details) options?

Alex Parra
  • 61
  • 3
  • I tried a form similar to Mathias' but with a loop of n times. You can try it that way or the following and it works. `For ($i=0; $i -le 10; $i++) { iperf3 -c 127.0.0.1 -p 5201 -t 1 --verbose Write-Host "Time: $(Get-Date -Format 'HH:mm:ss') ${_}" -ForegroundColor DarkGreen }` Keep in mind that the time printed would correspond to the time of the past execution. – Alex Parra Aug 22 '22 at 16:41
  • 1
    Hello @Alex, I've tried with this solution, but as you say it print only the time of the past execution. The response of mklement0 after is what I was searching for. Thanks for your help. – Pieo Aug 23 '22 at 08:10