网速测试利器-iperf3

2024-05-05 21:18
文章标签 测试 利器 网速 iperf3

本文主要是介绍网速测试利器-iperf3,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

简介

iperf3是一个网络速度测试工具,支持IPv4与IPv6,支持TCP、UDP、SCTP传输协议,可在Windows、Mac OS X、Linux、FreeBSD等各种平台使用,是一个简单又实用的小工具。 本文介绍安装、使用iperf3 网速测试工具。

安装iperf3

iperf3本身是以C++所开发的小程序,在官网https://iperf.fr/iperf-download.php上有提供各种平台的预编译二进制文件,解压缩后即可使用。

在CentOS 7上使用下列命令即可安装:

yum install iperf3

MAC OS X上使用下列命令即可安装:

brew  install iperf3

网络带宽测试

在使用iperf3测试时,要同时在server端与client端都各执行一个程序,让它们互相传送报文进行测试。下面的例子是在CentOS7上进行的测试。

首先在10.23.5.66机器启动server端的程序:

iperf3 -s

接着在10.23.5.65服务器上执行client 端的程序:

iperf3 -c 10.23.5.66

在测试时server端与client端都会出现测试的数据,client端以下是测试的结果:

[jinguang1@localhost ~]$ iperf3 -c 10.23.5.66
Connecting to host 10.23.5.66, port 5201
[  4] local 10.23.5.65 port 10412 connected to 10.23.5.66 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   114 MBytes   953 Mbits/sec    0   95.5 KBytes
[  4]   1.00-2.00   sec   113 MBytes   948 Mbits/sec    0   95.5 KBytes
[  4]   2.00-3.00   sec   113 MBytes   950 Mbits/sec    0   95.5 KBytes
[  4]   3.00-4.00   sec   113 MBytes   948 Mbits/sec    0   95.5 KBytes
[  4]   4.00-5.00   sec   113 MBytes   950 Mbits/sec    0   95.5 KBytes
[  4]   5.00-6.00   sec   113 MBytes   948 Mbits/sec    0   95.5 KBytes
[  4]   6.00-7.00   sec   113 MBytes   948 Mbits/sec    0   95.5 KBytes
[  4]   7.00-8.00   sec   113 MBytes   950 Mbits/sec    0   95.5 KBytes
[  4]   8.00-9.00   sec   113 MBytes   948 Mbits/sec    0   95.5 KBytes
[  4]   9.00-10.00  sec   113 MBytes   950 Mbits/sec    0   95.5 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   949 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.10 GBytes   949 Mbits/sec                  receiveriperf Done.

从打印的内容看,缺省参数下,Client将连接Server端的5201端口,持续向Server端发送数据,并统计出每秒传输的字节数、带宽、出现报文重传的次数、拥塞窗口(Congestion Window)大小,整个测试将持续10秒钟;最后将汇总10秒的平均数据,并给出发送和接收端的统计。

接下来分析一下Server的测试输出结果:

[jinguang1@localhost ~]$ iperf3 -s
warning: this system does not seem to support IPv6 - trying IPv4
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 10.23.5.65, port 10410
[  5] local 10.23.5.66 port 5201 connected to 10.23.5.65 port 10412
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   109 MBytes   913 Mbits/sec
[  5]   1.00-2.00   sec   113 MBytes   948 Mbits/sec
[  5]   2.00-3.00   sec   113 MBytes   949 Mbits/sec
[  5]   3.00-4.00   sec   113 MBytes   949 Mbits/sec
[  5]   4.00-5.00   sec   113 MBytes   949 Mbits/sec
[  5]   5.00-6.00   sec   113 MBytes   949 Mbits/sec
[  5]   6.00-7.00   sec   113 MBytes   949 Mbits/sec
[  5]   7.00-8.00   sec   113 MBytes   949 Mbits/sec
[  5]   8.00-9.00   sec   113 MBytes   949 Mbits/sec
[  5]   9.00-10.00  sec   113 MBytes   949 Mbits/sec
[  5]  10.00-10.04  sec  4.29 MBytes   947 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-10.04  sec  0.00 Bytes  0.00 bits/sec                  sender
[  5]   0.00-10.04  sec  1.10 GBytes   945 Mbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

Server端缺省监听IPv6地址和端口,如果未配置IPv6,会尝试IPv4。日志显示接收了来自10.23.5.65,源端口未10410的测试请求。Client端连续进行了10秒的测试,并显示了每秒传输的字节数,带宽信息;测试结束后会汇总发送和接收的统计信息。在Client连接关闭之后会继续侦听5201端口。

iperf3 进阶指令

iperf3 所提供的选项非常多,以下介绍一些常用的参数。

1. 测试时间和输出统计数据间隔

-t参数可以指定传输测试的持续时间,而-i可以指定统计输出的间隔时间,如需要持续测试一个小时,每10秒钟打印一次输出结果:

