How can I stop iperf server when it finishes?

25,358

Solution 1

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

Solution 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

Solution 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.)

Solution 4

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.

Solution 5

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

iperf -s -w 2Mb -p 5001 &
sleep 20
pkill iperf
Share:
25,358
Admin
Author by

Admin

Updated on October 02, 2020

Comments

  • Admin
    Admin about 3 years

    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.