11

Once the client finishes the process is automatically closed. I would like to do the same thing in the server side, because I want to automatize some processes, but the server side finishes but remains open.

Ander Galisteo
  • 111
  • 1
  • 1
  • 3

5 Answers5

4

In iperf3, you can just give the -1 parameter and it will close automatically. It only accepts one connection and it will exit when that is finished.

Example: % iperf3 -s -B 192.168.20.10 -p 70011 -1

user3480788
  • 111
  • 1
  • 6
3

I think it depends on the version. I can speak for iperf 2 where we recently added this capability. When the -server is launched there will ultimately be two threads per the "server", a listener thread and a traffic (receiver/server) thread. So -t does a few things, it sets the listener thread timeout and the traffic threads' times. The listener thread is the parent of the traffic thread so it must wait for the traffic threads to complete before it can terminate.

Example: Let's say one issues iperf -s -t 30 which will keep the listener around for 30 seconds. If no clients present themselves within 30 seconds the "server" terminates after 30 seconds. But if 20 seconds after the iperf -s -t 30 a client connect, e.g. iperf -c <server> -t 30, then the listener/server will to stay around for 20 + 30 seconds before terminating. (Note: The client's -t <value> isn't passed to the server so the server -t needs to be equal or greater than the clients -t.)

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
rjmcmahon
  • 324
  • 1
  • 3
3

In server side of iperf there is no -t option for time limitting. You can use -P option for limiting the incoming clients.

For example if you run iperf -s -P 1 command, after the client finishes the test, the server shuts itself down.

Jean Spector
  • 916
  • 9
  • 9
Onur
  • 43
  • 8
  • 1
    This should be the correct answer, or more specifically, `iperf -s -P 1` will cause the server to exit after one client test has completed. – emorris May 22 '20 at 14:45
  • I am using `iperf3` and in my case I would start up the server like this: `iperf3 -s -1`. Maybe it is the same in `iperf`? i.e: Not `-P 1` but just `-1`. – FlexMcMurphy Jun 03 '23 at 20:47
2

use iperf option -t . So that it will stop after t seconds. Default iperf client timeout is 10 seconds. so it stops after that.

Try. Here both will stop after 10 seconds.

Server: iperf -s -t 10

Client: iperf -c <ipaddress> -t 10

Rilwan
  • 2,251
  • 2
  • 19
  • 28
1

Start it in background, wait until it's complete and after kill it.

iperf -s -w 2Mb -p 5001 &
sleep 20
pkill iperf
Krisz
  • 701
  • 7
  • 23
  • 1
    for me, iperf did nothing from a TERM signal or Ctrl-C. In this case use `pkill -KILL iperf` – JPT Jul 02 '18 at 13:26