iperf3 网络性能测试

iperf3测试

1、iperf3简介

iperf3是一个主动测试网络带宽的工具,可以测试iTCP、UDP、SCTP等网络带宽;可以通过参数修改网络协议、缓冲区、测试时间、数据大小等,每个测试结果会得出吞吐量、带宽、重传数、丢包数等测试结果

2、参数详解

通用参数:

  • -v, --version,显示版本信息并退出;
  • -p, --port #,Server 端监听、Client 端连接的端口号;
  • -f, --format [kmgKMG],报告中所用的数据单位,Kbits, Mbits, KBytes, Mbytes;
  • -i, --interval #,每次报告的间隔,单位为秒;
  • -F, --file name,测试所用文件的文件名。如果使用在 Client 端,发送该文件用作测试;如果使用在 Server 端,则是将数据写入该文件,而不是丢弃;
  • -A, --affinity n/n,m,设置 CPU 亲和力;
  • -B, --bind ,绑定指定的网卡接口;
  • -V, --verbose,运行时输出更多细节;
  • -J, --json,运行时以 JSON 格式输出结果;
  • –logfile f,输出到文件;
  • -d, --debug,以 debug 模式输出结果;
  • -h, --help,显示帮助信息并退出。

Server 端参数:

  • -s, --server,以 Server 模式运行;
  • -D, --daemon,在后台以守护进程运行;
  • -I, --pidfile file,指定 pid 文件;
  • -1, --one-off,只接受 1 次来自 Client 端的测试,然后退出。

Client 端参数:

  • -c, --client ,以 Client 模式运行,并指定 Server 端的地址;
  • -u, --udp,以 UDP 协议进行测试;
  • -b, --bandwidth #[KMG][/#],限制测试带宽。UDP 默认为 1Mbit/秒,TCP 默认无限制
  • -t, --time #,以时间为测试结束条件进行测试,默认为 10 秒
  • -n, --bytes #[KMG],以数据传输大小为测试结束条件进行测试;
  • -k, --blockcount #[KMG],以传输数据包数量为测试结束条件进行测试;
  • -l, --len #[KMG],读写缓冲区的长度,TCP 默认为 128K,UDP 默认为 8K
  • –cport ,指定 Client 端运行所使用的 TCP 或 UDP 端口,默认为临时端口;
  • -P, --parallel #,测试数据流并发数量;多线程
  • -R, --reverse,反向模式运行(Server 端发送,Client 端接收);
  • -w, --window #[KMG],设置套接字缓冲区大小,TCP 模式下为窗口大小;
  • -C, --congestion ,设置 TCP 拥塞控制算法(仅支持 Linux 和 FreeBSD );
  • -M, --set-mss #,设置 TCP/SCTP 最大分段长度(MSS,MTU 减 40 字节);
  • -N, --no-delay,设置 TCP/SCTP no delay,屏蔽 Nagle 算法;
  • -4, --version4,仅使用 IPv4;
  • -6, --version6,仅使用 IPv6;
  • -S, --tos N,设置 IP 服务类型(TOS,Type Of Service);
  • -L, --flowlabel N,设置 IPv6 流标签(仅支持 Linux);
  • -Z, --zerocopy,使用 “zero copy”(零拷贝)方法发送数据;
  • -O, --omit N,忽略前 n 秒的测试;
  • -T, --title str,设置每行测试结果的前缀;
  • –get-server-output,从 Server 端获取测试结果;
  • –udp-counters-64bit,在 UDP 测试包中使用 64 位计数器(防止计数器溢出)。
3、安装使用
#在线使用下面指令可以安装iperf3工具
ccc@ccc:~$sudo apt install iperf3

测试用例

服务端

robot@robot:~$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.4.110, port 50512
[  5] local 192.168.4.77 port 5201 connected to 192.168.4.110 port 50518
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   573 KBytes  4.69 Mbits/sec                  
[  5]   1.00-2.00   sec   498 KBytes  4.08 Mbits/sec                  
[  5]   2.00-3.00   sec   433 KBytes  3.54 Mbits/sec                  
[  5]   3.00-4.00   sec   519 KBytes  4.25 Mbits/sec                  
[  5]   4.00-5.00   sec   592 KBytes  4.85 Mbits/sec                  
[  5]   5.00-6.00   sec   568 KBytes  4.66 Mbits/sec                  
[  5]   6.00-7.00   sec   632 KBytes  5.18 Mbits/sec                  
[  5]   7.00-8.00   sec   559 KBytes  4.58 Mbits/sec                  
[  5]   8.00-9.00   sec   583 KBytes  4.77 Mbits/sec                  
[  5]   9.00-10.00  sec   684 KBytes  5.61 Mbits/sec                  
[  5]  10.00-10.09  sec  80.6 KBytes  7.11 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.09  sec  6.10 MBytes  5.07 Mbits/sec    6             sender
[  5]   0.00-10.09  sec  5.59 MBytes  4.64 Mbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

