IPERF:如何测试网络速度,性能,带宽
无论在生产环境还是非生产环境中,都需要根据速度和带宽来测试网络性能。
速度和带宽分析的详细报告对于部署依赖网络的应用程序服务器非常必要。
同样,有时在进行故障排除时,我们需要仔细检查网络吞吐量的速度。
所有这些都需要可靠的网络性能测试工具。
这篇文章将专注于一种称为“ iperf”的工具。
IPERF是一个开放源代码工具,可用于测试网络性能。
与许多其他在线网络速度测试提供商相比,Iperf的测试结果更加可靠。
使用IPERF来测试网络性能的另一个好处是,如果我们在地理位置上不同的两台服务器,并且想要测量它们之间的网络性能,则这是非常可靠的。
如何安装iperf?
如果启用了epel yum存储库(在redhat系统中),则安装iperf非常容易。
[root@theitroad1 ~]# yum install iperf ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: iperf i386 2.0.5-1.el5 epel 52 k
从源代码安装iperf也非常容易。
只需从Iperf源代码包下载iperf源代码包
并按照以下步骤进行常规源安装。
#tar -xvf iperf-2.0.5.tar.gz
上面的命令将提取我们从上面的链接下载的tar包。
现在进入解压缩的目录,并运行以下命令以使用默认选项进行配置。
[root@theitroad2 ~]# cd iperf-2.0.5 [root@theitroad2 iperf-2.0.5]# ./configure
现在,使用“ make”命令对其进行编译,然后使用“ make install”命令进行安装。
[root@theitroad2 iperf-2.0.5]# make [root@theitroad2 iperf-2.0.5]# make install
如何在Windows机器上安装iperf?
在Windows中安装iperf也很容易。
让我们看看如何。
我们可以从Windows的Iperf下载Windows的iperf。
现在,将此zip文件解压缩到名为“ iperf”的文件夹,然后在该目录中运行iperf.exe。
例如,我提取了C:\iperf目录中的iperf zip,因此将打开Windows CMD,并导航到该目录,以运行iperf.exe命令。
C:\>cd C:\iperf C:\iperf>iperf.exe
如何测试一台Windows计算机和一台Linux计算机之间的网络速度?
如前所述,iperf可用于在远程计算机之间执行速度测试。
它在客户端服务器模型中工作。
我们可能已经注意到,与正常的操作系统下载器相比,某些Internet下载管理器在从Internet下载任何内容时是如此之快。
其背后的主要原因是它们可以在“并行TCP连接”上工作。
我记得其中一个这样的下载管理器是“ Internet下载管理器”。
让我们通过使用“ iperf”增加并行连接的数量来检查吞吐量报告。
[root@theitroad2 ~]# iperf -c 192.168.0.100 -P 20 ----------------------------------------------------------- Client connecting to 192.168.0.100, TCP port 5001 TCP window size: 16.0 KByte (default) ----------------------------------------------------------- [ 15] local 192.168.0.102 port 57258 connected with 192.168.0.100 port 5001 [ 3] local 192.168.0.102 port 57246 connected with 192.168.0.100 port 5001 [ 4] local 192.168.0.102 port 57247 connected with 192.168.0.100 port 5001 [ 5] local 192.168.0.102 port 57248 connected with 192.168.0.100 port 5001 [ 7] local 192.168.0.102 port 57250 connected with 192.168.0.100 port 5001 [ 6] local 192.168.0.102 port 57249 connected with 192.168.0.100 port 5001 [ 10] local 192.168.0.102 port 57253 connected with 192.168.0.100 port 5001 [ 8] local 192.168.0.102 port 57251 connected with 192.168.0.100 port 5001 [ 9] local 192.168.0.102 port 57252 connected with 192.168.0.100 port 5001 [ 16] local 192.168.0.102 port 57259 connected with 192.168.0.100 port 5001 [ 19] local 192.168.0.102 port 57261 connected with 192.168.0.100 port 5001 [ 18] local 192.168.0.102 port 57260 connected with 192.168.0.100 port 5001 [ 20] local 192.168.0.102 port 57262 connected with 192.168.0.100 port 5001 [ 17] local 192.168.0.102 port 57263 connected with 192.168.0.100 port 5001 [ 21] local 192.168.0.102 port 57264 connected with 192.168.0.100 port 5001 [ 11] local 192.168.0.102 port 57254 connected with 192.168.0.100 port 5001 [ 12] local 192.168.0.102 port 57255 connected with 192.168.0.100 port 5001 [ 13] local 192.168.0.102 port 57256 connected with 192.168.0.100 port 5001 [ 14] local 192.168.0.102 port 57257 connected with 192.168.0.100 port 5001 [ 22] local 192.168.0.102 port 57265 connected with 192.168.0.100 port 5001 [ ID] Interval Transfer Bandwidth [ 8] 0.0-10.6 sec 16.6 MBytes 13.1 Mbits/sec [ 16] 0.0-10.6 sec 16.6 MBytes 13.1 Mbits/sec [ 18] 0.0-10.6 sec 16.5 MBytes 13.1 Mbits/sec [ 17] 0.0-10.7 sec 16.6 MBytes 13.0 Mbits/sec [ 21] 0.0-10.7 sec 15.6 MBytes 12.3 Mbits/sec [ 12] 0.0-10.7 sec 17.5 MBytes 13.7 Mbits/sec [ 22] 0.0-10.7 sec 16.6 MBytes 13.0 Mbits/sec [ 15] 0.0-10.8 sec 17.8 MBytes 13.8 Mbits/sec [ 3] 0.0-10.7 sec 18.5 MBytes 14.5 Mbits/sec [ 4] 0.0-10.8 sec 18.1 MBytes 14.1 Mbits/sec [ 5] 0.0-10.7 sec 17.6 MBytes 13.9 Mbits/sec [ 7] 0.0-10.8 sec 18.4 MBytes 14.3 Mbits/sec [ 6] 0.0-10.8 sec 17.0 MBytes 13.2 Mbits/sec [ 10] 0.0-10.8 sec 16.8 MBytes 13.1 Mbits/sec [ 9] 0.0-10.8 sec 16.8 MBytes 13.0 Mbits/sec [ 19] 0.0-10.6 sec 16.5 MBytes 13.0 Mbits/sec [ 20] 0.0-10.7 sec 16.5 MBytes 12.9 Mbits/sec [ 11] 0.0-10.7 sec 18.0 MBytes 14.0 Mbits/sec [ 13] 0.0-10.7 sec 17.8 MBytes 13.9 Mbits/sec [ 14] 0.0-10.8 sec 18.2 MBytes 14.1 Mbits/sec [SUM] 0.0-10.8 sec 344 MBytes 266 Mbits/sec
在上面显示的示例中,我告诉iperf客户端在数据传输时创建与远程主机的20个并行TCP连接。
如果观察输出,则可以清楚地看到客户机上的20个不同端口已连接到服务器上的默认5001端口。
而且所有连接的传输速率都不同,最终,我们获得了266Mbits/s的组合吞吐量(这比单个TCP连接要好得多)。
在iperf中进行UDP速度测试
使用iperf进行UDP速度测试将为我们提供有关网络的更多信息,这对于查找网络瓶颈非常有用。
正如我们之前所讨论的,不仅TCP窗口大小,而且网络参数(如以下)也影响连接期间实现的吞吐量。
- 乱序传递
- 网络抖动
- 丢包占总包数
为了进行iperf udp测试,我们需要使用-u选项启动服务器,以便在服务器端打开UDP端口5001.
C:\iperf>iperf.exe -s -u ----------------------------------------------------------- Server listening on UDP port 5001 Receiving 1470 byte datagrams UDP buffer size: 64.0 KByte (default) -----------------------------------------------------------
现在,让我们通过发送UDP流量开始从客户端进行数据传输。
[root@theitroad2 ~]# iperf -c 192.168.0.100 -u -b 100m ----------------------------------------------------------- Client connecting to 192.168.0.100, UDP port 5001 Sending 1470 byte datagrams UDP buffer size: 107 KByte (default) ----------------------------------------------------------- [ 3] local 192.168.0.102 port 50836 connected with 192.168.0.100 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 97.4 MBytes 81.7 Mbits/sec [ 3] Sent 69508 datagrams [ 3] Server Report: [ 3] 0.0-10.0 sec 97.4 MBytes 81.8 Mbits/sec 0.167 ms 49/69507 (0.07%) [ 3] 0.0-10.0 sec 1 datagrams received out-of-order [root@theitroad2 ~]#
在上面的示例中,我使用了-b选项来指定要使用的带宽(因为默认情况下,iperf UDP仅使用1Mbps,因此我建议我们使用全部可用带宽来了解一下)
-u选项还需要在客户端上用于指定UDP流量。
输出将告诉我们以下信息。
带宽= 81.7Mbits /秒
网络抖动= 0.167毫秒(网络抖动是数据报文周期性到达的时间偏差。
如果使用地球另一端的服务器进行测试,则iperf输出中可能会看到较高的抖动值。
)
乱序= 1个数据报
丢失/总计= 49/69508
0.07%的数据报丢失一点也不重要,实际上我们可以说我们获得了不错的网络数据包丢失率。
VOIP由于其语音通信而需要的数据报损失非常小。
较高的数据克丢失可能会完全中断调用。
因此,如果基础架构上有VOIP或者其他此类关键应用程序,则使用iperf进行UDP测试将非常有帮助。
我们可以使用以下命令获取与iperf相关的所有选项。
[root@theitroad2 ~]# iperf --help