Iperf是一种用来测量网络带宽和网络质量的工具。
Jperf与Iperf一起使用的话可以提供一个java写成的图形界面。
两个运行Iperf的主机将网络分成了两份可以用以下方法测试连接的质量:- 延时(反应时间或者RTT):用ping命令量度- jitter(延时变化):用 Iperf UDP 测试来量度- 数据报丢失:用Iperf UDP 测试来量度带宽可以通过TCP测试来量度TCP (Transmission Control Protocol)与 UDP (User Datagram Protocol)的区别是:TCP检查数据包是否正确的传送给接受者,而UDP并不进行检查。
所以UDP 的传送速度比TCP要快。
Tperf使用TCP与UDP的不同功能来提供网络连接的统计数据。
最后,Iperf可以很容易的安装在任何UNIX/Linux或者Microsoft Windows系统中。
必须将一台主机设置为客户端,一台设置为服务器。
以下是Iperf安装在Linux以及Microsoft Windows系统中的截图。
在这里,Linux 是Iperf客户端,Windows是 Iperf服务器端。
当然,两个都用上Linux系统也是可以的。
Iperf tests:no arg. -b-r-d-w 缺省设置数据格式双向性带宽同步双向性带宽TCP窗口大小-p, -t, -i-u, -b-m-M-P端口,时间,间隔UDP测试,带宽设置显示最大片段大小最大片段大小设置平行测试-h帮助Jperf:no arg. -d-u, -b 缺省设置同步双向性带宽UDP测试,带宽设置缺省Iperf设置同时检查Jperf部分初始状态,Iperf客户端使用TCP端口5001来连接Iperf服务器,Iperf显示的带宽是从用户到服务器之间的带宽。
如果想使用UDP测试,使用-u参数。
Iperf客户端的-d> 和-r参数可以用来测量双向性带宽。
(详情见指导书)客户端#iperf -c 10.1.1.1------------------------------------------------------------Client connecting to 10.1.1.1, TCP port 5001TCP window size: 16384 Byte (default)------------------------------------------------------------[ 3] local 10.6.2.5 port 33453 connected with 10.1.1.1 port 5001 [ 3] 0.0-10.2 sec 1.26 MBytes 1.05 Mbits/sec服务器端#iperf -s------------------------------------------------------------Server listening on TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------ [852] local 10.1.1.1 port 5001 connected with 10.6.2.5 port 33453 [ ID] Interval Transfer Bandwidth[852] 0.0-10.6 sec 1.26 MBytes 1.03 Mbits/sec数据形式(-f参数)-f参数可以指定结果显示的格式: bits(b), bytes(B), kilobits(k), kilobytes(K), megabits(m), megabytes(M), gigabits(g) or gigabytes(G). 一般来说,带宽使用的单位是bits (或者 Kilobit,等等),大量的数据使用bytes (或者Kilobytes,等等)回顾一下,1 bytes等于8 bits,在电脑科学中,1 kilo等于1024(2的10次方)例如:100'000'000 bytes不等于100 Mbytes而是等于95.37 Mbytes(=100'000'000/1024/1024)客户端#iperf -c 10.1.1.1 -f b------------------------------------------------------------Client connecting to 10.1.1.1, TCP port 5001TCP window size: 16384 Byte (default)------------------------------------------------------------[ 3] local 10.6.2.5 port 54953 connected with 10.1.1.1 port 5001[ 3] 0.0-10.2 sec 1359872 Bytes 1064272 bits/sec服务器端#iperf -s------------------------------------------------------------Server listening on TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------[852] local 10.1.1.1 port 5001 connected with 10.6.2.5 port 33453 [ ID] Interval Transfer Bandwidth[852] 0.0-10.6 sec 920 KBytes 711 Kbits/secTop of the page双向带宽测量(-r 参数)为了量度双向带宽,Iperf服务器会主动向客户端发起连接。
初始状态时,只会量度客户到服务器的带宽。
如果你想同时测量双向带宽,请使用-d 关键字。
(见以下实验)客户端#iperf -c 10.1.1.1 -r------------------------------------------------------------Server listening on TCP port 5001TCP window size: 85.3 KByte (default)------------------------------------------------------------------------------------------------------------------------Client connecting to 10.1.1.1, TCP port 5001TCP window size: 16.0 KByte (default)------------------------------------------------------------[ 5] local 10.6.2.5 port 35726 connected with 10.1.1.1 port 5001 [ 5] 0.0-10.0 sec 1.12 MBytes 936 Kbits/sec[ 4] local 10.6.2.5 port 5001 connected with 10.1.1.1 port 1640 [ 4] 0.0-10.1 sec 74.2 MBytes 61.7 Mbits/sec服务器端#iperf -s------------------------------------------------------------Server listening on TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------ [852] local 10.1.1.1 port 5001 connected with 10.6.2.5 port 54355 [ ID] Interval Transfer Bandwidth[852] 0.0-10.1 sec 1.15 MBytes 956 Kbits/sec------------------------------------------------------------Client connecting to 10.6.2.5, TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------ [824] local 10.1.1.1 port 1646 connected with 10.6.2.5 port 5001 [ ID] Interval Transfer Bandwidth[824] 0.0-10.0 sec 73.3 MBytes 61.4 Mbits/secTop of the page同步双向性带宽测量(-d 参数)同时检查"Jperf"部分。
使用-d 参数同步测量双向带宽。
如果你想将测试分开进行,请使用-r参数(见前面测试)。
如果不加任何参数的话,只会量度从客户端到服务器端的带宽。
客户端#iperf -c 10.1.1.1 -d------------------------------------------------------------Server listening on TCP port 5001TCP window size: 85.3 KByte (default)------------------------------------------------------------------------------------------------------------------------Client connecting to 10.1.1.1, TCP port 5001TCP window size: 16.0 KByte (default)------------------------------------------------------------[ 5] local 10.6.2.5 port 60270 connected with 10.1.1.1 port 5001 [ 4] local 10.6.2.5 port 5001 connected with 10.1.1.1 port 2643 [ 4] 0.0-10.0 sec 76.3 MBytes 63.9 Mbits/sec[ 5] 0.0-10.1 sec 1.55 MBytes 1.29 Mbits/sec服务器端#iperf -s------------------------------------------------------------Server listening on TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------ [852] local 10.1.1.1 port 5001 connected with 10.6.2.5 port 60270 ------------------------------------------------------------Client connecting to 10.6.2.5, TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------ [800] local 10.1.1.1 port 2643 connected with 10.6.2.5 port 5001 [ ID] Interval Transfer Bandwidth[800] 0.0-10.0 sec 76.3 MBytes 63.9 Mbits/sec[852] 0.0-10.1 sec 1.55 MBytes 1.29 Mbits/secTop of the pageTCP窗口大小:(-w 参数)在连接中,如果接收方来不及验证,数据会暂时被存在一个缓冲区里。