【测试】Linux网络性能评估工具iperf|qperf|netperf

目录

简介和区别

一、qperf

qperf安装

qperf使用

RDMA测试

二、iperf

安装iperf

使用iperf

Iperf参数介绍


简介和区别

测试:

带宽、延迟、抖动、数据包丢失率、最大传输单元等统计信息。

不同:

qperf和iperf/netperf一样可以评测两个节点之间的带宽和延时,相比netperf和iperf,支持RDMA是qperf工具的独有特性。(qperf -h 可以看到qpperf有很多测试RDMA的选项)

一、qperf

特点:第一可以支持RDMA测量,第二可进行循环遍历测试。

  • qperf安装

可以直接通过yum源安装。#yun install qperf*
同时会安装两个依赖包(libibverbs, librdmacm),是直接和rdma功能相关的,不然无法启动rdma功能。也可以通过,https://pkgs.org/download/qperf 官方网页下载安装。

  • qperf使用

服务端节点直接运行如下,无需任何参数
#qperf

默认开启端口号:19765
通过netstat查看,如下:
#netstat –tunlup
tcp 0 0 0.0.0.0:19765 0.0.0.0:* LISTEN 53755/qperf

常用参数:

SERVERNODE:服务端地址(不带端口哦,要是带端口,就用--listen_port xxx)

TESTS:你想看的网络性能(qperf --help tests)可以一条命令中带多个测试项,常用:
tcp_bw —— TCP流带宽
tcp_lat —— TCP流延迟
udp_bw —— UDP流带宽
udp_lat —— UDP流延迟
conf —— 显示两端主机配置
OPTIONS:可选字段(qperf --help options)常用的参数:
–time/-t —— 测试持续的时间,默认为 2s
–msg_size/-m —— 设置报文的大小,默认测带宽是为 64KB,测延迟是为 1B
–listen_port/-lp —— 设置与服务端建立连接的端口号,默认为 19765
–verbose/-v —— 提供更多输出的信息,可以更多尝试一下 -vc、-vs、-vt、-vu 等等

 

TCP带宽测试测试

qperf                                       #服务端

qperf   11.165.67.18  tcp_bw  #客户端

(11.165.67.18:服务端的IP,tcp_bw:本次测试的命名)​​​​​​​​​​​​​​

TCP延时测试

qperf                                      #服务端

qperf 11.165.67.18 tcp_lat     #客户端

 同时测试tcp带宽和延时

qperf                                      #服务端

qperf 11.165.67.18 tcp_bw tcp_lat  #客户端


UDP带宽、延时测试测试
UDP协议测试同TCP协议测试类似,只需命令参数中将tcp_bw和tcp_lat改成udp_bw和udp_lat即可。

qperf                                                   #服务端

qperf 11.165.67.18 udp_bw udp_lat   #客户端

 指定测试运行时间(使用-t参数)来实现

         测试10秒tcp带宽:
        #qperf 11.165.67.18 -t 10 tcp_bw

 

循环loop遍历测试 (size递增测试)

 在做网卡性能摸底测试的时候,很多时候需要得到网卡的带宽和延时性能曲线。通过qperf提供的循环loop测试,可以一个命令得到所有数据。循环多次测试,每次改变消息大小

 例如从16K增加到64K,每次大小翻倍直到64K。
   

 #qperf  11.165.67.18  -oo msg_size:1:64K:*2 -vu tcp_bw tcp_lat

tcp_bw:
bw = 3.06 MB/sec
msg_size = 1 bytes
tcp_bw:
bw = 6.15 MB/sec
msg_size = 2 bytes
tcp_bw:
bw = 12 MB/sec
……



可以最后将测试数据图形化。得到msg_size从1到64K变化的过程中,带宽,延时增长趋势和临界点。这个临界点对于服务器性能评估是很有帮助的。

RDMA测试

如果网卡支持RDMA功能,例如IB卡,那么可以进行RDMA性能测试:

为了使用 RoCE 运行 qperf,应该在客户端添加 -cm1 标志。(mellonx)

服务端:

qperf

客户端

send/receive

qperf -cm1 172.17.31.51 rc_lat

qperf -cm1 172.17.31.51 rc_bw

write/read

qperf -cm1 172.17.31.51 rc_rdma_write_lat

qperf -cm1 172.17.31.51 rc_rdma_write_bw

数据包size: -m 

qperf  -cm1 172.17.31.51 -m 1M rc_bw

数据包数量: -n

qperf  -cm1 172.17.31.51 -m 1M -n 1000 rc_bw

polling或者wait event模式:-cp   0 wait  其他poll

