Home Archives Categories Tags

网络测速工具 iperf3 命令使用

发布时间: 更新时间: 总字数:1208 阅读时间:3m 作者: 分享

在 Linux 系统中,经常需要判断网络状况,如网卡最大速率,本文重点介绍如何使用网络测速工具 iperf3。

安装

iperf3安装iperf3下载:https://iperf.fr/iperf-download.php#fedora

[root@xiexianbin-cn ~]# rpm -ivh iperf3-3.1.3-1.fc24.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:iperf3-3.1.3-1.fc24              ################################# [100%]
[root@xiexianbin-cn ~]# 

服务器端

[root@xiexianbin-cn ~]# iperf3  -s

客户端

[root@xiexianbin-cn ~]# iperf3 -c 192.168.8.80
Connecting to host 192.168.8.80, port 5201
[  4] local 192.168.8.80 port 46422 connected to 192.168.8.80 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  3.89 GBytes  33.4 Gbits/sec    0   2.00 MBytes       
[  4]   1.00-2.00   sec  3.35 GBytes  28.8 Gbits/sec    0   2.00 MBytes       
[  4]   2.00-3.00   sec  4.35 GBytes  37.4 Gbits/sec    0   2.00 MBytes       
[  4]   3.00-4.00   sec  4.19 GBytes  36.0 Gbits/sec    0   2.00 MBytes       
[  4]   4.00-5.00   sec  4.32 GBytes  37.1 Gbits/sec    0   2.00 MBytes       
[  4]   5.00-6.00   sec  4.15 GBytes  35.6 Gbits/sec    0   2.00 MBytes       
[  4]   6.00-7.00   sec  3.61 GBytes  30.9 Gbits/sec    3   2.00 MBytes       
[  4]   7.00-8.00   sec  4.02 GBytes  34.7 Gbits/sec    0   2.00 MBytes       
[  4]   8.00-9.00   sec  3.97 GBytes  34.1 Gbits/sec    0   2.00 MBytes       
[  4]   9.00-10.00  sec  4.45 GBytes  38.3 Gbits/sec    0   2.00 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  40.3 GBytes  34.6 Gbits/sec    3             sender
[  4]   0.00-10.00  sec  40.3 GBytes  34.6 Gbits/sec                  receiver

iperf Done.
[root@xiexianbin-cn ~]# 

解释:
默认情况客户端使用TCP协议

  • -s:指明是服务器端
  • -c: 指明是客户端
  • 192.168.8.80: 为服务端IP地址

    [root@xiexianbin-cn ~]# iperf3 -u -c 192.168.8.80 -b 100M
    Connecting to host 192.168.8.80, port 5201
    [  4] local 192.168.8.80 port 33151 connected to 192.168.8.80 port 5201
    [ ID] Interval           Transfer     Bandwidth       Total Datagrams
    [  4]   0.00-1.01   sec  10.9 MBytes  91.1 Mbits/sec  1401  
    [  4]   1.01-2.01   sec  11.8 MBytes  98.4 Mbits/sec  1505  
    [  4]   2.01-3.01   sec  11.9 MBytes   100 Mbits/sec  1528  
    [  4]   3.01-4.01   sec  11.9 MBytes   100 Mbits/sec  1526  
    [  4]   4.01-5.01   sec  12.1 MBytes   102 Mbits/sec  1545  
    [  4]   5.01-6.00   sec  11.8 MBytes  99.7 Mbits/sec  1514  
    [  4]   6.00-7.01   sec  11.9 MBytes  98.7 Mbits/sec  1519  
    [  4]   7.01-8.01   sec  11.9 MBytes  99.7 Mbits/sec  1525  
    [  4]   8.01-9.01   sec  12.0 MBytes   100 Mbits/sec  1530  
    [  4]   9.01-10.01  sec  11.9 MBytes   100 Mbits/sec  1527  
    - - - - - - - - - - - - - - - - - - - - - - - - -
    [ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
    [  4]   0.00-10.01  sec   118 MBytes  98.9 Mbits/sec  0.162 ms  12468/14993 (83%)  
    [  4] Sent 14993 datagrams
    
    iperf Done.
    [root@xiexianbin-cn ~]# 
    

解释:

  • -u:指定是udp报文
  • -b:指定发送带宽大小。


服务器端:

[root@xiexianbin-cn ~]# iperf3 -u -c 192.168.8.80 -b 100M -p 2480
Connecting to host 192.168.8.80, port 2480
[  4] local 192.168.8.80 port 36328 connected to 192.168.8.80 port 2480
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec  10.8 MBytes  90.8 Mbits/sec  1387  
[  4]   1.00-2.00   sec  11.9 MBytes   100 Mbits/sec  1527  
[  4]   2.00-3.00   sec  11.9 MBytes   100 Mbits/sec  1527  
[  4]   3.00-4.01   sec  12.0 MBytes   100 Mbits/sec  1531  
[  4]   4.01-5.01   sec  11.9 MBytes  99.9 Mbits/sec  1528  
[  4]   5.01-6.01   sec  11.8 MBytes  98.6 Mbits/sec  1513  
[  4]   6.01-7.02   sec  11.9 MBytes   100 Mbits/sec  1527  
[  4]   7.02-8.02   sec  11.9 MBytes  99.9 Mbits/sec  1526  
[  4]   8.02-9.01   sec  12.0 MBytes   102 Mbits/sec  1536  
[  4]   9.01-10.01  sec  11.8 MBytes  98.6 Mbits/sec  1513  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-10.01  sec   118 MBytes  98.9 Mbits/sec  0.045 ms  12067/14982 (81%)  
[  4] Sent 14982 datagrams

iperf Done.
[root@xiexianbin-cn ~]# 

解释:

  • -p:指定端口

iperf3 –h 查看所有参数含义:

[root@xiexianbin-cn ~]# iperf3 -h
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
  -A, --affinity n/n,m      set CPU affinity
  -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
  -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'
  -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
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets
  --no-fq-socket-pacing     disable fair-queuing based socket pacing
                            (Linux only)

[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
[root@xiexianbin-cn ~]# 

完毕。

最新评论
加载中...