ipref网络性能评估工具
基本介绍
网络的主要性能参数包括带宽,时延,抖动和丢包率,用一个名词就是QOS(服务质量)。Iperf(可测丢包率)可以用来测量网络带宽和网络质量,还可以提供网络延迟抖动、数据包丢失率、最大传输单元等统计信息。参考:网络性能评估工具Iperf详解(可测丢包率)
(1)TCP方面
- 测试网络带宽。
- 报告MSS/MTU值的大小,在Windows上不支持;
- 支持通过套接字缓冲区修改TCP窗口大小。
(2)UDP方面(对UDP应用的关注点不是传输数据有多快,而是它的丢包率和延时指标)
-
可以设置指定带宽的UDP数据流
-
可以统计网络抖动值、丢包数等
-
支持多播测试
使用iperf,需要两台服务器,一台运行在服务器模式下(默认监听TCP 5001端口),另一台运行在客户端模式下。
IPerf通过选项 -c 和 -s 决定其当前是作为客户端程序还是作为服务端程序运行,作为客户端程序运行时,-c 后面是对端服务器的IP或域名。
特性
iperf2和iperf3是很大不同的产品,各有特点,https://iperf.fr/iperf-doc.php#3change
-
iPerf2 features currently supported by iPerf3 :
- TCP and UDP tests
- Set port (-p)
- Setting TCP options: No delay, MSS, etc.
- Setting UDP bandwidth (-b)
- Setting socket buffer size (-w)
- Reporting intervals (-i)
- Setting the iPerf buffer (-l)
- Bind to specific interfaces (-B)
- IPv6 tests (-6)
- Number of bytes to transmit (-n)
- Length of test (-t)
- Parallel streams (-P)
- Setting DSCP/TOS bit vectors (-S)
- Change number output format (-f)
-
New Features in iPerf 3.0 :
- Dynamic server (client/server parameter exchange) – Most server options from iPerf2 can now be dynamically set by the client
- Client/server results exchange
- A iPerf3 server accepts a single client simultaneously (multiple clients simultaneously for iPerf2)
- iPerf API (libiperf) – Provides an easy way to use, customize and extend iPerf functionality
- -R, Reverse test mode – Server sends, client receives
- -O, --omit N : omit the first n seconds (to ignore TCP slowstart)
- -b, --bandwidth n[KM] for TCP (only UDP for IPERF 2): Set target bandwidth to n bits/sec (default 1 Mbit/sec for UDP, unlimited for TCP).
- -V, --verbose : more detailed output than before
- -J, --json : output in JSON format
- -Z, --zerocopy : use a ‘zero copy’ sendfile() method of sending data. This uses much less CPU.
- -T, --title str : prefix every output line with this string
- -F, --file name : xmit/recv the specified file
- -A, --affinity n/n,m : set CPU affinity (cores are numbered from 0 - Linux and FreeBSD only)
- -k, --blockcount #[KMG] : number of blocks (packets) to transmit (instead of -t or -n)
- -4, --version4 : only use IPv4
- -6, --version6 : only use IPv6
- -L, --flowlabel : set IPv6 flow label (Linux only)
- -C, --linux-congestion : set congestion control algorithm (Linux and FreeBSD only) (-Z in iPerf2)
- -d, --debug : emit debugging output. Primarily (perhaps exclusively) of use to developers.
- -s, --server : iPerf2 can handle multiple client requests. iPerf3 will only allow one iperf connection at a time.
-
New Features in iPerf 3.1 :
- -I, --pidfile file write a file with the process ID, most useful when running as a daemon.
- –cport : Specify the client-side port.
- –sctp use SCTP rather than TCP (Linux, FreeBSD and Solaris).
- –udp-counters-64bit : Support very long-running UDP tests, which could cause a counter to overflow
- –logfile file : send output to a log file.
-
iPerf2 Features Not Supported by iPerf3 :
- Bidirectional testing (-d / -r)
- Data transmitted from stdin (-I)
- TTL : time-to-live, for multicast (-T)
- Exclude C(connection) D(data) M(multicast) S(settings) V(server) reports (-x)
- Report as a Comma-Separated Values (-y)
- Compatibility mode allows for use with older version of iPerf (-C)
- -m 参数探测TCP最大MTU,ipref3没有!
安装
ipref支持手机、windows和Linux各种版本。支持多线程,在客户端与服务端支持多重连接。
龙芯mips rpm包:http://ftp.loongnix.cn/os/loongnix/1.0/os/Packages/i/,有iperf-2.0.5和iperf3-3.0.6
龙芯mips deb包:http://ftp.loongnix.cn/os/loongnix/20/mips64el/pool/main/i/iperf3/,只有3.6-2版本
中科方德:http://update.os.nfschina.com/static/NFS4.0/GenOS/RPMS/Releases/Packages/,有iperf3-3.5-3
手动安装(Linux X86):
sudo wget -O /usr/lib/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3
sudo wget -O /usr/bin/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3
sudo chmod +x /usr/bin/iperf3
还有一个比较老的java GUI版本Jpref,有2.0和3.0,内置对应的iperf命令行。
命令格式
[客户端]
-b,--bandwidth 指定客户端通过UDP协议发送信息的带宽,默认值为1Mbit/s
-c host 以客户端模式运行,连接到IPerf服务端运行的主机IP地址或域名
-t ; -i -t(timing)测试的时长,默认10秒;-i(interval)带宽报告周期性显示的间隔时间
-n 设置测试所发送的数据总量,
-d, -L 双向传输测试模式,客户端与服务端建立双向连接,并相互发送数据进行测试
-r, -L 交易模式,在客户端到服务端的测试结束后,执行服务端到客户端的测试
-P 设置客户端同时连接到服务端的并发数(在多线程允许的条件下),默认值为1
-L,--listenport 指定一个端口,服务器将利用这个端口与客户机连接
-S, --tos 设置发出包的类型,具体类型请参阅man文档
-F 指定需要传输的文件
-T 指定ttl值
[服务端]
-s 以服务端模式运行,等待客户端的连接请求
-D Unix平台以后台守护程序运行;Windows平台下以服务形式运行
[服务端与客户端通用参数]
-f [kmKM] 分别表示以Kbits, Mbits, KBytes, MBytes显示报告,默认以Mbits为单位
-i sec 以秒为单位显示报告间隔
-l 缓冲区大小,默认是8KB
-R Run in reverse mode (server sends, client receives).
-m 显示tcp最大mtu
-o 将报告和错误信息输出到文件
-p 指定服务器端使用的端口或客户端所连接的端口
-u 使用udp协议
-w 指定TCP窗口大小,默认是8KB
-B 绑定一个主机地址或接口(当主机有多个地址或接口时使用该参数)
-C 兼容旧版本(当server端和client端版本不一样时使用)
-M 设定TCP数据包的最大mtu值
-N 设定TCP不延时
-V 传输ipv6数据包
[注] windows用iperf发流量可能需要增加-w的参数,在client端增加,如iperf3 -c 192.168.0.100 -w 16M -i 1 -P 5 -B 192.168.0.10 -t 10
使用实例
一般iperf3和iperf2都会同时使用,注意版本最好一致。
其中抖动和丢包率适应于UDP测试,而带宽测试适应于TCP和UDP,iperf不能够用来测试时延(通过PING来测试)。
图中D1,D2分别表示包A和包B的时延。
抖动=|D2-D1|
jitter抖动值就是连续发送时延差值的平均值。如果延时不稳定,忽快忽慢,网络就存在抖动。抖动这个指标,在VOIP,视频会议等场合,是一个非常重要的指标,如果产生抖动,往往声音和图像也会抖动,无法听清楚或者看清楚。
测试htb的时候最好用udp,udp通信开销小,测试的带宽更准确
带宽测试通常采用UDP模式,因为能测出极限带宽、时延抖动、丢包率。在进行测试时,首先以链路理论带宽作为数据发送速率进行测试,例如,从 客户端到服务器之间的链路的理论带宽为100Mbps,先用 -b 100M进行测试,然后根据测试结果(包括实际带宽,时延抖动和丢包率),再以实际带宽作为数据发送速率进行测试,会发现时延抖动和丢包率比第一次好很多,重复测试几次,就能得出稳定的实际带宽。
几个测试的报告:
TCP测试
j假设:192.168.1.1 为服务端,192.168.1.2为客户端
ipserf -s
(1)tcp模式下,客户端到服务器192.168.1.1上传带宽测试,测试时间为60秒
iperf -c 192.168.1.1 -t 60
iperf将尝试从客户端尽可能快地向服务端发送数据请求,并且会输出发送的数据量和网卡平均带宽值。
(2)客户端同时向服务器端发起30个连接线程
iperf -c 192.168.1.1 -P 30 -t 60
(3)测试上、下行带宽,测试时间60秒
iperf -c 192.168.1.1 -d -t 60
(4)通过“-n”参数指定要发送的数据量,或者"-F"一个大文件,模拟大量的数据传输。在指定“-n” “-F”参数后,“-t”参数失效。
iperf -c 192.168.1.1 -i 10 -n 10000000000
使用TCP来测试网络带宽,需要特别注意TCP窗口大小,可以使用-w参数指定。
网络通道的容量capacity = bandwidth * round-trip time
而理论TCP窗口的大小就是网络通道的容量。比如,网络带宽为40Mbit/s,回环路径消耗时间是2ms,那么TCP的窗口大小不小于40Mbit/s×2ms = 80kbit = 10Kbytes。查询iperf默认的TCP窗口大小来决定是否需要设置此参数,在此例中,窗口大小应设计大于10Kbytes,当然在实际测试中可能需要作出调整。
UDP测试
使用-u参数进行UDP测试。
- 吞吐量,抖动和丢包率需要同时测试,只能通过UDP获得。
- 与TCP测试不同的是,UDP测试不采取尽可能快地发送流量的方式,可以直接指定目标带宽。
- 此外,udp通信开销小,测试的带宽更准确。
服务端:
ipserf3 -s
ipserf -s -u
客户端测试:
iperf -c 192.168.1.1 -u -i 1 -f M -t 10 -b 100M
iperf -c 192.168.1.1 -u -i 1 -w 1M -t 30 -P 20 -b 100k
改变包大小测速:
iperf -s -u -i 1 -p 8000 -l 1380
iperf -u -c 192.168.1.1 -p 8000 -l 1380 -B 192.168.1.2 -t 100 -i 1 -b 100M
192.168.1.1 -u -i 1 -w 1M -t 30 -P 20 -b 100k
改变包大小测速:
```shell
#服务器:
iperf -s -u -i 1 -p 8000 -l 1380 # 数据包大小是1380个字节
#客户端
iperf -u -c 192.168.1.1 -p 8000 -l 1380 -B 192.168.1.2 -t 100 -i 1 -b 100M #绑定本地ip
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)