QDS06 Iperf 测网速

简介: QDS (Quick Deployment Series)快速的部署一个软件。这次我们来部署 Iperf 。 Iperf 是一个网络性能测试工具。Iperf 可以测试最大 TCP 和 UDP 带宽性能,具有多种参数和 UDP 特性,可以根据需要调整,可以报告带宽、延迟抖动和数据包丢失。

QDS (Quick Deployment Series)快速的部署一个软件。这次我们来部署 Iperf 。

Iperf 是一个网络性能测试工具。Iperf 可以测试最大 TCP 和 UDP 带宽性能,具有多种参数和 UDP 特性,可以根据需要调整,可以报告带宽、延迟抖动和数据包丢失。

下载安装

yum 安装

如果可以正常使用 yum ,那么可以使用 yum 来安装 Iperf ,该软件包在 epel 源中,需要先安装 epel 。

yum install -y epel-release

yum install -y iperf

这样就安装好了 Iperf ,版本默认是 2.x 。

编译安装

如果所在机器无法正常使用 yum ,或者想要使用最新版本的 Iperf ,那么请选择编译安装,在编译前请确保该机器相关编译器已经正确安装且可以使用。

Iperf 开源在 Github,所以我们可以在 Github 上找到最新的源代码。

Github 仓库地址:https://github.com/esnet/iperf

Github 发布地址:https://github.com/esnet/iperf/releases

仓库里有最早的 2.0 (2007 年 8 月发布)到现在最新的 3.7 版本都有,我们以最新的 3.7 版本为例进行编译安装。

下载安装包并且解压

wget https://github.com/esnet/iperf/archive/3.7.tar.gz
tar -zxf 3.7.tar.gz -C iperf

编译

cd iperf
./configure 
make

到这里可以暂停一下,如果你只是一次性使用,那么就不需要继续了,你只要进入到 iperf/src 目录下,该目录下有一个 iperf3 的可执行文件,直接执行该文件,就可以运行 Iperf 并且镜像测试。

如果你希望以后使用更方便,那么你需要接着上边的步骤把编译好的 Iperf 安装到系统中。

make install 

这样你就可以在系统的任意位置运行 Iperf ,因为已经安装到了系统中。

简单测试

因为网络测试是两个点之间的网络,所以需要在两台机器上都部署 Iperf 。

我们的测试环境如下所示

node01 :192.168.0.2 用作 Server
node02 :192.168.0.3 用作 Client

在 Server 端启动 Server 服务

./iperf3 -s

在 Client 端启动 Client ,并且指定 Server 的 IP 地址。

./iperf3 -c 192.168.0.2

下面是测试过程中服务端的显示

[root@node01 src]# ./iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.3, port 36406
[  5] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36410
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  36.2 MBytes   304 Mbits/sec
[  5]   1.00-2.00   sec  47.6 MBytes   399 Mbits/sec
[  5]   2.00-3.00   sec  50.7 MBytes   425 Mbits/sec
[  5]   3.00-4.00   sec  47.4 MBytes   397 Mbits/sec
[  5]   4.00-5.00   sec  53.0 MBytes   444 Mbits/sec
[  5]   5.00-6.00   sec  45.8 MBytes   384 Mbits/sec
[  5]   6.00-7.00   sec  50.9 MBytes   427 Mbits/sec
[  5]   7.00-8.00   sec  53.4 MBytes   448 Mbits/sec
[  5]   8.00-9.00   sec  56.5 MBytes   474 Mbits/sec
[  5]   9.00-10.00  sec  47.8 MBytes   401 Mbits/sec
[  5]  10.00-10.29  sec  4.03 MBytes   118 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.29  sec   493 MBytes   402 Mbits/sec        receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

可以看到最后测试的结果是 402 Mbits/sec ,结果看 Bitrate 字段。

[root@node02 src]# ./iperf3 -c 192.168.0.2
Connecting to host 192.168.0.2, port 5201
[  5] local 192.168.0.3 port 36410 connected to 192.168.0.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  40.7 MBytes   341 Mbits/sec  2239   4.47 MBytes
[  5]   1.00-2.00   sec  48.8 MBytes   409 Mbits/sec  1925   4.73 MBytes
[  5]   2.00-3.00   sec  48.8 MBytes   409 Mbits/sec  1683   4.47 MBytes
[  5]   3.00-4.00   sec  47.5 MBytes   398 Mbits/sec  2364   2.44 MBytes
[  5]   4.00-5.00   sec  53.8 MBytes   451 Mbits/sec  1492   5.02 MBytes
[  5]   5.00-6.00   sec  45.0 MBytes   377 Mbits/sec  2556   4.46 MBytes
[  5]   6.00-7.00   sec  51.2 MBytes   430 Mbits/sec  1766   4.75 MBytes
[  5]   7.00-8.00   sec  52.5 MBytes   440 Mbits/sec  2159   2.28 MBytes
[  5]   8.00-9.00   sec  57.5 MBytes   482 Mbits/sec  1424   5.00 MBytes
[  5]   9.00-10.00  sec  47.5 MBytes   398 Mbits/sec  2358   4.36 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   493 MBytes   414 Mbits/sec  19966     sender
[  5]   0.00-10.29  sec   493 MBytes   402 Mbits/sec           receiver

