iperf2简单使用介绍

iperf

注意:iperf2和iperf3不兼容

参数说明(iperf2)

以下是iperf2部分常用参数说明,iperf3可能有所不同,具体请参考官方文档

客户端和服务端共有参数

Client/Server:
  -b, --bandwidth #[kmgKMG | pps]  仅udp有效,单位bits/sec,默认是1 Mbit/sec.
  -e, --enhancedreports    use enhanced reporting giving more tcp/udp and traffic information
  -f, --format    [kmgKMG]  输出的带宽格式: Kbits='k', Mbits='m', KBytes='K', MBytes='M'
  -i, --interval  #         每隔多少秒输出一次测试报告
  -l, --len       #[kmKM]   设置读写缓冲区的大小(不能超过默认大小),iPerf通过多次写入len字节数组来工作(Defaults: TCP=128K, v4 UDP=1470, v6 UDP=1450)
  -m, --print_mss          print TCP maximum segment size (MTU - TCP/IP header)
  -o, --output    <filename> 将报告输出到指定文件,重定向到文件
  -p, --port      #        客户端connect或者服务端监听指定的端口
  -u, --udp                测试udp,没有此选项默认测试TCP
      --udp-counters-64bit use 64 bit sequence numbers with UDP
  -w, --window    #[KM]    设置套接字缓冲区大小为指定值。对于TCP,设置TCP窗口大小。对于UDP,它只是接收数据报的缓冲区,因此限制了最大的可接收数据报的大小。
  -z, --realtime           request realtime scheduler
  -B, --bind <host>[:<port>][%<dev>] bind to <host>, ip addr (including multicast address) and optional port and device
  -C, --compatibility      for use with older versions does not sent extra msgs
  -M, --mss       #        set TCP maximum segment size (MTU - 40 bytes)
  -N, --nodelay            set TCP no delay, disabling Nagle's Algorithm
  -S, --tos       #        set the socket's IP_TOS (byte) field

-w参数说明:

设置套接字缓冲区大小。对于TCP,设置TCP窗口大小。对于UDP,它只是接收数据报的缓冲区,因此限制了最大的可接收数据报的大小。

-p参数说明:

服务器侦听和客户端连接的服务器端口。客户端和服务器端必须是相同的。默认值为5001,与ttcp相同。

服务端专有参数

Server specific:
  -s, --server             以server模式运行iperf
  -t, --time      #        time in seconds to listen for new connections as well as to receive traffic (default not set)
      --udp-histogram #,#  enable UDP latency histogram(s) with bin width and count, e.g. 1,1000=1(ms),1000(bins)
  -B, --bind <ip>[%<dev>]  bind to multicast address and optional device
  -H, --ssm-host <ip>      set the SSM source, use with -B for (S,G) 
  -U, --single_udp         run in single threaded UDP mode
  -D, --daemon             run the server as a daemon
  -V, --ipv6_domain        Enable IPv6 reception by setting the domain and socket to AF_INET6 (Can receive on both IPv4 and IPv6)

客户端专有参数

Client specific:
  -c, --client    <host>   以客户端模式运行, 并connect运行在<host>上面的iperf server
  -d, --dualtest           Do a bidirectional test simultaneously
      --ipg                set the the interpacket gap (milliseconds) for packets within an isochronous frame
      --isochronous <frames-per-second>:<mean>,<stddev> send traffic in bursts (frames - emulate video traffic)
  -n, --num       #[kmgKMG]   需要发送缓冲区的数量,通常情况下,iperf会发送10s。当此参数设定时,iperf会发送len字节长度的数组num次,且无论会花费多少时间 (参考-t和-l选项)
  -r, --tradeoff           Do a bidirectional test individually
  -t, --time      #        iPerf 通常通过在 time 秒内重复发送 len 个字节数组来工作。(默认 10s)
  -B, --bind [<ip> | <ip:port>] bind ip (and optional port) from which to source traffic
  -F, --fileinput <name>   input the data to be transmitted from a file
  -I, --stdin              input the data to be transmitted from stdin
  -L, --listenport #       port to receive bidirectional tests back on
  -P, --parallel  #        要运行的并行客户端线程数,服务端也需要同样的配置
  -R, --reverse            reverse the test (client receives, server sends)
  -T, --ttl       #        time-to-live, for multicast (default 1)
  -V, --ipv6_domain        Set the domain to IPv6 (send packets over IPv6)
  -X, --peer-detect        perform server version detection and version exchange
  -Z, --linux-congestion <algo>  set TCP congestion control algorithm (Linux only)

