iperf3
1 背景知识
iperf3 工具只要是用于测试服务器带宽的工具,不建议使用 scp 命令,因为测试并不准备。
1.1 带宽的单位说明
1、数据量的单位一般有两种:bit 和 Byte。
2、因此,带宽的单位也有两种:b/s 或者 B/s,如果数值较大,可以使用 K 表示千(Kb/s 或者 KB/s),M 表示百万(Mb/s 或者 MB/s)。
3、Mb/s:Million bits per second的缩写,是一种传输速率单位,指每秒传输的位(比特)数量。通常用于运营商带宽速率的计量。
4、MB/s:Million Bytes per second的缩写,是一种传输速率单位,指每秒传输的字节数量。即是我们平时说的下载速度。
5、Byte 和 bit 是不一样的,Byte = 8 bit,而不同的地方单位不同,需要进行换算,下表整理了在 VMP 中的各个位置的单位。
1.2 iperf3 中的概念
1、服务端:收包,使用 -s 参数指定, iperf3 -s
2、客户端:发包,使用 -c xx.xx.xx.xx 来指定要往哪个服务端发包,例如:
iperf3 -c 172.20.20.200
2 iperf 命令安装
yum install iperf iperf3 -y
3 iperf 参数
详情请见官方文档。
3.1 参数分为三种类型的参数
1、服务端参数。
Command line option | Description |
---|---|
-s, --server | 在服务器模式下运行iperf. |
-D, --daemon | 将 iperf 作为守护进程使用。 |
-I, --pidfilefile | 指定pidfile 的位置 |
2、客户端参数。 |
Command line option | Description |
---|---|
-c, --client host | iperf 运行为客户单 |
--sctp | 使用SCTP 而不是TCP(仅限Linux,FreeBSD和Solaries) |
-u, --udp | 使用UDP而不是TCP。 |
-b, --bandwidth n[KM] | 设置带宽的单位 'k' = Kbits/sec 'K' = KBytes/sec 'm' = Mbits/sec 'M' = MBytes/sec |
-t, --time n | 在 --time 时间内重复发送 --num 个 --length 长度大小的缓冲区数据。 |
-n, --num n[KM] | 要发送的缓冲区个数。 |
-k, --blockcount n[KM] | 要发送的数据块数量。 |
-l, --length n[KM] | 要发送的缓冲区的长度 |
-P, --parallel n | 是否开启多个连接 |
-R, --reverse | 以反向模式运行,服务端发送,客户端接收。 |
-w, --window n[KM] | 设置套接字缓冲区大小为指定值。 |
-M, --set-mss n | 尝试设置 TCP 最大段大小 (MSS)。MSS 通常是 MTU - 40 字节用于 TCP/IP 标头。对于以太网,MSS 为 1460 字节(1500 字节 MTU)。 |
-N, --no-delay | 设置TCP 无延迟的选项。 |
-4, --version4 | 仅仅使用 IPv4. |
-6, --version4 | 仅仅使用 IPv6. |
-S, --tos n | |
-L, --flowlabel n | 设置 IPv6数据流标签(currently only supported on Linux). |
-Z, --zerocopy | 使用“零拷贝”方法发送数据,而不是通常的write。 |
-O, --omit n | 跳过TCP慢启动 |
-T, --title \*str\ | 日志输出时,加上 |
-C, --linux-congestion algo | 设置 拥塞控制算法l algorithm |
3、一般通用参数。 |
命令行选项 | 描述 |
---|---|
-p, --port n | 默认值为 5201。服务器要侦听和客户端连接的服务器端口,这在客户端和服务器中应该相同。 |
--cport n | 用于指定客户端端口的选项。 |
-f, --format kmKM | 指定用于打印带宽数字的格式的字母。 'k' = Kbits/sec 'K' = KBytes/sec 'm' = Mbits/sec 'M' = MBytes/sec |
-i, --interval n | 默认值为零。设置周期带宽、抖动、和丢失报告。如果非零值,则自上次报告以来每隔几秒的带宽进行一次报告。如果为零,则无周期性打印报告。 |
-F, --file name | 客户端:从文件中读取并写入网络,而不是使用随机数据; 服务器端:从网络读取并写入文件,而不是丢弃数据。 |
-A, --affinity n/n,m-F | 如果可能的话,指定使用哪些CPU (仅限 Linux 和 FreeBSD)。其中 n 是 CPU 编号 |
-B, ---bind host | 绑定到主机,这是此计算机的地址之一。对于客户这将设置出站接口。对于服务器,这将设置传入接口。这仅在具有多个多宿主主机上有用网络接口。 |
-V, --verbose | 提供更详细的输出. |
-J, --json | JSON格式的输出 . |
--logfile file | 将输出发送到日志文件。(iPerf 3.1 中的新功能) |
--d, --debug | 发出调试输出。主要用于开发人员。 |
-v, --version | 显示版本信息并退出。 |
-h, --help | 显示帮助概要并退出。 |
4 iperf 常用用法
4.1 服务端
iperf3 -s
4.2 客户端
iperf3 -b M -c 192.168.10.170
//屏幕输出:
5] local 192.168.10.168 port 38588 connected to 192.168.10.170 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 2.97 GBytes 25.5 Gbits/sec 0 1.09 MBytes
[ 5] 1.00-2.00 sec 2.62 GBytes 22.5 Gbits/sec 0 1.14 MBytes
[ 5] 2.00-3.00 sec 2.78 GBytes 23.8 Gbits/sec 0 1.22 MBytes
[ 5] 3.00-4.00 sec 2.77 GBytes 23.8 Gbits/sec 0 1.22 MBytes
[ 5] 4.00-5.00 sec 2.66 GBytes 22.9 Gbits/sec 0 1.28 MBytes
[ 5] 5.00-6.00 sec 2.79 GBytes 24.0 Gbits/sec 0 1.28 MBytes
[ 5] 6.00-7.00 sec 2.71 GBytes 23.2 Gbits/sec 0 1.28 MBytes
[ 5] 7.00-8.00 sec 2.72 GBytes 23.3 Gbits/sec 0 1.28 MBytes
[ 5] 8.00-9.00 sec 2.76 GBytes 23.7 Gbits/sec 0 1.28 MBytes
[ 5] 9.00-10.00 sec 2.81 GBytes 24.2 Gbits/sec 0 1.28 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 27.6 GBytes 23.7 Gbits/sec 0 sender
[ 5] 0.00-10.04 sec 27.6 GBytes 23.6 Gbits/sec receiver