iperf Done.
[root@node02 src]#

从客户端来看,测试结果约是 400 Mbits/sec ,结果看 Bitrate 的值。

可以使用 -P 参数指定多个进程来压测带宽,使得达到该线路的极限。

服务端显示如下所示,

^@Accepted connection from 192.168.0.3, port 36434
[  5] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36436
[  8] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36438
[ 10] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36440
[ 12] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36442
[ 14] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36444
[ 16] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36446
[ 18] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36448
[ 20] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36450
[ 22] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36452
[ 24] local 192.168.0.2 port 5201 connected to 192.168.0.3 port 36454
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  8.06 MBytes  67.6 Mbits/sec
[  8]   0.00-1.00   sec  7.84 MBytes  65.7 Mbits/sec
[ 10]   0.00-1.00   sec  9.01 MBytes  75.6 Mbits/sec
[ 12]   0.00-1.00   sec  8.68 MBytes  72.8 Mbits/sec
[ 14]   0.00-1.00   sec  8.65 MBytes  72.6 Mbits/sec
[ 16]   0.00-1.00   sec  8.14 MBytes  68.2 Mbits/sec
[ 18]   0.00-1.00   sec  8.04 MBytes  67.5 Mbits/sec
[ 20]   0.00-1.00   sec  8.76 MBytes  73.5 Mbits/sec
[ 22]   0.00-1.00   sec  8.44 MBytes  70.8 Mbits/sec
[ 24]   0.00-1.00   sec  8.64 MBytes  72.5 Mbits/sec
[SUM]   0.00-1.00   sec  84.3 MBytes   707 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
省略部分测试过程。
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]  10.00-10.26  sec  2.71 MBytes  86.5 Mbits/sec
[  8]  10.00-10.26  sec  2.76 MBytes  88.2 Mbits/sec
[ 10]  10.00-10.26  sec  2.63 MBytes  84.1 Mbits/sec
[ 12]  10.00-10.26  sec  3.56 MBytes   113 Mbits/sec
[ 14]  10.00-10.26  sec  1.43 MBytes  45.7 Mbits/sec
[ 16]  10.00-10.26  sec  1.50 MBytes  47.8 Mbits/sec
[ 18]  10.00-10.26  sec  3.54 MBytes   113 Mbits/sec
[ 20]  10.00-10.26  sec  3.79 MBytes   121 Mbits/sec
[ 22]  10.00-10.26  sec   645 KBytes  20.1 Mbits/sec
[ 24]  10.00-10.26  sec  2.92 MBytes  93.2 Mbits/sec
[SUM]  10.00-10.26  sec  25.5 MBytes   813 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.26  sec   107 MBytes  87.3 Mbits/sec        receiver
[  8]   0.00-10.26  sec   107 MBytes  87.6 Mbits/sec        receiver
[ 10]   0.00-10.26  sec   107 MBytes  87.8 Mbits/sec        receiver
[ 12]   0.00-10.26  sec   113 MBytes  92.2 Mbits/sec        receiver
[ 14]   0.00-10.26  sec   108 MBytes  88.6 Mbits/sec        receiver
[ 16]   0.00-10.26  sec   106 MBytes  86.6 Mbits/sec        receiver
[ 18]   0.00-10.26  sec   110 MBytes  90.0 Mbits/sec        receiver
[ 20]   0.00-10.26  sec   111 MBytes  91.0 Mbits/sec        receiver
[ 22]   0.00-10.26  sec   107 MBytes  87.1 Mbits/sec        receiver
[ 24]   0.00-10.26  sec   112 MBytes  91.2 Mbits/sec        receiver
[SUM]   0.00-10.26  sec  1.06 GBytes   889 Mbits/sec        receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
^Ciperf3: interrupt - the server has terminated

在服务端可以看到在使用 10 个进程压测以后,总带宽是 889 Mbits/sec ,已经比较接近千兆网线的物理极限了。测试结果看最后的 SUM 行,Bitrate 的值。

客户端的显示如下所示。