qperf  -cm1 172.17.31.51 -m 1M -cp 0  rc_bw 或者用-cp1 表示开启polling模式

设置持续时间:-t 默认是s, 加m、h、d 可表示分钟、小时、天

qperf  -cm1 172.17.31.51 -m 1M -t 20 rc_bw #20s

qperf  -cm1 172.17.31.51 -m 1M -t 20m rc_bw #20分钟

使用rdam_cm apo: -cm1       Use RDMA Connection Manager

qperf  -cm1 172.17.31.51 -m 1M -t 20 rc_bw 

qperf -h 可以看到qpperf有很多测试RDMA的选项,见文章末尾。

二、iperf/iperf3

(1)TCP方面

1 测试网络带宽。

2 支持多线程,在客户端与服务端支持多重连接。

3 报告MSS/MTU值的大小。

4 支持TCP窗口值自定义并可通过套接字缓冲。

(2)UDP方面

1 可以设置指定带宽的UDP数据流

2 可以测试网络抖动值、丢包数

3 支持多播测试

4 支持多线程,在客户端与服务端支持多重连接。

安装iperf

yum install iperf*

使用iperf

iperf3 同理

TCP

服务端-s:

iperf -s

客户端-c:

iperf -c 198.51.100.5

UDP

服务端-s:

iperf -s 

客户端-c:

iperf -c 198.51.100.5 -u -b 0

默认情况下,iperf讲UDP客户端的带宽限制为每秒1Mbit,可以用-b标志更改此值,将数字替换为要测试的最大带宽速率,-b 0  表示无限制。如果需要测试网络速度,可以将数字设置为高于网络提供商提供的最大带宽上限:

iperf -c 198.51.100.5 -u -b 1000m

这将告诉客户端我们希望尽可能达到每秒1000Mbits的最大值,该-b标志仅在使用UDP连接时有效,因为iperf未在TCP客户端上设置带宽限制。

双向测试

在某些情况下,可能希望测试两台服务器以获得最大吞吐量。使用iperf提供的内置双向测试功能可以轻松完成此测试。

服务端-s:

iperf -s

客户端-c:

iperf -c 198.51.100.5 -d

该命令使得iperf将在服务器上启server和client (198.51.100.6)连接--即当客户端又当服务端,iperf会将iperf服务器连接到客户端,该连接现在既充当服务器连接又充当客户端连接。

测试单线程TCP

iperf -s -p 12345 -i 1 -M

iperf -c   192.168.31.56   -p 12345 -i 1 -t 10 -w 20K

-c:客户端模式,后接服务器ip

-p:后接服务端监听的端口

-i:设置带宽报告的时间间隔,单位为秒

-t:设置测试的时长,单位为秒

-w:设置tcp窗口大小,一般可以不用设置,默认即可

测试多线程TCP (-P)

在客户端添加-P参即可测试多线程的TCP性能,如下为使用两个线程的测试情况

iperf -s -p 12345 -i 1 -M

iperf -c 192.168.31.56   -p  12345 -i 1 -t 10 -w 20K  -P 2

-P, --parallel #

