Netperf是一种网络性能的测量工具,主要针对基于TCP或UDP的传输。Netperf根据应用的不同,可以进行不同模式的网络性能测试,即批量数据传输(bulk data transfer)模式和请求/应答(request/reponse)模式。

工作原理

Netperf工具以client/server方式工作。server端是netserver,用来侦听来自client端的连接,client端是netperf,用来向server发起网络测试.在client与server之间,首先建立一个控制连接,传递有关测试配置的信息,以及测试的结果:在控制连接建立并传递了测试配置信息以后,client与server之间会再建立一个测试连接,进行来回传递特殊的流量模式,以测试网络的性能

软件安装

  1. 下载安装Netperf工具
下载链接:ftp://ftp.netperf.org/netperf/
[root@xiesshavip001 ~]# wget ftp://ftp.netperf.org/netperf/netperf-2.7.0.tar.gz
  1. 安装依赖包gcc cc
[root@xiesshavip001 ~]# yum install gcc cc -y
  1. 解压安装
[root@xiesshavip001 ~]# tar -zxvf netperf-2.7.0.tar.gz
[root@xiesshavip001 netperf-2.7.0]# ./configure
[root@xiesshavip001 netperf-2.7.0]# make && make install

命令参数介绍

命令行参数包括如下选项:

-H host :指定远端运行netserver的server IP地址。
-l testlen:指定测试的时间长度(秒)
-t testname:指定进行的测试类型,包括TCP_STREAM,UDP_STREAM,TCP_RR,TCP_CRR,UDP_RR
-s size 设置本地系统的socket发送与接收缓冲大小
-S size 设置远端系统的socket发送与接收缓冲大小
-m size 设置本地系统发送测试分组的大小
-M size 设置远端系统接收测试分组的大小
-D 对本地与远端系统的socket设置TCP_NODELAY选项

netperf 网络测试

  1. TCP_STREAM Netperf缺省情况下进行TCP批量传输,即-t TCP_STREAM。测试过程中,netperf向netserver发送批量的TCP数据分组,以确定数据传输过程中的吞吐量:
[root@xiesshavip002 ~]# netserver  # 服务端启动netserver 服务
Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
[root@xiesshavip001 ~]# netperf -H 192.168.130.20 -l 60
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 60.01 935.66
[root@xiesshavip001 ~]#
[root@xiesshavip001 ~]# netperf -H 192.168.130.20 -l 60 -- -m 10240 # 修改发送的包的大小
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec 87380 16384 10240 60.02 937.58
[root@xiesshavip001 ~]#
  1. UDP_STREAM UDP_STREAM用来测试进行UDP批量传输时的网络性能。注意:此时测试分组的大小不得大于socket的发送与接收缓冲大小,否则netperf会报出错提示:
[root@xiesshavip001 ~]# netperf -t UDP_STREAM  -H 192.168.130.20 -l 10
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET
Socket Message Elapsed Messages
Size Size Time Okay Errors Throughput
bytes bytes secs # # 10^6bits/sec 212992 65507 10.01 131286 0 6874.75
212992 10.01 1 0.05 [root@xiesshavip001 ~]#
[root@xiesshavip001 ~]# netperf -t UDP_STREAM -H 192.168.130.20 -l 10 -- -m 300000 # 超过socket的发送与接收缓冲大212992
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET
send_data: data send error: Message too long (errno 90)
netperf: send_omni: send_data failed: Message too long
[root@xiesshavip001 ~]#
  1. TCP_RR TCP_RR方式的测试对象是多次TCP request和response的交易过程
[root@xiesshavip001 ~]# netperf -t TCP_RR -H 192.168.130.20
MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET : first burst 0
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 16384 87380 1 1 10.00 8228.63
16384 87380
[root@xiesshavip001 ~]#

我们可以通过测试相关的参数来改变request和response分组的大小,TCP_RR方式下的参数如下表所示:

参数	           说明
-r req,resp 设置request和reponse分组的大小
-s size 设置本地系统的socket发送与接收缓冲大小
-S size 设置远端系统的socket发送与接收缓冲大小
-D 对本地与远端系统的socket设置TCP_NODELAY选项
[root@xiesshavip001 ~]# netperf -t TCP_RR -H 192.168.130.20 -- -r 64 64
MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET : first burst 0
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 16384 87380 64 64 10.00 8143.22
16384 87380
[root@xiesshavip001 ~]#
  1. TCP_CRR 与TCP_RR不同,TCP_CRR为每次交易建立一个新的TCP连接。
