Linux 网络测速工具 iperf3 使用介绍

发布时间: 更新时间: 总字数:1174 阅读时间:3m 作者: IP上海 分享 网址

本文主要介绍 iperf3 的安装、使用。在 Linux 系统中,经常需要判断网络状况,如带宽(网卡最大速率),本文介绍如何使用网络测速工具 iperf3(旧称 iperf)命令测试网速。

安装

iperf3下载地址:https://iperf.fr/iperf-download.php#fedora

$ rpm -ivh iperf3-3.1.3-1.fc24.x86_64.rpm

help

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

$ 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

使用

服务器端

$ iperf3 -s -D

说明:

  • -s:指明是服务器端
  • -d:daemon 进程

客户端

$ iperf3 -c <server ip>
$ iperf3 -c <server ip> -b 100M -u
$ iperf3 -c <server ip> -b 100M -u -p 2480 -t 60 -P 4

说明:

  • -A:CPU亲和性,可以将具体的iperf3进程绑定对应编号的逻辑 CPU,避免iperf进程在不同的CPU间调度。
  • -c:指明是客户端,后跟连接的服务端地址
  • -b:指定发送带宽大小,UDP缺省为 1 Mbit/sec,TCP无限制
  • -f:format格式,可以是kKmMgG, A就是adaptive,类似于ls -h友好显示
  • -u:指定是udp报文,默认情况客户端使用TCP协议
  • -p:指定服务的监听端口
  • -t:测试的时长,单位秒
  • -P:并行客户端流的数量
  • -n:传输包的大小 bytes
  • -N:nodelay,禁用Nagle’s algorithm。
  • -w:设置套接字缓冲区大小,TCP 模式下为窗口大小。window size是作流控用的,避免发送端发的太快,接收端处理不过来(接收端在header里设置了一个window size,提示发送方未被ack的累积发送量不要超过window size)
  • -O:禁用 tcp slow start-O 3 表示忽略前三次请求
  • -i:间隔多久输出信息流量信息,默认单位为秒
  • -l:包大小,默认单位为Byte。通常测试PPS的时候该值为46,测试bps时该值为1500
  • -V:显示详细信息

测试结果指标

字段 含义
Transfer 传送的总数据量
Bandwidth 带宽大小
Jitter 波动率
Lost/Total 丢包/总报文数
Datagrams 丢包率
Retr(Retransmitted TCP segments) 重试传输TCP段,越大表示网络质量越差
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数