网络性能测试工具: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


相关推荐
皮实的芒果3 小时前
前端实时通信方案对比:WebSocket vs SSE vs setInterval 轮询
前端·javascript·性能优化
mx9513 小时前
真实业务场景:在React中使用Web Worker实现HTML导出PDF的性能优化实践
性能优化·浏览器
博睿谷IT99_6 小时前
PostgreSQL性能优化实用技巧‌
数据库·postgresql·性能优化
天才测试猿7 小时前
软件测试之功能测试详解
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
冼紫菜7 小时前
基于Redis实现高并发抢券系统的数据同步方案详解
java·数据库·redis·后端·mysql·缓存·性能优化
顾林海7 小时前
深入探究 Android Native 代码的崩溃捕获机制
android·面试·性能优化
施嘉伟9 小时前
Kingbase性能优化浅谈
性能优化·kingbase
远方23510 小时前
应用信息1.13.0发布
测试工具·安全·apk·开发工具·应用·工具·信息
珠峰下的沙砾12 小时前
如何在 Postman 中,自动获取 Token 并将其赋值到环境变量
测试工具·lua·postman
东风西巷12 小时前
Control Center安卓版:自定义控制中心,提升手机操作体验
android·智能手机·性能优化·软件需求