[root@xiesshavip001 ~]# netperf -t TCP_CRR -H 192.168.130.20
MIGRATED TCP Connect/Request/Response TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 16384 87380 1 1 10.00 899.38 # 数值明显比TCP_RR值小
16384 87380
[root@xiesshavip001 ~]#
  1. UDP_RR UDP_RR方式使用UDP分组进行request/response的交易过程
[root@xiesshavip001 ~]# netperf -t UDP_RR -H 192.168.130.20
MIGRATED UDP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.130.20 () port 0 AF_INET : first burst 0
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 212992 212992 1 1 10.00 8425.86
212992 212992
[root@xiesshavip001 ~]#

netperf --help

[root@xiesshavip001 ~]# netperf --help
netperf: invalid option -- '-' Usage: netperf [global options] -- [test options] Global options:
-a send,recv Set the local send,recv buffer alignment
-A send,recv Set the remote send,recv buffer alignment
-B brandstr Specify a string to be emitted with brief output
-c [cpu_rate] Report local CPU usage
-C [cpu_rate] Report remote CPU usage
-d Increase debugging output
-D time,[units] * Display interim results at least every time interval
using units as the initial guess for units per second
A negative value for time will make heavy use of the
system's timestamping functionality
-f G|M|K|g|m|k Set the output units
-F lfill[,rfill]* Pre-fill buffers with data from specified file
-h Display this text
-H name|ip,fam * Specify the target machine and/or local ip and family
-i max,min Specify the max and min number of iterations (15,1)
-I lvl[,intvl] Specify confidence level (95 or 99) (99)
and confidence interval in percentage (10)
-j Keep additional timing statistics
-l testlen Specify test duration (>0 secs) (<0 bytes|trans)
-L name|ip,fam * Specify the local ip|name and address family
-o send,recv Set the local send,recv buffer offsets
-O send,recv Set the remote send,recv buffer offset
-n numcpu Set the number of processors for CPU util
-N Establish no control connection, do 'send' side only
-p port,lport* Specify netserver port number and/or local port
-P 0|1 Don't/Do display test headers
-r Allow confidence to be hit on result only
-s seconds Wait seconds between test setup and test start
-S Set SO_KEEPALIVE on the data connection
-t testname Specify test to perform
-T lcpu,rcpu Request netperf/netserver be bound to local/remote cpu
-v verbosity Specify the verbosity level
-W send,recv Set the number of send,recv buffers
-v level Set the verbosity level (default 1, min 0)
-V Display the netperf version and exit
-y local,remote Set the socket priority
-Y local,remote Set the IP_TOS. Use hexadecimal.
-Z passphrase Set and pass to netserver a passphrase For those options taking two parms, at least one must be specified;
specifying one value without a comma will set both parms to that
value, specifying a value with a leading comma will set just the second
parm, a value with a trailing comma will set just the first. To set
each parm to unique values, specify both and separate them with a
comma. * For these options taking two parms, specifying one value with no comma
will only set the first parms and will leave the second at the default
value. To set the second value it must be preceded with a comma or be a
comma-separated pair. This is to retain previous netperf behaviour.
[root@xiesshavip001 ~]#

