Iperf has two versions, windows version and linux version.
The linux version download address is: https://sourceforge.net/projects/iperf/files/jperf/jperf%202.0.0/
The download address of the windows version is: http://www.veryhuo.com/down/html/159693.html
The main functions of Iperf are as follows:
The main functions of Iperf are as follows:
TCP
-
Measure network bandwidth
-
Report size and observations of MSS/MTU values
-
Support for TCP window values via socket buffering
-
Multithreading is supported when P threads or Win32 threads are available. Client and server support simultaneous multiple connections
UDP
-
Clients can create UDP streams of specified bandwidth
-
Measure packet loss
-
Measurement delay
-
Multicast support
-
Multithreading is supported when P threads are available. Client and server support simultaneous multiple connections (does not support Windows)
other
-
Where appropriate, K (kilo-) and M (mega-) can be used in options. For example 131072 bytes can be replaced by 128K.
-
The total time to run can be specified, and even the total amount of data transferred can be set.
-
In the report, choose the most appropriate units for the data.
-
The server supports multiple connections instead of waiting for a single-threaded test.
-
Repeated display of network bandwidth, fluctuations and packet loss at specified time intervals.
-
The server side can run as a background program.
-
The server side can run as a Windows service.
-
Use a typical data flow to test the effect of link-layer compression on available bandwidth.
-
Supports the transfer of specified files, which can be tested qualitatively and quantitatively
How to use Iperf
-
Install Iperf
-
For the Windows version of Iperf, simply copy the decompressed iperf.exe and cygwin1.dll to the %systemroot% directory.
-
For linux version of Iperf, please use the following command to install
gunzip -c iperf-<version>.tar.gz | tar -xvf -
cd iperf-<version>
./configure
make
make install
-
-
Use Iperf (take the windows version as an example)
Enter the iperf command in the command prompt to run Iperf, use the command Iperf –help to view the help of iperf
command line options |
describe |
Client and server sharing options |
|
-f, --format [bkmaBKMA] |
格式化带宽数输出。支持的格式有: |
-i, --interval # |
设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。 |
-l, --len #[KM] |
设置读写缓冲区的长度。TCP方式默认为8KB,UDP方式默认为1470字节。 |
-m, --print_mss |
输出TCP MSS值(通过TCP_MAXSEG支持)。MSS值一般比MTU值小40字节。通常情况 |
-p, --port # |
设置端口,与服务器端的监听端口一致。默认是5001端口,与ttcp的一样。 |
-u, --udp |
使用UDP方式而不是TCP方式。参看-b选项。 |
-w, --window #[KM] |
设置套接字缓冲区为指定大小。对于TCP方式,此设置为TCP窗口大小。对于UDP方式,此设置为接受UDP数据包的缓冲区大小,限制可以接受数据包的最大值。 |
-B, --bind host |
绑定到主机的多个地址中的一个。对于客户端来 说,这个参数设置了出栈接口。对于服务器端来说,这个参数设置入栈接口。这个参数只用于具有多网络接口的主机。在Iperf的UDP模式下,此参数用于绑 定和加入一个多播组。使用范围在224.0.0.0至239.255.255.255的多播地址。参考-T参数。 |
-C, --compatibility |
与低版本的Iperf使用时,可以使用兼容模式。不需要两端同时使用兼容模式,但是强烈推荐两端同时使用兼容模式。某些情况下,使用某些数据流可以引起1.7版本的服务器端崩溃或引起非预期的连接尝试。 |
-M, --mss #[KM} |
通过TCP_MAXSEG选项尝试设置TCP最大信息段的值。MSS值的大小通常是TCP/IP头减去40字节。在以太网中,MSS值 为1460字节(MTU1500字节)。许多操作系统不支持此选项。 |
-N, --nodelay |
设置TCP无延迟选项,禁用Nagle's运算法则。通常情况此选项对于交互程序,例如telnet,是禁用的。 |
-V (from v1.6 or higher) |
绑定一个IPv6地址。 |
服务器端专用选项 |
|
-s, --server |
Iperf服务器模式 |
-D (v1.2或更高版本) |
Unix平台下Iperf作为后台守护进程运行。在Win32平台下,Iperf将作为服务运行。 |
-R(v1.2或更高版本,仅用于Windows) |
卸载Iperf服务(如果它在运行)。 |
-o(v1.2或更高版本,仅用于Windows) |
重定向输出到指定文件 |
-c, --client host |
如果Iperf运行在服务器模式,并且用-c参数指定一个主机,那么Iperf将只接受指定主机的连接。此参数不能工作于UDP模式。 |
-P, --parallel # |
服务器关闭之前保持的连接数。默认是0,这意味着永远接受连接。 |
客户端专用选项 |
|
-b, --bandwidth #[KM] |
UDP模式使用的带宽,单位bits/sec。此选项与-u选项相关。默认值是1 Mbit/sec。 |
-c, --client host |
运行Iperf的客户端模式,连接到指定的Iperf服务器端。 |
-d, --dualtest |
运行双测试模式。这将使服务器端反向连接到客户端,使用-L 参数中指定的端口(或默认使用客户端连接到服务器端的端口)。这些在操作的同时就立即完成了。如果你想要一个交互的测试,请尝试-r参数。 |
-n, --num #[KM] |
传送的缓冲器数量。通常情况,Iperf按照10秒钟发送数据。-n参数跨越此限制,按照指定次数发送指定长度的数据,而不论该操作耗费多少时间。参考-l与-t选项。 |
-r, --tradeoff |
往复测试模式。当客户端到服务器端的测试结束时,服务器端通过-l选项指定的端口(或默认为客户端连接到服务器端的端口),反向连接至客户端。当客户端连接终止时,反向连接随即开始。如果需要同时进行双向测试,请尝试-d参数。 |
-t, --time # |
设置传输的总时间。Iperf在指定的时间内,重复的发送指定长度的数据包。默认是10秒钟。参考-l与-n选项。 |
-L, --listenport # |
指定服务端反向连接到客户端时使用的端口。默认使用客户端连接至服务端的端口。 |
-P, --parallel # |
线程数。指定客户端与服务端之间使用的线程数。默认是1线程。需要客户端与服务器端同时使用此参数。 |
-S, --tos # |
Type of service for outgoing packets. Many routers ignore the TOS field. You can specify this value using hexadecimal numbers starting with "0x", or octal or decimal numbers starting with "0". |
-T, --ttl # |
The TTL value of the outgoing multicast packet. This is essentially the number of hops the data takes through the router. The default is 1, link-local. |
-F (from v1.2 or higher) |
Bandwidth is measured using a specific data stream, such as a specified file. |
-I (from v1.2 or higher) |
As with -F, input data from standard input and output files. |
Miscellaneous |
|
-h, --help |
Display the command line reference and exit. |
-v, --version |
Display version information and build information and exit. |
The bandwidth test usually adopts the UDP mode, because it can measure the limit bandwidth, delay jitter, and packet loss rate. When testing, firstly use the theoretical bandwidth of the link as the data transmission rate to test, for example, the theoretical bandwidth of the link from the client to the server is 100Mbps, first test with -b 100M, and then according to the test results (including Actual bandwidth, delay jitter and packet loss rate), and then use the actual bandwidth as the data transmission rate to test, you will find that the delay jitter and packet loss rate are much better than the first time, repeat the test several times, you can get a stable actual bandwidth.
UDP mode
服务器端:
iperf -s -u -w 4m -i 1 -p 5008
客户端:
iperf -u -c 192.168.1.1 -b 100M -t 60
在udp模式下,以100Mbps为数据发送速率,客户端到服务器192.168.1.1上传带宽测试,测试时间为60秒。
iperf -u -c 192.168.1.1 -b 5M -P 30 -t 60
客户端同时向服务器端发起30个连接线程,以5Mbps为数据发送速率。
iperf -u -c 192.168.1.1 -l 1024 -i 1 -t 12 -b 5M -p 5008
TCP模式
默认使用5001端口
服务器端:
iperf -s -i 1 -w 4m
客户端:
iperf -c 192.168.1.1 -t 60
在tcp模式下,客户端到服务器192.168.1.1上传带宽测试,测试时间为60秒。
组播模式
服务器
iperf -s -u -B 224.0.55.55 -i 1
客户端
iperf -c 224.0.55.55 -u -T 32 -t 10 -i 1 -b 1M