网络性能测试工具:iperf3介绍

文章目录


前言

新接触的网络环境如何评估网络带宽和吞吐量呢,有的项目没有对业务流量进行合理规划,服务或者中间件出口带宽经常有被打满的情况。所以提前预测网络带宽的瓶颈还是非常有必要的。

ipef3工具,是一个用于测试网络带宽的开源工具,用于评估网络的性能和吞吐量,他是iperf工具的第三个版本。


一、iperf3 的安装和使用

下载和安装

官网链接: https://iperf.fr/

iperf3支持Windows和Linux版本,Windows是直接编译好的exe文件,Linux一般是rpm包,可以通过yum源安装。

windows 下载连接: https://files.budman.pw/ 下载后解压,在cmd或者gitbash窗口可以启动。

Linux 通过 yum install iperf3 直接安装。

参数说明

  1. -c, --client <server_hostname>:指定客户端模式,连接到指定的服务器。

  2. -s, --server:指定服务器模式,启动 iPerf3 服务器。

  3. -p, --port :指定服务器监听的端口号,默认为 5201。

  4. -t, --time :指定测试持续时间,单位为秒,默认为 10 秒。

  5. -i, --interval :设置报告输出的间隔时间,单位为秒,默认为 1 秒。

  6. -w, --window <window_size>:设置 TCP 窗口大小,单位为字节,默认为 128KB。

  7. -b, --bandwidth :限制带宽,单位为比特每秒(bps)。

  8. -u, --udp:使用 UDP 协议进行测试,默认TCP协议。

  9. -l, --len :设置 UDP 数据包的长度,单位为字节,默认为 1460 字节。

  10. -n, --bytes :设置要发送的字节数,可以与 -t 参数一起使用。

  11. -P, --parallel :指定并发连接数,可以同时进行多个连接。

  12. -R, --reverse:反向测试,客户端变为服务器,服务器变为客户端。

  13. -V, --IPv6:使用 IPv6 地址。

  14. -h, --help:显示帮助信息。

二、iperf3 测试

现在我们分别在Windows端和Linux端安装了iperf3软件。

Windows主机 (192.168.37.1) 客户端

Linux主机(192.168.37.100) 服务端

服务端启动

bash 复制代码
[root@work ~]# iperf3 -s -p 5222
-----------------------------------------------------------
Server listening on 5222
-----------------------------------------------------------

-s 表示服务器端 -p 指定服务端监听端口

客户端启动

bash 复制代码
$ ./iperf3.exe -c 192.168.37.100 -p 5222  -t 10 -i 1
Connecting to host 192.168.37.100, port 5222
[  4] local 192.168.37.1 port 13957 connected to 192.168.37.100 port 5222
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   315 MBytes  2.64 Gbits/sec
[  4]   1.00-2.00   sec   349 MBytes  2.93 Gbits/sec
[  4]   2.00-3.00   sec   304 MBytes  2.55 Gbits/sec
[  4]   3.00-4.00   sec   332 MBytes  2.78 Gbits/sec
[  4]   4.00-5.00   sec   335 MBytes  2.81 Gbits/sec
[  4]   5.00-6.00   sec   352 MBytes  2.95 Gbits/sec
[  4]   6.00-7.00   sec   367 MBytes  3.07 Gbits/sec
[  4]   7.00-8.00   sec   367 MBytes  3.08 Gbits/sec
[  4]   8.00-9.00   sec   339 MBytes  2.84 Gbits/sec
[  4]   9.00-10.00  sec   318 MBytes  2.67 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  3.30 GBytes  2.83 Gbits/sec                  sender
[  4]   0.00-10.00  sec  3.30 GBytes  2.83 Gbits/sec                  receiver

iperf Done.

-c 表示客户端

-p 5222 指定服务端口

-t 10 测试持续时间

-i 1 设置报告输出的间隔时间。

服务端输出

bash 复制代码
[root@work ~]# iperf3 -s -p 5222
-----------------------------------------------------------
Server listening on 5222
-----------------------------------------------------------
Accepted connection from 192.168.37.1, port 13956
[  5] local 192.168.37.100 port 5222 connected to 192.168.37.1 port 13957
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   301 MBytes  2.52 Gbits/sec                  
[  5]   1.00-2.00   sec   348 MBytes  2.92 Gbits/sec                  
[  5]   2.00-3.00   sec   304 MBytes  2.55 Gbits/sec                  
[  5]   3.00-4.00   sec   333 MBytes  2.79 Gbits/sec                  
[  5]   4.00-5.00   sec   338 MBytes  2.83 Gbits/sec                  
[  5]   5.00-6.00   sec   349 MBytes  2.93 Gbits/sec                  
[  5]   6.00-7.00   sec   366 MBytes  3.07 Gbits/sec                  
[  5]   7.00-8.00   sec   366 MBytes  3.07 Gbits/sec                  
[  5]   8.00-9.00   sec   344 MBytes  2.89 Gbits/sec                  
[  5]   9.00-10.00  sec   317 MBytes  2.66 Gbits/sec                  
[  5]  10.00-10.04  sec  11.4 MBytes  2.42 Gbits/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  3.30 GBytes  2.82 Gbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5222
-----------------------------------------------------------

