赞
踩
iPerf - TCP、UDP 和 SCTP 的终极速度测试工具。常用的的网络限制 + 互联网中立性测试工具。被广为认可。
但是国内网站上的iperf使用说明都含糊不清甚至是错的,没办法只能自己手动翻译和搬运了官网上的iperf手册。
另请参阅 https://github.com/esnet/iperf
另请参阅 https://sourceforge.net/projects/iperf2/
iPerf 的主要目标是帮助调整特定路径上的 TCP 连接。最 TCP 的基本调整问题是 TCP 窗口大小,它控制网络中任何一点的数据量。 如果它太小,发送方有时会处于空闲状态,性能不佳。用于 TCP窗口大小是带宽延迟乘积,
瓶颈带宽 * 往返时间
在下面的 modi4/cyclops 示例中,瓶颈链路是 45 Mbit/秒的 DS3 链路,使用 ping 测量的往返时间为 42 ms。 带宽延迟乘积为
45 Mbit/秒 * 42 ms
= (45e6) * (42e-3)
= 1890000 位
= 230 KB
这是确定最佳窗口大小的起点;将其设置得更高或更低可能会产生更好的结果。 在我们的示例中,尽管带宽延迟乘积为 230K,但超过 130K 的缓冲区大小并没有提高性能。
请注意,许多操作系统和主机对 TCP 窗口大小有上限。 这些可能低至 64 KB,也可能高达几 MB。iPerf 尝试检测何时发生这些情况,并发出警告,指出实际和请求的窗口大小为 不相等(如下所示,尽管这是由于 IRIX 中的四舍五入)。 有关 TCP 窗口大小的详细信息,请参阅 LaFibre.info。 下面是伊利诺伊州 node1 和北卡罗来纳州 node2 之间的示例会话。它们通过 vBNS 主干网和 45 Mbit/秒 DS3 链路连接。 请注意,我们使用适当的 TCP 窗口大小将带宽性能提高了 3 倍。 在允许以字节粒度设置窗口大小的平台上使用自适应窗口大小功能。
node2> iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 60.0 KByte (default)
------------------------------------------------------------
[ 4] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 2357
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.1 sec 6.5 MBytes 5.2 Mbits/sec
node1> iperf -c node2
------------------------------------------------------------
Client connecting to node1, TCP port 5001
TCP window size: 59.9 KByte (default)
------------------------------------------------------------
[ 3] local <IP Addr node1> port 2357 connected with <IP Addr node2> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 6.5 MBytes 5.2 Mbits/sec
node2> iperf -s -w 130k
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 130 KByte
------------------------------------------------------------
[ 4] local <IP Addr node 2> port 5001 connected with <IP Addr node 1> port 2530
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.1 sec 19.7 MBytes 15.7 Mbits/sec
node1> iperf -c node2 -w 130k
------------------------------------------------------------
Client connecting to node2, TCP port 5001
TCP window size: 129 KByte (WARNING: requested 130 KByte)
------------------------------------------------------------
[ 3] local <IP Addr node1> port 2530 connected with <IP Addr node2> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 19.7 MBytes 15.8 Mbits/sec
node2> iperf -s -w 300k
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 300 KByte
------------------------------------------------------------
[ 4] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 6902
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.2 sec 20.9 MBytes 16.5 Mbits/sec
[ 4] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 6911
[ 5] local <IP Addr node2> port 5001 connected with <IP Addr node2> port 6912
[ ID] Interval Transfer Bandwidth
[ 5] 0.0-10.1 sec 21.0 MBytes 16.7 Mbits/sec
[ 4] 0.0-10.3 sec 12.0 MBytes 9.4 Mbits/sec
node1> ./iperf -c node2 -w 300k
------------------------------------------------------------
Client connecting to node2, TCP port 5001
TCP window size: 299 KByte (WARNING: requested 300 KByte)
------------------------------------------------------------
[ 3] local <IP Addr node2> port 6902 connected with <IP Addr node1> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.2 sec 20.9 MBytes 16.4 Mbits/sec
node1> iperf -c node2 -w 300k -P 2
------------------------------------------------------------
Client connecting to node2, TCP port 5001
TCP window size: 299 KByte (WARNING: requested 300 KByte)
------------------------------------------------------------
[ 4] local <IP Addr node2> port 6912 connected with <IP Addr node1> port 5001
[ 3] local <IP Addr node2> port 6911 connected with <IP Addr node1> port 5001
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.1 sec 21.0 MBytes 16.6 Mbits/sec
[ 3] 0.0-10.2 sec 12.0 MBytes 9.4 Mbits/sec
TCP 的次要调整问题是最大传输单元 (MTU)。 为了最有效,两个主机都应支持路径 MTU 发现。 没有路径 MTU 发现的主机通常使用 536 作为 MSS,这会浪费带宽和处理时间。 使用 -m 选项显示正在使用的 MSS,并查看这是否符合您的预期。 以太网通常约为 1460 字节。
node3> iperf -s -m
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 60.0 KByte (default)
------------------------------------------------------------
[ 4] local <IP Addr node3> port 5001 connected with <IP Addr node4> port 1096
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 2.0 sec 1.8 MBytes 6.9 Mbits/sec
[ 4] MSS size 1448 bytes (MTU 1500 bytes, ethernet)
[ 4] Read lengths occurring in more than 5% of reads:
[ 4] 952 bytes read 219 times (16.2%)
[ 4] 1448 bytes read 1128 times (83.6%)
下面是不支持路径 MTU 发现的主机。它只会发送和接收 576 字节的小数据包。
node4> iperf -s -m
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 32.0 KByte (default)
------------------------------------------------------------
[ 4] local <IP Addr node4> port 5001 connected with <IP Addr node3> port 13914
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 2.3 sec 632 KBytes 2.1 Mbits/sec
WARNING: Path MTU Discovery may not be enabled.
[ 4] MSS size 536 bytes (MTU 576 bytes, minimum)
[ 4] Read lengths occurring in more than 5% of reads:
[ 4] 536 bytes read 308 times (58.4%)
[ 4] 1072 bytes read 91 times (17.3%)
[ 4] 1608 bytes read 29 times (5.5%)
iPerf 支持其他调优选项,这些选项是针对特殊网络情况(如 HIPPI-to-HIPPI over ATM)添加的。
iPerf 创建恒定比特率 UDP 流。这是一个非常人工的流,类似于语音通信,但没有太多其他内容。
您需要将数据报大小 (-l) 调整为应用程序使用的大小。
服务器通过数据报中的 ID 号检测 UDP 数据报丢失。 通常,一个 UDP 数据报会变成多个 IP 数据包。丢失单个 IP 数据包将丢失整个数据报。 要测量数据包丢失而不是数据报丢失,请使用 -l 选项使数据报足够小以适合单个数据包。 默认大小为 1470 字节,适用于以太网。还会检测到无序数据包。 (无序数据包会导致丢失的数据包计数出现一些歧义; iPerf 假定它们不是重复的数据包,因此它们被排除在丢失的数据包计数之外。 由于 TCP 不会向用户报告丢失,因此我发现 UDP 测试有助于查看路径上的数据包丢失情况。
抖动计算由服务器连续计算,如下所示 RFC 1889 中的 RTP。客户端在 包。服务器将相对传输时间计算为 (服务器的接收时间 - 客户端的发送时间)。客户端和服务器的时钟不需要 同步;在抖动计算中减去任何差异。抖动 是连续运输时间之间差值的平滑平均值。
node2> iperf -s -u -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 60.0 KByte (default)
------------------------------------------------------------
[ 4] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 9726
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.0- 1.0 sec 1.3 MBytes 10.0 Mbits/sec 0.209 ms 1/ 894 (0.11%)
[ 4] 1.0- 2.0 sec 1.3 MBytes 10.0 Mbits/sec 0.221 ms 0/ 892 (0%)
[ 4] 2.0- 3.0 sec 1.3 MBytes 10.0 Mbits/sec 0.277 ms 0/ 892 (0%)
[ 4] 3.0- 4.0 sec 1.3 MBytes 10.0 Mbits/sec 0.359 ms 0/ 893 (0%)
[ 4] 4.0- 5.0 sec 1.3 MBytes 10.0 Mbits/sec 0.251 ms 0/ 892 (0%)
[ 4] 5.0- 6.0 sec 1.3 MBytes 10.0 Mbits/sec 0.215 ms 0/ 892 (0%)
[ 4] 6.0- 7.0 sec 1.3 MBytes 10.0 Mbits/sec 0.325 ms 0/ 892 (0%)
[ 4] 7.0- 8.0 sec 1.3 MBytes 10.0 Mbits/sec 0.254 ms 0/ 892 (0%)
[ 4] 8.0- 9.0 sec 1.3 MBytes 10.0 Mbits/sec 0.282 ms 0/ 892 (0%)
[ 4] 0.0-10.0 sec 12.5 MBytes 10.0 Mbits/sec 0.243 ms 1/ 8922 (0.011%)
node1> iperf -c node2 -u -b 10m
------------------------------------------------------------
Client connecting to node2, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 60.0 KByte (default)
------------------------------------------------------------
[ 3] local <IP Addr node1> port 9726 connected with <IP Addr node2> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 12.5 MBytes 10.0 Mbits/sec
[ 3] Sent 8922 datagrams
请注意,当使用较大的 32 KB 数据报时,由于数据报重组而导致的抖动较高,每个数据报拆分为 23 个 1500 字节的数据包。 此处看到的较高数据报丢失可能是由于流量的突发性,即 23 个背靠背数据包,然后是长数据包 暂停,而不是均匀分布的单个数据包。
node2> iperf -s -u -l 32k -w 128k -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 32768 byte datagrams
UDP buffer size: 128 KByte
------------------------------------------------------------
[ 3] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 11303
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 1.3 MBytes 10.0 Mbits/sec 0.430 ms 0/ 41 (0%)
[ 3] 1.0- 2.0 sec 1.1 MBytes 8.5 Mbits/sec 5.996 ms 6/ 40 (15%)
[ 3] 2.0- 3.0 sec 1.2 MBytes 9.7 Mbits/sec 0.796 ms 1/ 40 (2.5%)
[ 3] 3.0- 4.0 sec 1.2 MBytes 10.0 Mbits/sec 0.403 ms 0/ 40 (0%)
[ 3] 4.0- 5.0 sec 1.2 MBytes 10.0 Mbits/sec 0.448 ms 0/ 40 (0%)
[ 3] 5.0- 6.0 sec 1.2 MBytes 10.0 Mbits/sec 0.464 ms 0/ 40 (0%)
[ 3] 6.0- 7.0 sec 1.2 MBytes 10.0 Mbits/sec 0.442 ms 0/ 40 (0%)
[ 3] 7.0- 8.0 sec 1.2 MBytes 10.0 Mbits/sec 0.342 ms 0/ 40 (0%)
[ 3] 8.0- 9.0 sec 1.2 MBytes 10.0 Mbits/sec 0.431 ms 0/ 40 (0%)
[ 3] 9.0-10.0 sec 1.2 MBytes 10.0 Mbits/sec 0.407 ms 0/ 40 (0%)
[ 3] 0.0-10.0 sec 12.3 MBytes 9.8 Mbits/sec 0.407 ms 7/ 401 (1.7%)
node1> iperf -c node2 -b 10m -l 32k -w 128k
------------------------------------------------------------
Client connecting to node2, UDP port 5001
Sending 32768 byte datagrams
UDP buffer size: 128 KByte
------------------------------------------------------------
[ 3] local <IP Addr node2> port 11303 connected with <IP Addr node1> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 12.5 MBytes 10.0 Mbits/sec
[ 3] Sent 401 datagrams
要测试多播,请运行多个服务器,并设置了 bind 选项 (-B, --bind) 到组播组地址。运行客户端,连接到多播 组地址并根据需要设置 TTL(-T、–ttl)。与普通的 TCP 和 UDP测试后,客户端可以启动组播服务器。在这种情况下, 在服务器启动之前发送的数据报在第一个周期中显示为丢失 报告(下面有 61 个关于 ARNO 的数据报)。
node5> iperf -c 224.0.67.67 -u --ttl 5 -t 5
------------------------------------------------------------
Client connecting to 224.0.67.67, UDP port 5001
Sending 1470 byte datagrams
Setting multicast TTL to 5
UDP buffer size: 32.0 KByte (default)
------------------------------------------------------------
[ 3] local <IP Addr node5> port 1025 connected with 224.0.67.67 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 5.0 sec 642 KBytes 1.0 Mbits/sec
[ 3] Sent 447 datagrams
node5> iperf -s -u -B 224.0.67.67 -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 224.0.67.67
Joining multicast group 224.0.67.67
Receiving 1470 byte datagrams
UDP buffer size: 32.0 KByte (default)
------------------------------------------------------------
[ 3] local 224.0.67.67 port 5001 connected with <IP Addr node5> port 1025
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 131 KBytes 1.0 Mbits/sec 0.007 ms 0/ 91 (0%)
[ 3] 1.0- 2.0 sec 128 KBytes 1.0 Mbits/sec 0.008 ms 0/ 89 (0%)
[ 3] 2.0- 3.0 sec 128 KBytes 1.0 Mbits/sec 0.010 ms 0/ 89 (0%)
[ 3] 3.0- 4.0 sec 128 KBytes 1.0 Mbits/sec 0.013 ms 0/ 89 (0%)
[ 3] 4.0- 5.0 sec 128 KBytes 1.0 Mbits/sec 0.008 ms 0/ 89 (0%)
[ 3] 0.0- 5.0 sec 642 KBytes 1.0 Mbits/sec 0.008 ms 0/ 447 (0%)
node6> iperf -s -u -B 224.0.67.67 -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 224.0.67.67
Joining multicast group 224.0.67.67
Receiving 1470 byte datagrams
UDP buffer size: 60.0 KByte (default)
------------------------------------------------------------
[ 3] local 224.0.67.67 port 5001 connected with <IP Addr node5> port 1025
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 129 KBytes 1.0 Mbits/sec 0.778 ms 61/ 151 (40%)
[ 3] 1.0- 2.0 sec 128 KBytes 1.0 Mbits/sec 0.236 ms 0/ 89 (0%)
[ 3] 2.0- 3.0 sec 128 KBytes 1.0 Mbits/sec 0.264 ms 0/ 89 (0%)
[ 3] 3.0- 4.0 sec 128 KBytes 1.0 Mbits/sec 0.248 ms 0/ 89 (0%)
[ 3] 0.0- 4.3 sec 554 KBytes 1.0 Mbits/sec 0.298 ms 61/ 447 (14%)
如上所述启动多个客户端或服务器,将数据发送到同一组播服务器。 (如果有多个服务器侦听组播地址,则每个服务器都将获取数据)
使用“ifconfig”命令获取节点的 IPv6 地址。
使用 -V 选项指示您正在使用 IPv6 地址 请注意,我们还需要显式绑定服务器地址。
服务端:
$ iperf -s -V
客户端:
$ iperf -c <服务器IPv6地址> -V>
注意:iPerf 版本 1.6.2 和 eariler 需要显式绑定 IPv6 地址 替换为 -B
选项。
使用 -F
或 -I
选项。如果要测试网络的性能 对于压缩/未压缩的流,只需创建具有代表性的流和 使用 -F 选项对其进行测试。这通常是由于链路层造成的 压缩数据。
-F
选项用于文件输入。
-I
选项用于来自 stdin 的输入。
例如,
客户端:$ iperf -c <服务器地址> -F <文件名>
客户端:$ iperf -c <服务器地址> -I
使用 -D
命令行选项将服务器作为守护程序运行。重定向 输出到文件。
例如 iperf -s -D > iperflog
。这将使 iPerf 服务器运行 作为守护程序,服务器消息将记录在文件 iperfLog 中。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。