Reputation: 47
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.
Upvotes: 3
Views: 2821
Reputation: 1316
I made a recent post on a similar old question, but this can be also appropriate to post. If you have the capability to download and install, you can download newer iperf3 binaries for windows from the unofficial build mentioned from this neowin post. As stated before, starting with iperf3.9, the --timestamps
flag was added to allow prepended timestamps as such:
PS C:\Users\kyrlon> iperf3 -c 127.0.0.1 --timestamp
Thu Apr 4 17:32:38 2024 Connecting to host 127.0.0.1, port 5201
Thu Apr 4 17:32:38 2024 [ 5] local 127.0.0.1 port 33864 connected to 127.0.0.1 port 5201
Thu Apr 4 17:32:39 2024 [ ID] Interval Transfer Bitrate
Thu Apr 4 17:32:39 2024 [ 5] 0.00-1.00 sec 581 MBytes 4.86 Gbits/sec
Thu Apr 4 17:32:40 2024 [ 5] 1.00-2.00 sec 578 MBytes 4.84 Gbits/sec
Thu Apr 4 17:32:41 2024 [ 5] 2.00-3.00 sec 704 MBytes 5.92 Gbits/sec
Thu Apr 4 17:32:42 2024 [ 5] 3.00-4.00 sec 778 MBytes 6.53 Gbits/sec
Thu Apr 4 17:32:43 2024 [ 5] 4.00-5.00 sec 746 MBytes 6.25 Gbits/sec
Thu Apr 4 17:32:44 2024 [ 5] 5.00-6.00 sec 796 MBytes 6.66 Gbits/sec
Thu Apr 4 17:32:45 2024 [ 5] 6.00-7.00 sec 708 MBytes 5.96 Gbits/sec
Thu Apr 4 17:32:46 2024 [ 5] 7.00-8.00 sec 790 MBytes 6.63 Gbits/sec
Thu Apr 4 17:32:47 2024 [ 5] 8.00-9.00 sec 815 MBytes 6.84 Gbits/sec
Thu Apr 4 17:32:48 2024 [ 5] 9.00-10.00 sec 881 MBytes 7.38 Gbits/sec
Thu Apr 4 17:32:48 2024 - - - - - - - - - - - - - - - - - - - - - - - - -
Thu Apr 4 17:32:48 2024 [ ID] Interval Transfer Bitrate
Thu Apr 4 17:32:48 2024 [ 5] 0.00-10.00 sec 7.20 GBytes 6.19 Gbits/sec sender
Thu Apr 4 17:32:48 2024 [ 5] 0.00-10.00 sec 7.20 GBytes 6.18 Gbits/sec receiver
Thu Apr 4 17:32:48 2024
Thu Apr 4 17:32:48 2024 iperf Done.
Additionally, as mentioned by the release notes for iperf3.9:
An optional argument to this flag, which is a format specification to strftime(3), allows for custom timestamp formats (#909, #1028).
You can also get fancy and add optional flags for custom formats specified from strftime to your desires.
Here is an example with format string set to an equivalent to "%H:%M:%S" (the ISO 8601 time format) with a space after the prepended time:
PS C:\Users\kyrlon> iperf3 -c 127.0.0.1 --timestamp="%T "
18:25:36 Connecting to host 127.0.0.1, port 5201
18:25:36 [ 5] local 127.0.0.1 port 34916 connected to 127.0.0.1 port 5201
18:25:37 [ ID] Interval Transfer Bitrate
18:25:37 [ 5] 0.00-1.00 sec 603 MBytes 5.03 Gbits/sec
18:25:38 [ 5] 1.00-2.00 sec 608 MBytes 5.12 Gbits/sec
18:25:39 [ 5] 2.00-3.00 sec 634 MBytes 5.32 Gbits/sec
18:25:40 [ 5] 3.00-4.00 sec 663 MBytes 5.56 Gbits/sec
18:25:41 [ 5] 4.00-5.00 sec 756 MBytes 6.34 Gbits/sec
18:25:42 [ 5] 5.00-6.00 sec 784 MBytes 6.56 Gbits/sec
18:25:43 [ 5] 6.00-7.01 sec 593 MBytes 4.97 Gbits/sec
18:25:44 [ 5] 7.01-8.00 sec 790 MBytes 6.64 Gbits/sec
18:25:45 [ 5] 8.00-9.00 sec 784 MBytes 6.59 Gbits/sec
18:25:46 [ 5] 9.00-10.00 sec 689 MBytes 5.79 Gbits/sec
18:25:46 - - - - - - - - - - - - - - - - - - - - - - - - -
18:25:46 [ ID] Interval Transfer Bitrate
18:25:46 [ 5] 0.00-10.00 sec 6.74 GBytes 5.79 Gbits/sec sender
18:25:46 [ 5] 0.00-10.00 sec 6.74 GBytes 5.78 Gbits/sec receiver
18:25:46
18:25:46 iperf Done.
Upvotes: 1
Reputation: 439812
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.
Upvotes: 4
Reputation: 71
Did you try using the --interval
or --verbose
(for details) options?
Upvotes: 0