结果查看,主要是看 receiver Bindwidth达到的的值。

反向测试

服务端启动方式不变,客户端在原来启动命令基础上,增加-R 参数就是客户端和服务器将对调过来。

客户端

bash 复制代码
$ ./iperf3.exe -c 192.168.37.100 -p 5222  -t 10 -i 1 -R
Connecting to host 192.168.37.100, port 5222
Reverse mode, remote host 192.168.37.100 is sending
[  4] local 192.168.37.1 port 9562 connected to 192.168.37.100 port 5222
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   106 MBytes   892 Mbits/sec
[  4]   1.00-2.00   sec   106 MBytes   886 Mbits/sec
[  4]   2.00-3.00   sec   105 MBytes   877 Mbits/sec
[  4]   3.00-4.00   sec  97.9 MBytes   822 Mbits/sec
[  4]   4.00-5.00   sec  89.4 MBytes   750 Mbits/sec
[  4]   5.00-6.00   sec  74.6 MBytes   625 Mbits/sec
[  4]   6.00-7.00   sec  71.9 MBytes   603 Mbits/sec
[  4]   7.00-8.00   sec  68.0 MBytes   571 Mbits/sec
[  4]   8.00-9.00   sec  69.1 MBytes   580 Mbits/sec
[  4]   9.00-10.00  sec  69.4 MBytes   582 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec   857 MBytes   719 Mbits/sec    0             sender
[  4]   0.00-10.00  sec   857 MBytes   719 Mbits/sec                  receiver

iperf Done.

服务端

bash 复制代码
[root@work ~]# iperf3 -s -p 5222
-----------------------------------------------------------
Server listening on 5222
-----------------------------------------------------------
Accepted connection from 192.168.37.1, port 9561
[  5] local 192.168.37.100 port 5222 connected to 192.168.37.1 port 9562
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  5]   0.00-1.02   sec   105 MBytes   863 Mbits/sec    0    218 KBytes       
[  5]   1.02-2.01   sec   105 MBytes   884 Mbits/sec    0    218 KBytes       
[  5]   2.01-3.01   sec   105 MBytes   878 Mbits/sec    0    218 KBytes       
[  5]   3.01-4.02   sec  98.2 MBytes   820 Mbits/sec    0    218 KBytes       
[  5]   4.02-5.02   sec  89.5 MBytes   753 Mbits/sec    0    218 KBytes       
[  5]   5.02-6.02   sec  75.0 MBytes   628 Mbits/sec    0    218 KBytes       
[  5]   6.02-7.03   sec  73.0 MBytes   603 Mbits/sec    0    218 KBytes       
[  5]   7.03-8.03   sec  67.5 MBytes   571 Mbits/sec    0    218 KBytes       
[  5]   8.03-9.03   sec  69.5 MBytes   579 Mbits/sec    0    218 KBytes       
[  5]   9.03-10.02  sec  68.8 MBytes   582 Mbits/sec    0    218 KBytes       
[  5]  10.02-10.04  sec  1.25 MBytes   562 Mbits/sec    0    218 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.04  sec   857 MBytes   716 Mbits/sec    0             sender
[  5]   0.00-10.04  sec  0.00 Bytes  0.00 bits/sec                  receiver
-----------------------------------------------------------
Server listening on 5222
-----------------------------------------------------------

这里,服务端结果,看sender 这一行,这次服务端是发送端。带宽716Mbits/sec


相关推荐
UWA1 小时前
有什么指标可以判断手机是否降频
人工智能·智能手机·性能优化·memory·游戏开发
鼠鼠我捏,要死了捏2 小时前
深入解析Java GC调优:从原理到实战
java·性能优化·gc调优
武子康13 小时前
Java-154 深入浅出 MongoDB 用Java访问 MongoDB 数据库 从环境搭建到CRUD完整示例
java·数据库·分布式·sql·mongodb·性能优化·nosql
性感博主在线瞎搞14 小时前
【人工智能】神经网络的优化器optimizer(四):Adam自适应动量优化器
人工智能·深度学习·神经网络·性能优化·优化器
鼠鼠我捏,要死了捏16 小时前
深入剖析Java垃圾回收性能优化实战指南
java·性能优化·gc
码界奇点17 小时前
MongoDB 排序操作详解sort方法使用指南
数据库·mongodb·性能优化
武子康18 小时前
Java-157 MongoDB 存储引擎 WiredTiger vs InMemory:何时用、怎么配、如何验证 mongod.conf
java·数据库·sql·mongodb·性能优化·系统架构·nosql
白帽子凯哥哥19 小时前
SpringBoot + Elasticsearch实战:从零构建高性能搜索与数据分析平台
大数据·spring boot·后端·elasticsearch·搜索引擎·性能优化·聚合查询
软件测试小仙女19 小时前
AI驱动的测试:Cypress的cy.prompt功能实践
自动化测试·软件测试·人工智能·测试工具·cypress·ai测试·测试计划