首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >结束iperf3服务器

结束iperf3服务器
EN

Stack Overflow用户
提问于 2018-08-15 23:05:51
回答 3查看 2.9K关注 0票数 0

基于this的答案,如何在iperf3中做到这一点。在浏览iperf3手册页和文档时,似乎不再存在-t选项。如果有一段时间没有客户端存在,那么在某个时间段之后,我还能实现哪些其他方式来终止服务器进程呢?有比在后台运行bash脚本更好/更简单的方法吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-09-04 23:45:36

目前没有办法使iperf3服务器在一段时间后死亡,或者如果没有客户机的话。

您发布的链接提到希望在测试后使iperf2端点完成。iperf3支持一次关闭标志,使服务器最多只能进行一次测试和退出.

票数 1
EN

Stack Overflow用户

发布于 2018-09-06 19:48:00

使用iperf2,-t将在没有通信量的t秒钟后杀死侦听器。它还将服务器线程限制为t秒,而不考虑客户端的-t时间。如果给定-d,则-t只应用于服务器通信线程,iperf侦听器将保持不变。

测试后关闭侦听器的另一个选项是在服务器命令行上设置-P 1。

鲍勃

https://sourceforge.net/projects/iperf2/

票数 1
EN

Stack Overflow用户

发布于 2022-03-18 12:23:04

解决这个问题的一种方法是,如果您在某个时间段之后没有连接,或者客户端连接超时。您可以尝试执行服务器到服务器连接。这再加上1 off选项将接近服务器。

使用python2的示例:

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51867590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档