How can I stop iperf server when it finishes?

那年仲夏 提交于 2019-12-23 09:55:51

问题


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.


回答1:


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




回答2:


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




回答3:


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

iperf -s -w 2Mb -p 5001 &
sleep 20
pkill iperf



回答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




回答5:


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

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



来源:https://stackoverflow.com/questions/39876341/how-can-i-stop-iperf-server-when-it-finishes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!