netperf 网络性能测试的更多相关文章

  1. 发行版Linux和麒麟操作系统下netperf 网络性能测试

    Netperf是一种网络性能的测量工具,主要针对基于TCP或UDP的传输.Netperf根据应用的不同,可以进行不同模式的网络性能测试,即批量数据传输(bulk data transfer)模式和请求 ...

  2. Netperf网络性能测试工具详解教程

    本文下载链接: [学习笔记]Netperf网络性能测试工具.pdf 一.Netperf工具简介 1.什么是Netperf ? (1)Netperf是由惠普公司开发的一种网络性能测量工具,主要针对基于T ...

  3. Linux netperf网络性能测试

    Linux netperf网络性能测试 (2013-10-14 16:07:48) 转载▼     网络性能测量的五项指标 1. 可用性(availability) 测试网络性能的第一步是确定网络是否 ...

  4. iperf/netperf网络性能测试工具、Wireshark网络包分析工具

    iperf   http://www.linuxidc.com/Linux/2014-05/101160.htm netperf  http://www.linuxidc.com/Linux/2013 ...

  5. TCP/UDP网络性能测试工具 - Netperf (zz) ..网络测试工具

    在构建或管理一个网络系统时,我们更多的是关心网络的可用性,即网络是否连通,而对于其整体的性能往往考虑不多. 除了netperf以外.       还有很多其它的网络性能测试工具.       如db, ...

  6. [原创]Linux下网络性能测试Netperf工具介绍及安装

    [原创]Linux下网络性能测试Netperf工具介绍及安装 1 官方网站 http://www.netperf.org/netperf/ 2 Netperf介绍 Netperf是一种网络性能的测试工 ...

  7. Linux系统性能测试工具(八)——网络性能测试工具之netperf

    本文介绍关于Linux系统(适用于centos/ubuntu等)的网络性能测试工具-iperf.磁盘io性能测试工具包括: iperf: netperf 参考链接:https://www.jiansh ...

  8. 复刻smartbits的国产网络性能测试工具minismb-如何配置Ping报文

    复刻smartbits的国产网络性能测试工具minismb,是一款专门用于测试智能路由器,网络交换机的性能和稳定性的软硬件相结合的工具.可以通过此以太网测试工具测试任何ip网络设备的端口吞吐率,带宽, ...

  9. 网络性能测试工具iperf详细使用图文教程

      Iperf是一个网络性能测试工具.Iperf可以测试TCP和UDP带宽质量.Iperf可以测量最大TCP带宽,具有多种参数和UDP特性. Iperf可以报告带宽,延迟抖动和数据包丢失.利用Iper ...

随机推荐

  1. Lint——Android SDK提供的静态代码扫描工具

    Lint和FindBugs一样,都是静态代码扫描工具,区别在于它是Android SDK提供的,会检查Android项目源文件的正确性.安全性.性能.可用性等潜在的bug并优化改进. 下图简单地描述了 ...

  2. python-->(set /dict)交集 差集 并集 补集(功能用来做交差并补的)

    # ### 集合 作用:交集 差集 并集 补集(功能用来做交差并补的) '''特征:自动去重 无序''' #定义一个空集合 setvar = set() #set()强制转换成一个空集合的数据类型 p ...

  3. 231A

    #include <iostream> using namespace std; #define maxSize 10 int main() { int views[maxSize]; i ...

  4. 15-Python3 编程第一步

    2018-11-20 11:42:06 ''' 肥婆纳妾数列 斐波那契数列,又称黄金分割数列:这个数列从第3项开始,每一项都等于前两项之和, 随着数列项数的增加,前一项与后一项之比越来越逼近黄金分割的 ...

  5. 数据加密之MD5加密

    MD5是一个安全的散列算法,有两个特点:1.输入两个不同的明文(一段原始的数字信息)不会得到相同的输出值2.根据输出值,不能得到原始的明文,即过程不可逆所以要解密MD5没有现成的算法,只能用穷举法,把 ...

  6. “0x00,0x08”两个十六进制字符串,转换为整形

    int m_length=0;char buf[2]=={0x00,0x08};memcpy(&m_length,&buf[0],2); m_length=m_length<&l ...

  7. php 数据库备份还原

    public function exportDatabase(){ $data = input(); //备份数据库 $host="192.168.0.123"; $user=&q ...

  8. Ubuntu系统添加搜狗输入法

    前端开发时有时候要接触到Ubuntu系统,但由于本身没有拼音输入,故需要自己安装搜狗,记录方法如下: 1.安装前先升级资源库并安装输入法依赖包: $sudo apt-get update $sudo ...

  9. node+react 打包成功,控制台报错

    控制台报错: 'ReactCurrentOwner' of undefined 解决办法:RN版本的问题. As I mentioned, make sure you've installed the ...

  10. ES6class

    类的方法都定义在prototype对象上面,所以类的新方法可以添加在prototype对象上面.Object.assign方法可以很方便地一次向类添加多个方法. 类的内部所有定义的方法,都是不可枚举的 ...