本文将介绍如何使用工具iperf进行带宽测试。
iperf是一个比较好用网络性能测试工具,可以测试最大TCP和UDP带宽性能,具有多种参数和UDP特性,可以根据需要调整,可以报告带宽、延迟抖动和数据包丢失。本文只介绍如何测试带宽。
(工具下载地址:https://pan.baidu.com/s/1c22exDu,密码:qnmg)
下载软件,解压,iperf3.exe就是我们将要使用的工具。
在两端测试PC上安装好工具。
在测试带宽之前,确保两端网络可达,确定可以ping通(如台式机ping不通注意Windows自带防火墙)。
首先是服务器端,打开CMD命令行,将iperf3.exe拖入到cmd命令行中,输入选项 -s,回车执行,如图:
这表示服务器端在等待客户端的请求。
此时在客户端PC上,同样打开CMD命令行,将iperf3.exe拖入到cmd命令行中,输入-c选项,并指定服务器IP地址,如图所示:
回车执行,就能够看到测试的带宽值。
下图是我自己测试的截图:
我测试的是一条运营商的100M链路,这里大家可以注意看一下,这里测出的单位是bits/sec,即比特/秒。我们平时下载时显示的速度是B/sec,即字节/每秒。读者注意这里的区别。
我把此软件支持的选项列出,有兴趣的小伙伴可以深入研究。
C:\Users\SCEIC>C:\Users\SCEIC\Desktop\iperf\iperf3.exe
iperf3: parameter error - must either be a client (-c) or server (-s)
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-F, --file name xmit/recv the specified file
-B, --bind <host> bind to a specific interface
-V, --verbose more detailed output
-J, --json output in JSON format
--logfile f send output to a log file
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-I, --pidfile file write PID file
-1, --one-off handle one client connection then exit
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-u, --udp use UDP rather than TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --len #[KMG] length of buffer to read or write
(default 128 KB for TCP, 8 KB for UDP)
--cport <port> bind to a specific client port (TCP and UDP, default
: ephemeral port)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes)
-N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service'
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
--udp-counters-64bit use 64-bit counters in UDP test packets
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: http://software.es.net/iperf/
Report bugs to: https://github.com/esnet/iperf