-n,-l参数说明(udp测试):

这两个参数都未指定的情况下,默认len=1470字节,也就是每次发送1470字节,默认发送10s。
只指定-l时,上述条件改为每次发送-l字节数,但是不能超过默认大小,否则会发送失败,默认发送10s
只指定-n时,默认len=1470字节,但只发送-n次,而不限制发送时间
同时指定时,表示发送-n-l长度的数据,不限制发送时间,同样-l不能超过默认大小

-t参数说明:

iPerf通常通过在time秒内重复发送 len个字节数组来工作,默认10s,-t可以更改为其他值

iperf测试示例

TCP测试

  • 服务端
  • iperf 默认就是TCP测试模式
$ iperf -s -i 1
  • 客户端
    • 192.168.3.33是服务端的ip
    • -f M 设置带宽格式为MByte
    • -i 1 1s中输出一次测试报告
$  iperf -c 192.168.3.33 -i 1 -f M

测试结果如下

------------------------------------------------------------
Client connecting to 192.168.3.33, TCP port 5001
TCP window size: 45.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.3.34 port 32948 connected with 192.168.3.33 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.00-1.00 sec  10.3 MBytes  10.3 MBytes/sec
[  1] 1.00-2.00 sec  10.0 MBytes  10.0 MBytes/sec
[  1] 2.00-3.00 sec  10.5 MBytes  10.5 MBytes/sec
[  1] 3.00-4.00 sec  10.4 MBytes  10.4 MBytes/sec
[  1] 4.00-5.00 sec  10.1 MBytes  10.1 MBytes/sec
[  1] 5.00-6.00 sec  10.1 MBytes  10.1 MBytes/sec
[  1] 6.00-7.00 sec  9.75 MBytes  9.75 MBytes/sec
[  1] 7.00-8.00 sec  10.5 MBytes  10.5 MBytes/sec
[  1] 8.00-9.00 sec  10.2 MBytes  10.2 MBytes/sec
[  1] 9.00-10.00 sec  10.5 MBytes  10.5 MBytes/sec
[  1] 0.00-10.11 sec   103 MBytes  10.1 MBytes/sec

UDP测试

最大带宽测试

客户端使用-b参数指定当前网络理论支持的最大带宽,即可测试出当前网络的实际最大带宽

  • 服务端
$ iperf -s -u -i 1
  • 客户端
    • 192.168.3.33是服务端的ip
    • -u 设置udp测试模式
    • -b 设置最大带宽为50Mbit
$ iperf -c 192.168.3.33 -i 1 -u -b 50M

测试结果如下

Client connecting to 192.168.3.33, UDP port 5001
Sending 1470 byte datagrams, IPG target: 224.30 us (kalman adjust)
UDP buffer size:  160 KByte (default)
------------------------------------------------------------
[  3] local 192.168.3.8 port 44359 connected with 192.168.3.33 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  4.43 MBytes  37.1 Mbits/sec
[  3]  1.0- 2.0 sec  4.61 MBytes  38.7 Mbits/sec
[  3]  2.0- 3.0 sec  4.36 MBytes  36.6 Mbits/sec
[  3]  3.0- 4.0 sec  4.28 MBytes  35.9 Mbits/sec
[  3]  4.0- 5.0 sec  4.22 MBytes  35.4 Mbits/sec
[  3]  5.0- 6.0 sec  4.42 MBytes  37.1 Mbits/sec
[  3]  6.0- 7.0 sec  4.75 MBytes  39.8 Mbits/sec
[  3]  7.0- 8.0 sec  4.75 MBytes  39.9 Mbits/sec
[  3]  8.0- 9.0 sec  4.60 MBytes  38.6 Mbits/sec
[  3] WARNING: did not receive ack of last datagram after 10 tries.
[  3]  0.0-10.0 sec  45.0 MBytes  37.7 Mbits/sec
[  3] Sent 32110 datagrams
多线程测试

使用-P参数指定测试线程数

  • 服务端
$  iperf -s -u -i 1 -P 5 
  • 客户端
$ iperf -c 192.168.3.33 -i 1 -u -b 50M -P 5
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值