[root@node02 src]# ./iperf3 -c 192.168.0.2 -P 10
Connecting to host 192.168.0.2, port 5201
[  5] local 192.168.0.3 port 36436 connected to 192.168.0.2 port 5201
[  7] local 192.168.0.3 port 36438 connected to 192.168.0.2 port 5201
[  9] local 192.168.0.3 port 36440 connected to 192.168.0.2 port 5201
[ 11] local 192.168.0.3 port 36442 connected to 192.168.0.2 port 5201
[ 13] local 192.168.0.3 port 36444 connected to 192.168.0.2 port 5201
[ 15] local 192.168.0.3 port 36446 connected to 192.168.0.2 port 5201
[ 17] local 192.168.0.3 port 36448 connected to 192.168.0.2 port 5201
[ 19] local 192.168.0.3 port 36450 connected to 192.168.0.2 port 5201
[ 21] local 192.168.0.3 port 36452 connected to 192.168.0.2 port 5201
[ 23] local 192.168.0.3 port 36454 connected to 192.168.0.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  11.6 MBytes  97.7 Mbits/sec  308    718 KBytes
[  7]   0.00-1.00   sec  10.4 MBytes  86.9 Mbits/sec  260    696 KBytes
[  9]   0.00-1.00   sec  11.6 MBytes  97.3 Mbits/sec  313    749 KBytes
[ 11]   0.00-1.00   sec  11.6 MBytes  97.3 Mbits/sec  304    673 KBytes
[ 13]   0.00-1.00   sec  12.4 MBytes   104 Mbits/sec  308    662 KBytes
[ 15]   0.00-1.00   sec  11.5 MBytes  96.6 Mbits/sec  309    650 KBytes
[ 17]   0.00-1.00   sec  11.3 MBytes  94.9 Mbits/sec  307    634 KBytes
[ 19]   0.00-1.00   sec  11.4 MBytes  95.4 Mbits/sec  352    650 KBytes
[ 21]   0.00-1.00   sec  11.6 MBytes  97.3 Mbits/sec  289    724 KBytes
[ 23]   0.00-1.00   sec  11.5 MBytes  96.7 Mbits/sec  410    650 KBytes
[SUM]   0.00-1.00   sec   115 MBytes   964 Mbits/sec  3160
- - - - - - - - - - - - - - - - - - - - - - - - -
  省略部分测试过程。
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   9.00-10.00  sec  10.0 MBytes  83.9 Mbits/sec  212    707 KBytes
[  7]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec  248   1.04 MBytes
[  9]   9.00-10.00  sec  10.0 MBytes  83.9 Mbits/sec  252   5.66 KBytes
[ 11]   9.00-10.00  sec  12.5 MBytes   105 Mbits/sec  169   1.10 MBytes
[ 13]   9.00-10.00  sec  10.0 MBytes  83.9 Mbits/sec  201   5.66 KBytes
[ 15]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec  203   5.66 KBytes
[ 17]   9.00-10.00  sec  12.5 MBytes   105 Mbits/sec  217   1.36 MBytes
[ 19]   9.00-10.00  sec  12.5 MBytes   105 Mbits/sec  195   1.24 MBytes
[ 21]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec  222   5.66 KBytes
[ 23]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec  247   1.21 MBytes
[SUM]   9.00-10.00  sec   112 MBytes   944 Mbits/sec  2166
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   108 MBytes  90.5 Mbits/sec  2700      sender
[  5]   0.00-10.26  sec   107 MBytes  87.3 Mbits/sec           receiver
[  7]   0.00-10.00  sec   108 MBytes  90.5 Mbits/sec  2914      sender
[  7]   0.00-10.26  sec   107 MBytes  87.6 Mbits/sec           receiver
[  9]   0.00-10.00  sec   108 MBytes  90.5 Mbits/sec  2697      sender
[  9]   0.00-10.26  sec   107 MBytes  87.8 Mbits/sec           receiver
[ 11]   0.00-10.00  sec   113 MBytes  94.7 Mbits/sec  2427      sender
[ 11]   0.00-10.26  sec   113 MBytes  92.2 Mbits/sec           receiver
[ 13]   0.00-10.00  sec   110 MBytes  92.2 Mbits/sec  2674      sender
[ 13]   0.00-10.26  sec   108 MBytes  88.6 Mbits/sec           receiver
[ 15]   0.00-10.00  sec   108 MBytes  90.4 Mbits/sec  2719      sender
[ 15]   0.00-10.26  sec   106 MBytes  86.6 Mbits/sec           receiver
[ 17]   0.00-10.00  sec   110 MBytes  92.3 Mbits/sec  2908      sender
[ 17]   0.00-10.26  sec   110 MBytes  90.0 Mbits/sec           receiver
[ 19]   0.00-10.00  sec   111 MBytes  93.4 Mbits/sec  2650      sender
[ 19]   0.00-10.26  sec   111 MBytes  91.0 Mbits/sec           receiver
[ 21]   0.00-10.00  sec   109 MBytes  91.5 Mbits/sec  2616      sender
[ 21]   0.00-10.26  sec   107 MBytes  87.1 Mbits/sec           receiver
[ 23]   0.00-10.00  sec   112 MBytes  93.6 Mbits/sec  3176      sender
[ 23]   0.00-10.26  sec   112 MBytes  91.2 Mbits/sec           receiver
[SUM]   0.00-10.00  sec  1.07 GBytes   920 Mbits/sec  27481     sender
[SUM]   0.00-10.26  sec  1.06 GBytes   889 Mbits/sec           receiver