iperf3 -c server_ip -i 10 -t 3600

2. 储存测试结果

--logfile参数可以将输出的测试结果储存至文件中:

iperf3 -c server_ip --logfile stats.txt

3. 设定侦听端口

iperf3缺省使用5201端口,如果需要指定,可以使用-p参数。这需要在Server和Client侧都需要进行指定,如使用12345端口:

#server侧
iperf3 -s -p 12345
#client侧
iperf3 -c server_ip -p 12345

4. JSON 格式输出

如果需要做一些自动化方面测试和管理工作,需要读取格式化的测试结果,那可以选择-J参数,来输出JSON格式测试结果。

[jinguang1@localhost ~]$ iperf3 -c 10.23.5.66 -J -t 2
{"start":	{"connected":	[{"socket":	4,"local_host":	"10.23.5.65","local_port":	13346,"remote_host":	"10.23.5.66","remote_port":	5201}],"version":	"iperf 3.1.7","system_info":	"Linux localhost.localdomain 3.10.0-862.9.1.el7.x86_64 #1 SMP Mon Jul 16 16:29:36 UTC 2018 x86_64","timestamp":	{"time":	"Fri, 07 Sep 2018 01:31:45 GMT","timesecs":	1536283905},"connecting_to":	{"host":	"10.23.5.66","port":	5201},"cookie":	"localhost.localdomain.1536283905.522","tcp_mss_default":	1460,"test_start":	{"protocol":	"TCP","num_streams":	1,"blksize":	131072,"omit":	0,"duration":	2,"bytes":	0,"blocks":	0,"reverse":	0}},"intervals":	[{"streams":	[{"socket":	4,"start":	0,"end":	1.000059,"seconds":	1.000059,"bytes":	118546160,"bits_per_second":	948313208.319058,"retransmits":	0,"snd_cwnd":	97820,"rtt":	508,"omitted":	false}],"sum":	{"start":	0,"end":	1.000059,"seconds":	1.000059,"bytes":	118546160,"bits_per_second":	948313208.319058,"retransmits":	0,"omitted":	false}}, {"streams":	[{"socket":	4,"start":	1.000059,"end":	2.000063,"seconds":	1.000004,"bytes":	117912520,"bits_per_second":	943296336.710671,"retransmits":	0,"snd_cwnd":	97820,"rtt":	499,"omitted":	false}],"sum":	{"start":	1.000059,"end":	2.000063,"seconds":	1.000004,"bytes":	117912520,"bits_per_second":	943296336.710671,"retransmits":	0,"omitted":	false}}],"end":	{"streams":	[{"sender":	{"socket":	4,"start":	0,"end":	2.000063,"seconds":	2.000063,"bytes":	236458680,"bits_per_second":	945804841.588347,"retransmits":	0,"max_snd_cwnd":	97820,"max_rtt":	508,"min_rtt":	499,"mean_rtt":	503},"receiver":	{"socket":	4,"start":	0,"end":	2.000063,"seconds":	2.000063,"bytes":	235998780,"bits_per_second":	943965299.700324}}],"sum_sent":	{"start":	0,"end":	2.000063,"seconds":	2.000063,"bytes":	236458680,"bits_per_second":	945804841.588347,"retransmits":	0},"sum_received":	{"start":	0,"end":	2.000063,"seconds":	2.000063,"bytes":	235998780,"bits_per_second":	943965299.700324},"cpu_utilization_percent":	{"host_total":	3.365885,"host_user":	0.294900,"host_system":	3.447099,"remote_total":	0.054653,"remote_user":	0.003388,"remote_system":	0.049958},"sender_tcp_congestion":	"cubic","receiver_tcp_congestion":	"cubic"}
}

5. 使用多条连接进行测试

-P参数可以指定同时连接测试的数量,缺省使用一条连接。

[jinguang1@localhost ~]$ iperf3 -c 10.23.5.66 -P 2 -t 2
Connecting to host 10.23.5.66, port 5201
[  4] local 10.23.5.65 port 13652 connected to 10.23.5.66 port 5201
[  6] local 10.23.5.65 port 13654 connected to 10.23.5.66 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  56.8 MBytes   477 Mbits/sec    0   65.6 KBytes
[  6]   0.00-1.00   sec  56.9 MBytes   478 Mbits/sec    0   67.0 KBytes
[SUM]   0.00-1.00   sec   114 MBytes   954 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   1.00-2.00   sec  56.5 MBytes   474 Mbits/sec    0   65.6 KBytes
[  6]   1.00-2.00   sec  56.5 MBytes   474 Mbits/sec    0   67.0 KBytes
[SUM]   1.00-2.00   sec   113 MBytes   948 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-2.00   sec   113 MBytes   475 Mbits/sec    0             sender
[  4]   0.00-2.00   sec   113 MBytes   474 Mbits/sec                  receiver
[  6]   0.00-2.00   sec   113 MBytes   476 Mbits/sec    0             sender
[  6]   0.00-2.00   sec   113 MBytes   474 Mbits/sec                  receiver
[SUM]   0.00-2.00   sec   227 MBytes   951 Mbits/sec    0             sender
[SUM]   0.00-2.00   sec   226 MBytes   949 Mbits/sec                  receiveriperf Done.

