Reputation: 980
based off this answer, how can this be done in iperf3
. Going through the iperf3
man page and documentation, it seems that the -t
option no longer exists. What other ways can I implement to kill the server process after some duration or if no clients exist for some time? Is there a better / easier way than running a bash script in the back ground to kill the server after a certain amount of time?
Upvotes: 0
Views: 5089
Reputation: 15009
If you started iperf3
in daemon mode with the -D
option
iperf3 -s -D
Then you can stop it by sending it a SIGHUP
signal (signal number 1)
pkill -HUP iperf3
or
pkill -1 iperf3
Upvotes: 0
Reputation: 369
One way around this is if you dont get a connection after a certain period or the client side connection times out. You can try doing a server to server connection. This coupled with the 1 off option will close to server.
example using python2:
import subprocess
import time
import numpy as np
iperf_location = r'C:\Users\iperf3.exe'
server_IP = '192.168.0.10'
client_IP = '192.168.0.11'
server_command = iperf_location + ' -s -B ' + server_IP + ' --one-off'
client_command = iperf_location + ' -c ' + server_IP + ' -B ' + client_IP
#this command does a server to server connection. This way the server will close out correctly
#in the event that the client cannot connect
fail_command = iperf_location + ' -c ' + server_IP + ' -B ' + server_IP
subprocess.Popen(server_command)
time.sleep(1)
x = subprocess.Popen(client_command, stdout=subprocess.PIPE)
speed_list = []
for item in x.stdout:
item = str(item)
#print item
if 'Mbits/sec' in item.split(' '):
if "sender\n" not in item.split(' '):
if "receiver\n" not in item.split(' '):
x = item.split(' ').index('Mbits/sec')
speed_list.append(float(item.split(' ')[x-1]))
if len(speed_list) != 0:
avg_data_rate = np.average(speed_list)
print avg_data_rate
else:
avg_data_rate = 0
print 'Test failed. Doing server direct test to ensure iperf cleans up correctly'
subprocess.check_output(fail_command)
Upvotes: 0
Reputation: 324
With iperf2 the -t will kill the listener after t seconds of no traffic. It will also limit the server threads to t seconds regardless of the clients' -t times. If - d is given, the -t only applies to server traffic threads and the iperf listener will remain.
Another option to kill the listener after a test is to set -P 1 on the server command line
Bob
https://sourceforge.net/projects/iperf2/
Upvotes: 1
Reputation: 446
There's no way currently to make the iperf3 server die after some amount of time, or if no clients exist.
The link you posted mentions wanting to make an iperf2 endpoint finish after a test. iperf3 supports a --one-off flag that causes the server to do at most one test and exit.
Upvotes: 1