iperf Done.
[root@node02 src]#

看最后的测试结果,可以发现,网络带宽在 900 Mbits/sec ,其中 sender 的带宽是 920 Mbits/sec ,receiver 带宽是 889 Mbits/sec 。测试结果看 SUM 行,Bitrate 的值。

说明:
该测试只测试了 TCP 的网络带宽,更多详细的测试请关注本博客,后续会放出。
通过 Server 端和 Client 的测试结果来看,两者的结果一致,只要关注 Client 的结果即可。

附录 -help 参数

[root@node01 src]$ ./iperf3 -h
Usage: iperf3 [-s|-c host] [options]
       iperf3 [-h|--help] [-v|--version]

Server or Client:
  -p, --port      #         server port to listen on/connect to
  -f, --format   [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits
  -i, --interval  #         seconds between periodic throughput reports
  -F, --file name           xmit/recv the specified file
  -A, --affinity n/n,m      set CPU affinity
  -B, --bind      <host>    bind to the interface associated with the address <host>
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  --logfile f               send output to a log file
  --forceflush              force flushing output at every interval
  -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
  --rsa-private-key-path    path to the RSA private key used to decrypt
                            authentication credentials
  --authorized-users-path   path to the configuration file containing user
                            credentials
Client specific:
  -c, --client    <host>    run in client mode, connecting to <host>
  -u, --udp                 use UDP rather than TCP
  --connect-timeout #       timeout for control connection setup (ms)
  -b, --bitrate #[KMG][/#]  target bitrate in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  --pacing-timer #[KMG]     set the timing for pacing, in microseconds (default 1000)
  --fq-rate #[KMG]          enable fair-queuing based socket pacing in
                            bits/sec (Linux only)
  -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, --length    #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, dynamic or 1460 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)
  --bidir                   run in bidirectional mode.
                            Client and server send and receive data.
  -w, --window    #[KMG]    set window size / socket buffer size
  -C, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)
  -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, 0-255.
                            The usual prefixes for octal and hex can be used,
                            i.e. 52, 064 and 0x34 all specify the same value.
  --dscp N or --dscp val    set the IP dscp value, either 0-63 or symbolic.
                            Numeric values can be specified in decimal,
                            octal and hex (see --tos above).
  -L, --flowlabel N         set the IPv6 flow label (only supported on Linux)
  -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
  --extra-data str          data string to include in client and server JSON
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets
  --repeating-payload       use repeating pattern in payload, instead of
                            randomized payload (like in iperf2)
  --username                username for authentication
  --rsa-public-key-path     path to the RSA public key used to encrypt
                            authentication credentials

[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-

iperf3 homepage at: https://software.es.net/iperf/
Report bugs to:     https://github.com/esnet/iperf
[root@node01 src]$
相关文章
|
网络协议 5G Linux
iperf3 万兆测试
iperf3 万兆测试
475 0
iperf3 万兆测试
|
网络协议 网络虚拟化 Windows
测试vpn设备 带宽,丢包率windows使用iperf3
iPerf3是用于主动测试IP网络上最大可用带宽的工具。它支持时序、缓冲区、协议(TCP,UDP,SCTP与IPv4和IPv6)有关的各种参数。对于每次测试,它都会详细的带宽报告,延迟抖动和数据包丢失。
641 0
测试vpn设备 带宽,丢包率windows使用iperf3
测试服务器在本地下载速度
测试服务器在本地下载速度
140 0
|
Windows
Windows系统查看各个进程网速的软件(查看网速工具)
Windows系统查看各个进程网速的软件(查看网速工具)
701 0
|
5G Linux Python
使用Speedtest CLI测试你的网速
使用Speedtest CLI测试你的网速
使用Speedtest CLI测试你的网速
|
网络安全
RAKsmart检测网速和跟踪路由功能怎么用?
RAKsmart近年来在国内受到很多站长的欢迎,虽说RAKsmart主机商采取光纤接入、专线线路等等多种措施来提升国内的访问速度,但RAKsmart美国服务器毕竟都是位于美国机房,距离中国大陆较远,所以很多新手用户仍然对RAKsmart美国服务器的访问速度抱有怀疑态度。
770 0
|
Android开发 iOS开发

热门文章

最新文章