6. 选择使用的传输协议

iperf3缺省使用TCP作为传输协议,如果使用UDP则使用-u参数,使用SCTP 则使用--sctp参数。

7. 反向传输

缺省iperf3使用上传模式:Client负责发送数据,Server负责接收;如果需要测试下载速度,则在Client侧使用-R参数即可。

这篇关于网速测试利器-iperf3的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/962702

相关文章

Spring Cloud:构建分布式系统的利器

引言 在当今的云计算和微服务架构时代,构建高效、可靠的分布式系统成为软件开发的重要任务。Spring Cloud 提供了一套完整的解决方案,帮助开发者快速构建分布式系统中的一些常见模式(例如配置管理、服务发现、断路器等)。本文将探讨 Spring Cloud 的定义、核心组件、应用场景以及未来的发展趋势。 什么是 Spring Cloud Spring Cloud 是一个基于 Spring

将一维机械振动信号构造为训练集和测试集(Python)

从如下链接中下载轴承数据集。 https://www.sciencedirect.com/science/article/pii/S2352340918314124 import numpy as npimport scipy.io as sioimport matplotlib.pyplot as pltimport statistics as statsimport pandas

编译测试后出现“发现不明确的匹配”错误

原文链接:http://blog.163.com/zhaoyanping_1125/blog/static/201329153201204218533/ 错误提示: 【“/”应用程序中的服务器错误。  分析器错误 说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。  分析器错误信息: 发现不明确的匹配。】   这个问题发生原因一般情况是

RODNet安装测试

项⽬地址: GitHub - yizhou-wang/RODNet: RODNet: Radar object detection network 搭建环境并配置RODNet 1. 参考README.md搭建并配置环境 准备数据集 1. 本实验使⽤ ROD2021 dataset. 百度⽹盘链接:百度网盘 请输入提取码 密码:slxy 2. 使⽤这个script来重新组织文件。 具体形

Mockito测试

Mockito 一 mockito基本概念 Mock测试是单元测试的重要方法之一,而Mockito作为一个流行的Mock框架,简单易学,且有非常简洁的API,测试代码的可读性很高。 Mock测试就是在测试过程中,对于一些不容易构造(如HttpServletRequest必须在Servlet容器中才能构造出来)或者说获取比较复杂的对象(如JDBC中的ResultSet对象)

jmeter测试https请求

公司最近在搞全站HTTPS改造,进一步提高网站的安全性,防止运营商劫持。那么,改造完成后,所有前后端的URL将全部为https。 So ,研究下怎么用Jmeter访问https请求呢。 其实很简单, 第一步在jmeter中创建HTTP请求,如下图进行配置,https端口为443; 第二步,在本机浏览器,如Chrome中导入该域名证书,在更多工具-设置-管理证书的地方,找到该证书,导出到本地。然后在

pytest测试框架flaky插件重试失败用例

Pytest提供了丰富的插件来扩展其功能,本章介绍下插件flaky ,用于在测试用例失败时自动重新运行这些测试用例。与前面文章介绍的插件pytest-rerunfailures功能有些类似,但是功能上不如pytest-rerunfailures插件丰富。 flaky官方并没有明确python和pytest版本限制。 flaky安装 使用pip命令安装: pip install flaky

Selenium进行Web自动化测试

Selenium进行Web自动化测试 Selenium+Python实现Web自动化测试一、环境配置 Selenium+Python实现Web自动化测试 一、环境配置 环境基于win10(X64) 安装Python;安装PyCham安装chomedriver chomedriver下载地址 可以查看本地chrome软件版本下载对应的chomedriver,如果没有则下载最新

pytorch国内镜像源安装及测试

一、安装命令:  pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple  二、测试: import torchx = torch.rand(5, 3)print(x)

地推利器Xinstall:全方位二维码统计,打造高效地推策略,轻松掌握市场脉搏!

在移动互联网时代,地推作为一种传统的推广方式,依然占据着重要的地位。然而,随着市场竞争的加剧,地推也面临着诸多挑战,如如何有效监测下载来源、解决填码和人工登记的繁琐、避免重复打包和iOS限制、以及如何准确考核推广业绩等。针对这些痛点,Xinstall作为一款强大的移动应用统计与推广平台,推出了全面的地推二维码统计功能,助力地推人员轻松应对各种挑战。 一、一键生成统计二维码,告别繁琐填码 地推