客户端

tcp网络协议测试

ccc@ccc:~$ iperf3 -c 192.168.4.77
Connecting to host 192.168.4.77, port 5201
[  4] local 172.17.145.18 port 43830 connected to 192.168.4.77 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   954 KBytes  7.82 Mbits/sec    0   62.2 KBytes
[  4]   1.00-2.00   sec   608 KBytes  4.98 Mbits/sec    0   87.7 KBytes
[  4]   2.00-3.00   sec   547 KBytes  4.48 Mbits/sec    1   72.1 KBytes
[  4]   3.00-4.00   sec   486 KBytes  3.98 Mbits/sec    0   87.7 KBytes
[  4]   4.00-5.00   sec   608 KBytes  4.98 Mbits/sec    0   96.2 KBytes
[  4]   5.00-6.00   sec   547 KBytes  4.48 Mbits/sec    3   49.5 KBytes
[  4]   6.00-7.00   sec   669 KBytes  5.48 Mbits/sec    0   58.0 KBytes
[  4]   7.00-8.00   sec   547 KBytes  4.48 Mbits/sec    2   46.7 KBytes
[  4]   8.00-9.00   sec   547 KBytes  4.48 Mbits/sec    0   58.0 KBytes
[  4]   9.00-10.00  sec   730 KBytes  5.98 Mbits/sec    0   62.2 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  6.10 MBytes  5.12 Mbits/sec    6             sender
[  4]   0.00-10.00  sec  5.59 MBytes  4.69 Mbits/sec                  receiver

iperf Done.
  • [ ID]:这是测试会话的唯一标识符,此处为数字4,表示这是第四个测试会话。
  • Interval:测试的时间区间,从0.00秒开始,持续到10.00秒结束。
  • Transfer:在指定时间范围内传输的数据总量。发送端传输了大约6.10 MBytes(兆字节)的数据,接收端接收了大约5.59 MBytes的数据。
  • Bandwidth:数据传输的带宽,即每秒传输的数据量。发送端的带宽为5.12 Mbits/sec(兆比特每秒),接收端的带宽为4.69 Mbits/sec。
  • Retr:重传次数,出现在发送端的信息中,此处为6,表示在测试期间发送端有6次数据包需要重传。

在这次10秒的网络性能测试中,发送端以大约5.12兆比特每秒的带宽传输数据,共传输了6.10兆字节,期间发生了6次数据包重传。接收端则以大约4.69兆比特每秒的带宽接收了5.59兆字节的数据。这表明网络连接存在一定的丢包和带宽波动,需要进一步排查网络质量或设备性能问题。

udp网络协议测试

ccc@ccc:~$ iperf3 -u -b 50M -c 192.168.4.77
Connecting to host 192.168.4.77, port 5201
[  4] local 172.17.145.18 port 2307 connected to 192.168.4.77 port 5201
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec  5.41 MBytes  45.4 Mbits/sec  693
[  4]   1.00-2.00   sec  5.96 MBytes  50.0 Mbits/sec  763
[  4]   2.00-3.00   sec  5.97 MBytes  50.1 Mbits/sec  764
[  4]   3.00-4.00   sec  5.96 MBytes  50.0 Mbits/sec  763
[  4]   4.00-5.00   sec  5.95 MBytes  49.9 Mbits/sec  761
[  4]   5.00-6.00   sec  5.97 MBytes  50.1 Mbits/sec  764
[  4]   6.00-7.00   sec  5.95 MBytes  49.9 Mbits/sec  761
[  4]   7.00-8.00   sec  5.98 MBytes  50.1 Mbits/sec  765
[  4]   8.00-9.00   sec  5.95 MBytes  49.9 Mbits/sec  761
[  4]   9.00-10.00  sec  5.95 MBytes  49.9 Mbits/sec  762
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-10.00  sec  59.0 MBytes  49.5 Mbits/sec  0.000 ms  0/0 (0%)
[  4] Sent 0 datagrams

iperf Done.
  • Jitter:表示数据包传输延迟的变化情况,数值为0.000毫秒,表示数据包之间的延迟非常稳定;
  • Lost/Total Datagrams:表示丢失率,为0%,即所有发送的数据包都成功到达了目的地;
  • 专属学习链接:https://xxetb.xetslk.com/s/36yiy3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值