• iperf3 测速


    iperf3 测速

    https://iperf.fr/iperf-doc.php

    https://github.com/esnet/iperf

    在 iPerf 2.0、iPerf 3.0 和 iPerf 3.1 之间切换

    • iPerf3 当前支持的 iPerf2 功能:
      • TCP 和 UDP 测试
      • 设置端口(-p)
      • 设置 TCP 选项:无延迟、MSS 等。
      • 设置 UDP 带宽 (-b)
      • 设置套接字缓冲区大小 (-w)
      • 报告间隔 (-i)
      • 设置 iPerf 缓冲区 (-l)
      • 绑定到特定接口 (-B)
      • IPv6 测试 (-6)
      • 要传输的字节数 (-n)
      • 测试长度 (-t)
      • 并行流 (-P)
      • 设置 DSCP/TOS 位向量 (-S)
      • 更改数字输出格式 (-f)
    • iPerf 3.0 中的新功能:
      • 动态服务器(客户端/服务器参数交换)——iPerf2 中的大多数服务器选项现在可以由客户端动态设置
      • 客户端/服务器结果交换
      • iPerf3 服务器同时接受单个客户端(iPerf2 同时接受多个客户端)
      • iPerf API (libiperf) – 提供一种简单的方法来使用、自定义和扩展 iPerf 功能
      • -R,反向测试模式——服务器发送,客户端接收
      • -O, --omit N :省略前 n 秒(忽略TCP 慢启动
      • -b, --bandwidth n[KM] 用于 TCP(仅 UDP 用于 IPERF 2):将目标带宽设置为 n 位/秒(UDP 默认为 1 Mbit/秒,TCP 无限制)。
      • -V, --verbose :比以前更详细的输出
      • -J, --json : 以 JSON 格式输出
      • -Z, --zerocopy :使用“零拷贝”sendfile() 方法发送数据。这使用更少的CPU。
      • -T, --title str : 用这个字符串作为每个输出行的前缀
      • -F, --file name : xmit/recv 指定文件
      • -A, --affinity n/n,m :设置 CPU 亲和性(核心从 0 开始编号 - 仅限 Linux 和 FreeBSD)
      • -k, --blockcount #[KMG] :要传输的块(数据包)数(而不是 -t 或 -n)
      • -4, --version4 :仅使用 IPv4
      • -6, --version6 :仅使用 IPv6
      • -L, --flowlabel :设置 IPv6 流标签(仅限 Linux)
      • -C, --linux-congestion :设置拥塞控制算法(仅限 Linux 和 FreeBSD)(iPerf2 中的 -Z)
      • -d, --debug :发出调试输出。主要(可能专门)供开发人员使用。
      • -s, --server : iPerf2 可以处理多个客户端请求。iPerf3 一次只允许一个 iperf 连接。
    • iPerf 3.1 中的新功能:
      • -I, --pidfile file 使用进程 ID 写入文件,在作为守护进程运行时最有用。
      • --cport :指定客户端端口。
      • --sctp 使用 SCTP 而不是 TCP(Linux、FreeBSD 和 Solaris)。
      • --udp-counters-64bit :支持非常长时间运行的 UDP 测试,这可能导致计数器溢出
      • --logfile 文件:将输出发送到日志文件。
    • iPerf3 不支持的 iPerf2 功能:
      • 双向测试(-d / -r)
      • 从标准输入 (-I) 传输的数据
      • TTL:生存时间,用于多播 (-T)
      • 排除 C(连接) D(数据) M(多播) S(设置) V(服务器)报告 (-x)
      • 报告为逗号分隔值 (-y)
      • 兼容模式允许与旧版本的 iPerf (-C) 一起使用

    iPerf 3 user documentation

    GENERAL OPTIONS
    Command line optionDescription
    -p, --port n The server port for the server to listen on and the client to connect to. This should be the same in both client and server. Default is 5201.
    --cport n Option to specify the client-side port. (new in iPerf 3.1)
    -f, --format [kmKM] A letter specifying the format to print bandwidth numbers in. Supported formats are 
        'k' = Kbits/sec           'K' = KBytes/sec
        'm' = Mbits/sec           'M' = MBytes/sec
    The adaptive formats choose between kilo- and mega- as appropriate.
    -i, --interval n Sets the interval time in seconds between periodic bandwidth, jitter, and loss reports. If non-zero, a report is made every interval seconds of the bandwidth since the last report. If zero, no periodic reports are printed. Default is zero.
    -F, --file name client-side: read from the file and write to the network, instead of using random data;
    server-side: read from the network and write to the file, instead of throwing the data away.
    -A, --affinity n/n,m-F Set the CPU affinity, if possible (Linux and FreeBSD only). On both the client and server you can set the local affinity by using the n form of this argument (where n is a CPU number). In addition, on the client side you can override the server’s affinity for just that one test, using the n,m form of argument. Note that when using this feature, a process will only be bound to a single CPU (as opposed to a set containing potentialy multiple CPUs).
    -B, --bind host Bind to host, one of this machine's addresses. For the client this sets the outbound interface. For a server this sets the incoming interface. This is only useful on multihomed hosts, which have multiple network interfaces.
    -V, --verbose give more detailed output
    -J, --json output in JSON format
    --logfile file send output to a log file. (new in iPerf 3.1)
    --d, --debug emit debugging output. Primarily (perhaps exclusively) of use to developers.
    -v, --version Show version information and quit.
    -h, --help Show a help synopsis and quit.
     
    SERVER SPECIFIC OPTIONS
    Command line optionDescription
    -s, --server Run iPerf in server mode. (This will only allow one iperf connection at a time)
    -D, --daemon Run the server in background as a daemon.
    -I, --pidfilefile write a file with the process ID, most useful when running as a daemon. (new in iPerf 3.1)
     
    CLIENT SPECIFIC OPTIONS
    Command line optionDescription
    -c, --client host Run iPerf in client mode, connecting to an iPerf server running on host.
    --sctp Use SCTP rather than TCP (Linux, FreeBSD and Solaris). (new in iPerf 3.1)
    -u, --udp Use UDP rather than TCP. See also the -b option.
    -b, --bandwidth n[KM] Set target bandwidth to n bits/sec (default 1 Mbit/sec for UDP, unlimited for TCP). If there are multiple streams (-P flag), the bandwidth limit is applied separately to each stream. You can also add a ’/’ and a number to the bandwidth specifier. This is called "burst mode". It will send the given number of packets without pausing, even if that temporarily exceeds the specified bandwidth limit.
    -t, --time n The time in seconds to transmit for. iPerf normally works by repeatedly sending an array of len bytes for time seconds. Default is 10 seconds. See also the -l-k and -n options.
    -n, --num n[KM] The number of buffers to transmit. Normally, iPerf sends for 10 seconds. The -n option overrides this and sends an array of len bytes num times, no matter how long that takes. See also the -l-k and -t options.
    -k, --blockcount n[KM] The number of blocks (packets) to transmit. (instead of -t or -n) See also the -t-l and -n options.
    -l, --length n[KM] The length of buffers to read or write. iPerf works by writing an array of len bytes a number of times. Default is 128 KB for TCP, 8 KB for UDP. See also the -n-k and -t options.
    -P, --parallel n The number of simultaneous connections to make to the server. Default is 1.
    -R, --reverse Run in reverse mode (server sends, client receives).
    -w, --window n[KM] Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. (this gets sent to the server and used on that side too)
    -M, --set-mss n Attempt to set the TCP maximum segment size (MSS). The MSS is usually the MTU - 40 bytes for the TCP/IP header. For ethernet, the MSS is 1460 bytes (1500 byte MTU).
    -N, --no-delay Set the TCP no delay option, disabling Nagle's algorithm. Normally this is only disabled for interactive applications like telnet.
    -4, --version4 only use IPv4.
    -6, --version4 only use IPv6.
    -S, --tos n The type-of-service for outgoing packets. (Many routers ignore the TOS field.) You may specify the value in hex with a '0x' prefix, in octal with a '0' prefix, or in decimal. For example, '0x10' hex = '020' octal = '16' decimal. The TOS numbers specified in RFC 1349 are: 
        IPTOS_LOWDELAY     minimize delay        0x10
        IPTOS_THROUGHPUT   maximize throughput   0x08
        IPTOS_RELIABILITY  maximize reliability  0x04
        IPTOS_LOWCOST      minimize cost         0x02
    -L, --flowlabel n Set the IPv6 flow label (currently only supported on Linux).
    -Z, --zerocopy Use a "zero copy" method of sending data, such as sendfile(2), instead of the usual write(2). This uses much less CPU.
    -O, --omit n Omit the first n seconds of the test, to skip past the TCP TCP slowstart period.
    -T, --title str Prefix every output line with this string.
    -C, --linux-congestion algo Set the congestion control algorithm (Linux only for iPerf 3.0, Linux and FreeBSD for iPerf 3.1).
    root@ubuntu-test:~# 
    root@ubuntu-test:~# vi /lib/systemd/system/iperf3.service
    root@ubuntu-test:~# 
    root@ubuntu-test:~# cat /lib/systemd/system/iperf3.service
    [Unit]
    Description=iperf3 server
    After=syslog.target network.target auditd.service
    
    [Service]
    PIDFile=/var/run/iperf3.pid
    ExecStart=/usr/bin/iperf3 -s
    ExecStop=/usr/bin/killall -9 iperf3
    
    [Install]
    WantedBy=multi-user.target
    
    root@ubuntu-test:~# 
    root@ubuntu-test:~# systemctl daemon-reload 
    root@ubuntu-test:~# 
    root@ubuntu-test:~# systemctl start iperf3.service 
    root@ubuntu-test:~# 
    root@ubuntu-test:~# systemctl status iperf3.service 
    ● iperf3.service - iperf3 server
       Loaded: loaded (/lib/systemd/system/iperf3.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2022-03-30 09:17:34 EDT; 2min 6s ago
     Main PID: 19282 (iperf3)
        Tasks: 1 (limit: 4915)
       CGroup: /system.slice/iperf3.service
               └─19282 /usr/bin/iperf3 -s
    
    Mar 30 09:17:34 ubuntu-test systemd[1]: Started iperf3 server.
    root@ubuntu-test:~# 
    root@ubuntu-test:~# systemctl enable iperf3
    root@ubuntu-test:~# 
    root@ubuntu-test:~# systemctl list-units --type=service | grep iperf3
    iperf3.service                       loaded active running iperf3 server                                                                
    root@ubuntu-test:~# 
    root@ubuntu-test:~# sudo systemctl list-unit-files | grep enable | grep iperf3
    iperf3.service                                         enabled        
    root@ubuntu-test:~#

    网络性能测试工具 iperf 的使用

    来源 https://zhuanlan.zhihu.com/p/390420078

    常用的参数有

    • -u:发送 UDP 包,仅客户端可用,服务端默认 tcp udp 都可以接收
    • -b:指定发送速率(比如 100M),发送端不受限速影响,如果有限速,也只是接收端有影响
    • -p:后接服务端监听的端口(默认端口: 5201)
    • -i:设置带宽报告的时间间隔,单位为秒
    • -t:设置测试的时长,单位为秒
    • -w:设置tcp窗口大小,一般可以不用设置,默认即可
    • -B:绑定客户端的ip地址
    • -4:指定 ipv4
    • -n:指定传输的字节数
    • -f:格式化带宽数输出,后接单位,比如 K,M
    • --get-server-output:在客户端直接获取服务端输出的结果

    iperf3 的结果

    iperf3 的输出结果可以分为两类

    • 一类是,详细的带宽数据
    • 一类是,最终的带宽数据

    如果你像我一样加上 --get-server-output ,可以看到服务端输出的报告。

    接下来看一下,输出的报告有哪些内容。

    • 第一列 Interval:测试的时长
    • 第二列 Transfer:在 Interval 时长里,传输的数据量
    • 第三列 Bitrate:传输速率
    • 第四列 Jitter:网络抖动,连续发送数据包时延差值的平均值,越小说明网络质量越好
    • 第五列 Lost/Total Datagrams:丢失的数据包与发送的总数据包

    ============
    HT2500 Modem Info
    SAN: HTS65TEST0010 ESN: 14708933
    BeamID: beam01
    RxHuntFreq: 1936.25MHz
    RxLnbLO: 10600MHz
    TxBucLO: 12800MHz
    RxPol: V

    ============
    Speedtest
    Download: 10.15Mbps Upload: 2.10Mbps Ping: 600.30ms Jitter: 116.88ms

    ============
    iperf3

    TxPacketNum: 100 ServerTx: 10Mbits/sec ClientRx: 10Mbits/sec
    [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
    [ 4] 0.00-100.00 sec 120 MBytes 10.1 Mbits/sec 1.169 ms 2639/89715 (2.9%)
    [ 4] Sent 89715 datagrams

    ------------
    TxPacketNum: 100 ClientTx: 1Mbits/sec ServerRx: 1Mbits/sec
    [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
    [ 4] 0.00-100.00 sec 11.9 MBytes 999 Kbits/sec 26.338 ms 428/8838 (4.8%)
    [ 4] Sent 8838 datagrams

    ============

    iperf3.exe -B 10.241.128.53 -c 192.168.151.200 -u -i 1 -t 10 -l 1400 -b 1m --get-server-output

    iperf3.exe -B 10.241.128.53 -c 192.168.151.200 -u -R -i 1 -t 10 -l 1400 -b 10m --get-server-output

    经验总结

    1. 如果想要 测试吞吐量抖动 和 丢包率 这三个指标,只能添加 -u 参数 使用UDP进行测试,并且使用 --get-server-output 获得 server端的报告。最后不断在client端增加带宽值,直到server端出现轻微的丢包为止,此时server端显示的带宽就是被测系统的吞吐量。
    2. 我们在做性能测试的时候需要指定包长,不同的包长会得到不同的吞吐量,通过-l指定,而使用-b指定带宽。
    3. 使用TCP来测试网络带宽,有一个参数需要特别注意,那就是TCP窗口大小,可以使用-w参数指定。网络通道的容量capacity = bandwidth * round-trip time。而理论TCP窗口的大小就是网络通道的容量。比如,网络带宽为40Mbit/s,回环路径消耗时间是2ms,那么TCP的窗口大小不小于40Mbit/s×2ms = 80kbit = 10Kbytes,此时我们可以查询iperf默认的TCP窗口大小来决定是否需要设置此参数,在此例中,窗口大小应设计大于10Kbytes,当然,这仅仅是理论值,在实际测试中可能需要作出调整。

    =============== End

  • 相关阅读:
    【洛谷 P5357】 【模板】AC自动机(二次加强版)(AC自动机,差分)
    【洛谷 P1659】 [国家集训队]拉拉队排练(manacher)
    【洛谷 P3224】 [HNOI2012]永无乡(Splay,启发式合并)
    HNOI2019退役祭
    类欧几里得算法模板
    乘法逆元模板
    $Luogu$ $P3130$ $[USACO15DEC]$ 计数 $Counting$ $Haybales$
    $Luogu$ $P2746$ $[USACO5.3]$ 校园网 $Network$ $of$ $Schools$
    $Luogu$ $P2243$ 电路维修
    $Luogu$ $P4667$ $[BalticOI$ $2011$ $Day1]$ 打开灯泡 $Switch$ $the$ $Lamp$ $On$
  • 原文地址:https://www.cnblogs.com/lsgxeva/p/16079241.html
Copyright © 2020-2023  润新知