服务器关闭之前保持的连接数。默认是0,这意味着永远接受连接。(客户端:线程数。指定客户端与服务端之间使用的线程数。默认是1线程。需要客户端与服务器端同时使用此参数。

测试单线程UDP(默认带宽)

服务端

iperf -s -u -p 12345 -i 1 

客户端

iperf -c server-ip -p server-port -i 1 -t 10 -b,其中参数说明如下:

-c:客户端模式,后接服务器ip

-p:后接服务端监听的端口

-i:设置带宽报告的时间间隔,单位为秒

-t:设置测试的时长,单位为秒

-b:设置udp的发送带宽,单位bit/s

测试单线程UDP(带宽为10Mbit/s)

设置客户端带宽为10M即可,使用参数-b指定

返回信息:

其中,Jitter为抖动,lost/total为丢包数量,Datagrams为包数量。

Iperf参数介绍

命令行选项

描述

客户端与服务器共用选项

-f, --format [bkmaBKMA]

格式化带宽数输出。支持的格式有: 
'b' = bits/sec 'B' = Bytes/sec 
'k' = Kbits/sec 'K' = KBytes/sec 
'm' = Mbits/sec 'M' = MBytes/sec 
'g' = Gbits/sec 'G' = GBytes/sec 
'a' = adaptive bits/sec 'A' = adaptive Bytes/sec 
自适应格式是kilo-和mega-二者之一。除了带宽之外的字段都输出为字节,除非指定输出的格式,默认的参数是a。 
注 意:在计算字节byte时,Kilo = 1024, Mega = 1024^2,Giga = 1024^3。通常,在网络中,Kilo = 1000, Mega = 1000^2, and Giga = 1000^3,所以,Iperf也按此来计算比特(位)。如果这些困扰了你,那么请使用-f b参数,然后亲自计算一下。

-i, --interval #

设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。

-l, --len #[KM]

设置读写缓冲区的长度。TCP方式默认为8KB,UDP方式默认为1470字节。

-m, --print_mss

输出TCP MSS值(通过TCP_MAXSEG支持)。MSS值一般比MTU值小40字节。通常情况

-p, --port #

设置端口,与服务器端的监听端口一致。默认是5001端口,与ttcp的一样。

-u, --udp

使用UDP方式而不是TCP方式。参看-b选项。

-w, --window #[KM]

设置套接字缓冲区为指定大小。对于TCP方式,此设置为TCP窗口大小。对于UDP方式,此设置为接受UDP数据包的缓冲区大小,限制可以接受数据包的最大值。

-B, --bind host

绑定到主机的多个地址中的一个。对于客户端来 说,这个参数设置了出栈接口。对于服务器端来说,这个参数设置入栈接口。这个参数只用于具有多网络接口的主机。在Iperf的UDP模式下,此参数用于绑 定和加入一个多播组。使用范围在224.0.0.0至239.255.255.255的多播地址。参考-T参数。

-C, --compatibility

与低版本的Iperf使用时,可以使用兼容模式。不需要两端同时使用兼容模式,但是强烈推荐两端同时使用兼容模式。某些情况下,使用某些数据流可以引起1.7版本的服务器端崩溃或引起非预期的连接尝试。

-M, --mss #[KM}

通过TCP_MAXSEG选项尝试设置TCP最大信息段的值。MSS值的大小通常是TCP/IP头减去40字节。在以太网中,MSS值 为1460字节(MTU1500字节)。许多操作系统不支持此选项。

-N, --nodelay

设置TCP无延迟选项,禁用Nagle's运算法则。通常情况此选项对于交互程序,例如telnet,是禁用的。

-V (from v1.6 or higher)

绑定一个IPv6地址。 
服务端:$ iperf -s –V 
客户端:$ iperf -c -V 
注意:在1.6.3或更高版本中,指定IPv6地址不需要使用-B参数绑定,在1.6之前的版本则需要。在大多数操作系统中,将响应IPv4客户端映射的IPv4地址。

服务器端专用选项

-s, --server

Iperf服务器模式

-D (v1.2或更高版本)

Unix平台下Iperf作为后台守护进程运行。在Win32平台下,Iperf将作为服务运行。

-R(v1.2或更高版本,仅用于Windows)

卸载Iperf服务(如果它在运行)。

-o(v1.2或更高版本,仅用于Windows)

重定向输出到指定文件

-c, --client host

如果Iperf运行在服务器模式,并且用-c参数指定一个主机,那么Iperf将只接受指定主机的连接。此参数不能工作于UDP模式。

-P, --parallel #

服务器关闭之前保持的连接数。默认是0,这意味着永远接受连接。(客户端:线程数。指定客户端与服务端之间使用的线程数。默认是1线程。需要客户端与服务器端同时使用此参数。

客户端专用选项

-b, --bandwidth #[KM]

UDP模式使用的带宽,单位bits/sec。此选项与-u选项相关。默认值是1 Mbit/sec。

-c, --client host

运行Iperf的客户端模式,连接到指定的Iperf服务器端。

-d, --dualtest

运行双测试模式。这将使服务器端反向连接到客户端,使用-L 参数中指定的端口(或默认使用客户端连接到服务器端的端口)。这些在操作的同时就立即完成了。如果你想要一个交互的测试,请尝试-r参数。

-n, --num #[KM]

传送的缓冲器数量。通常情况,Iperf按照10秒钟发送数据。-n参数跨越此限制,按照指定次数发送指定长度的数据,而不论该操作耗费多少时间。参考-l与-t选项。

-r, --tradeoff

往复测试模式。当客户端到服务器端的测试结束时,服务器端通过-l选项指定的端口(或默认为客户端连接到服务器端的端口),反向连接至客户端。当客户端连接终止时,反向连接随即开始。如果需要同时进行双向测试,请尝试-d参数。

-t, --time #

设置传输的总时间。Iperf在指定的时间内,重复的发送指定长度的数据包。默认是10秒钟。参考-l与-n选项。

-L, --listenport #

指定服务端反向连接到客户端时使用的端口。默认使用客户端连接至服务端的端口。

-P, --parallel #

线程数。指定客户端与服务端之间使用的线程数。默认是1线程。需要客户端与服务器端同时使用此参数。

-S, --tos #

出栈数据包的服务类型。许多路由器忽略TOS字段。你可以指定这个值,使用以"0x"开始的16进制数,或以"0"开始的8进制数或10进制数。 
例如,16进制'0x10' = 8进制'020' = 十进制'16'。TOS值1349就是:
IPTOS_LOWDELAY minimize delay 0x10 
IPTOS_THROUGHPUT maximize throughput 0x08 
IPTOS_RELIABILITY maximize reliability 0x04 
IPTOS_LOWCOST minimize cost 0x02

-T, --ttl #

出栈多播数据包的TTL值。这本质上就是数据通过路由器的跳数。默认是1,链接本地。

-F (from v1.2 or higher)

使用特定的数据流测量带宽,例如指定的文件。 
$ iperf -c -F

-I (from v1.2 or higher)

与-F一样,由标准输入输出文件输入数据。

杂项

-h, --help

显示命令行参考并退出 。

-v, --version

显示版本信息和编译信息并退出。

qperf RDMA测试 相关选项

[root@localhost tool]# qperf --help opts
--access_recv OnOff (-ar)           Turn on/off accessing received data
  -ar1                              Cause received data to be accessed
--alt_port Port (-ap)               Set alternate path port
  --loc_alt_port Port (-lap)        Set local alternate path port
  --rem_alt_port Port (-rap)        Set remote alternate path port
--cpu_affinity PN (-ca)             Set processor affinity
  --loc_cpu_affinity PN (-lca)      Set local processor affinity
  --rem_cpu_affinity PN (-rca)      Set remote processor affinity
--flip OnOff (-f)                   Flip on/off sender and receiver
  -f1                               Flip (on) sender and receiver
--help Topic (-h)                   Get more information on a topic
--host Node (-H)                    Identify server node
--id Device:Port (-i)               Set RDMA device and port
  --loc_id Device:Port (-li)        Set local RDMA device and port
  --rem_id Device:Port (-ri)        Set remote RDMA device and port

--listen_port Port (-lp)            Set server listen port
--loop Var:Init:Last:Incr (-oo)     Sequence through values
--msg_size Size (-m)                Set message size
--mtu_size Size (-mt)               Set MTU size (RDMA only)
--no_msgs Count (-n)                Send Count messages
--cq_poll OnOff                     Set polling mode on/off
  --loc_cq_poll OnOff (-lcp)        Set local polling mode on/off
  --rem_cq_poll OnOff (-rcp)        Set remote polling mode on/off
  -cp1                              Turn polling mode on
  -lcp1                             Turn local polling mode on
  -rcp1                             Turn remote polling mode on
--ip_port Port (-ip)                Set TCP port used for tests
--precision Digits (-e)             Set precision reported
--rd_atomic Max (-nr)               Set RDMA read/atomic count
    --loc_rd_atomic Max (-lnr)      Set local RDMA read/atomic count
    --rem_rd_atomic Max (-rnr)      Set remote RDMA read/atomic count
--service_level SL (-sl)            Set service level
  --service_level SL (-lsl)         Set local service level
  --service_level SL (-rsl)         Set remote service level
--sock_buf_size Size (-sb)          Set socket buffer size
  --loc_sock_buf_size Size (-lsb)   Set local socket buffer size
  --rem_sock_buf_size Size (-rsb)   Set remote socket buffer size
--src_path_bits num (-sp)           Set source path bits
  --loc_src_path_bits num (-lsp)    Set local source path bits
  --rem_src_path_bits num (-rsp)    Set remote source path bits
--static_rate (-sr)                 Set IB static rate
  --loc_static_rate (-lsr)          Set local IB static rate
  --rem_static_rate (-rsr)          Set remote IB static rate
--time Time (-t)                    Set test duration
--timeout Time (-to)                Set timeout
  --loc_timeout Time (-lto)         Set local timeout
  --rem_timeout Time (-rto)         Set remote timeout
--unify_nodes (-un)                 Unify nodes
--unify_units (-uu)                 Unify units
--use_bits_per_sec (-ub)            Use bits/sec rather than bytes/sec
--use_cm OnOff (-cm)                Use RDMA Connection Manager or not
  -cm1                              Use RDMA Connection Manager
--verbose (-v)                      Verbose; turn on all of -v[cstu]
  --verbose_conf (-vc)              Show configuration information
  --verbose_stat (-vs)              Show statistical information
  --verbose_time (-vt)              Show timing information
  --verbose_used (-vu)              Show information on parameters
  --verbose_more (-vv)              More verbose; turn on all of -v[CSTU]
  --verbose_more_conf (-vvc)        Show more configuration information
  --verbose_more_stat (-vvs)        Show more statistical information
  --verbose_more_time (-vvt)        Show more timing information
  --verbose_more_used (-vvu)        Show more information on parameters
--version (-V)                      Print out version
--wait_server Time (-ws)            Set time to wait for server
 

[root@localhost tool]# qperf --help tests
Miscellaneous
    conf                    Show configuration
    quit                    Cause the server to quit
Socket Based
    rds_bw                  RDS streaming one way bandwidth
    rds_lat                 RDS one way latency
    sctp_bw                 SCTP streaming one way bandwidth
    sctp_lat                SCTP one way latency
    tcp_bw                  TCP streaming one way bandwidth
    tcp_lat                 TCP one way latency
    udp_bw                  UDP streaming one way bandwidth
    udp_lat                 UDP one way latency
RDMA Send/Receive
    rc_bi_bw                RC streaming two way bandwidth
    rc_bw                   RC streaming one way bandwidth
    rc_lat                  RC one way latency
    uc_bi_bw                UC streaming two way bandwidth
    uc_bw                   UC streaming one way bandwidth
    uc_lat                  UC one way latency
    ud_bi_bw                UD streaming two way bandwidth
    ud_bw                   UD streaming one way bandwidth
    ud_lat                  UD one way latency
    xrc_bi_bw               XRC streaming two way bandwidth
    xrc_bw                  XRC streaming one way bandwidth
    xrc_lat                 XRC one way latency
RDMA  write/read
    rc_rdma_read_bw         RC RDMA read streaming one way bandwidth
    rc_rdma_read_lat        RC RDMA read one way latency
    rc_rdma_write_bw        RC RDMA write streaming one way bandwidth
    rc_rdma_write_lat       RC RDMA write one way latency
    rc_rdma_write_poll_lat  RC RDMA write one way polling latency
    uc_rdma_write_bw        UC RDMA write streaming one way bandwidth
    uc_rdma_write_lat       UC RDMA write one way latency
    uc_rdma_write_poll_lat  UC RDMA write one way polling latency
InfiniBand Atomics
    rc_compare_swap_mr      RC compare and swap messaging rate
    rc_fetch_add_mr         RC fetch and add messaging rate
Verification
    ver_rc_compare_swap     Verify RC compare and swap
    ver_rc_fetch_add        Verify RC fetch and add

获取帮助

qperf -h

[root@rdma65 SDS_Admin]# qperf -h
Synopsis
    qperf
    qperf SERVERNODE [OPTIONS] TESTS

Description
    qperf measures bandwidth and latency between two nodes.  It can work
    over TCP/IP as well as the RDMA transports.  On one of the nodes, qperf
    is typically run with no arguments designating it the server node.  One
    may then run qperf on a client node to obtain measurements such as
    bandwidth, latency and cpu utilization.

    In its most basic form, qperf is run on one node in server mode by
    invoking it with no arguments.  On the other node, it is run with two
    arguments: the name of the server node followed by the name of the
    test.  A list of tests can be found in the section, TESTS.  A variety
    of options may also be specified.

    One can get more detailed information on qperf by using the --help
    option.  Below are examples of using the --help option:

        qperf --help examples       Some examples of using qperf
        qperf --help opts           Summary of options
        qperf --help options        Description of options
        qperf --help tests          Short summary and description of tests
        qperf --help TESTNAME       More information on test TESTNAME
You have mail in /var/spool/mail/root

[root@rdma65 SDS_Admin]# qperf --help examples
In these examples, we first run qperf on a node called myserver in server
mode by invoking it with no arguments.  In all the subsequent examples, we
run qperf on another node and connect to the server which we assume has a
hostname of myserver.
    * To run a TCP bandwidth and latency test:
        qperf myserver tcp_bw tcp_lat
    * To run a UDP latency test and then cause the server to terminate:
        qperf myserver udp_lat quit
    * To measure the RDMA UD latency and bandwidth:
        qperf myserver ud_lat ud_bw
    * To measure RDMA UC bi-directional bandwidth:
        qperf myserver rc_bi_bw
    * To get a range of TCP latencies with a message size from 1 to 64K
        qperf myserver -oo msg_size:1:64K:*2 -vu tcp_lat

 本文源文:https://blog.csdn.net/bandaoyu/article/details/116758976

  • 7
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值