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. 解压安装

    发行版Linux(CentOS7等)下编译和安装步骤如下:

  1.   [root@xiesshavip001 ~]# tar -zxvf netperf-2.7..tar.gz
      [root@xiesshavip001 ~]#cd ./netperf-2.7./
      [root@xiesshavip001 netperf-2.7.]# ./configure
      [root@xiesshavip001 netperf-2.7.]# cd ./src/
      [root@xiesshavip001 netperf-2.7.]# make
      [root@xiesshavip001 netperf-2.7.]# make install

    麒麟操作系统Linux(银河麒麟,搭配的是飞腾1500A 64位处理器)下编译和安装步骤如下:

  [root@xiesshavip001 ~]# tar -zxvf netperf-2.7.0.tar.gz
  [root@xiesshavip001 ~]#cd ./netperf-2.7.0/
  [root@xiesshavip001 netperf-2.7.0]# ./configure  –build=alpha //注释:此处指定编译平台为alpha
  [root@xiesshavip001 netperf-2.7.0]# cd ./src/
  [root@xiesshavip001 netperf-2.7.0]# make
  [root@xiesshavip001 netperf-2.7.0]# 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数据分组,以确定数据传输过程中的吞吐量:

  1. [root@xiesshavip002 ~]# netserver  # 服务端启动netserver 服务
    Starting netserver with host 'IN(6)ADDR_ANY' port '' and family AF_UNSPEC
    [root@xiesshavip001 ~]# netperf -H 192.168.130.20 -l
    MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port AF_INET to 192.168.130.20 () port AF_INET
    Recv Send Send
    Socket Socket Message Elapsed
    Size Size Size Time Throughput
    bytes bytes bytes secs. ^6bits/sec
    60.01 935.66
    [root@xiesshavip001 ~]#
    [root@xiesshavip001 ~]# netperf -H 192.168.130.20 -l -- -m # 修改发送的包的大小
    MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port AF_INET to 192.168.130.20 () port AF_INET
    Recv Send Send
    Socket Socket Message Elapsed
    Size Size Size Time Throughput
    bytes bytes bytes secs. ^6bits/sec 60.02 937.58

2、UDP_STREAM UDP_STREAM用来测试进行UDP批量传输时的网络性能。注意:此时测试分组的大小不得大于socket的发送与接收缓冲大小,否则netperf会报出错提示:

[root@xiesshavip001 ~]# netperf -t UDP_STREAM  -H 192.168.130.20 -l
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port AF_INET to 192.168.130.20 () port AF_INET
Socket Message Elapsed Messages
Size Size Time Okay Errors Throughput
bytes bytes secs # # ^6bits/sec 10.01 6874.75
10.01 0.05 [root@xiesshavip001 ~]#
[root@xiesshavip001 ~]# netperf -t UDP_STREAM -H 192.168.130.20 -l -- -m # 超过socket的发送与接收缓冲大212992
MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port AF_INET to 192.168.130.20 () port AF_INET
send_data: data send error: Message too long (errno )
netperf: send_omni: send_data failed: Message too long

3、TCP_RR TCP_RR方式的测试对象是多次TCP request和response的交易过程

  1. [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 AF_INET to 192.168.130.20 () port AF_INET : first burst
    Local /Remote
    Socket Size Request Resp. Elapsed Trans.
    Send Recv Size Size Time Rate
    bytes Bytes bytes bytes secs. per sec 10.00 8228.63

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

    参数	           说明
    -r req,resp 设置request和reponse分组的大小
    -s size 设置本地系统的socket发送与接收缓冲大小
    -S size 设置远端系统的socket发送与接收缓冲大小
    -D 对本地与远端系统的socket设置TCP_NODELAY选项
  2. [root@xiesshavip001 ~]# netperf -t TCP_RR -H 192.168.130.20 -- -r
    MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port AF_INET to 192.168.130.20 () port AF_INET : first burst
    Local /Remote
    Socket Size Request Resp. Elapsed Trans.
    Send Recv Size Size Time Rate
    bytes Bytes bytes bytes secs. per sec 10.00 8143.22

4、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 AF_INET to 192.168.130.20 () port AF_INET
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 10.00 899.38 # 数值明显比TCP_RR值小

5、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 AF_INET to 192.168.130.20 () port AF_INET : first burst
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec 10.00 8425.86

6、netperf 的命令使用帮助: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 (,)
-I lvl[,intvl] Specify confidence level ( or ) ()
and confidence interval in percentage ()
-j Keep additional timing statistics
-l testlen Specify test duration (> secs) (< 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 | 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 , min )
-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.

参考链接:

1、源代码和帮助文档

2、netperf 网络性能测试

3、netperf的安装及使用

4、ARM64平台编译stream、netperf出错解决办法

5、netperf使用指南

6、netperf 与网络性能测量

发行版Linux和麒麟操作系统下netperf 网络性能测试的更多相关文章

  1. chmod 权限777 是什么意思(Unix和Linux的各种操作系统下)

    在Unix和Linux的各种操作系统下,每个文件(文件夹也被看作是文件)都按读.写.运行设定权限.例如我用ls -l命令列文件表时,得到如下输出:-rw-r--r-- 1 bu users 2254 ...

  2. top(topas),vmstat,iostat在linux和AIX操作系统下显示情况

    top(topas),vmstat,iostat在linux和AIX操作系统下显示情况 分类: Linux基础 2013-08-09 17:26 1093人阅读 评论(0) 收藏 举报 详细列出各命令 ...

  3. Tsung CentOS 操作系统下搭建tsung性能测试环境_Part 2

    CentOS 操作系统下搭建tsung性能测试环境_Part 2 by:授客 QQ:1033553122 --------------------接CentOS 操作系统下搭建tsung性能测试环境_ ...

  4. Tsung CentOS 操作系统下搭建tsung性能测试环境_Part 1

    CentOS 操作系统下搭建tsung性能测试环境_Part 1 by:授客 QQ:1033553122 步骤1.下载软件安装包 CentOS-6.0-x86_64-bin-DVD1.iso jdk- ...

  5. Linux netperf网络性能测试

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

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

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

  7. 高手从零开始的全定制发行版-Linux from Scratch

    在制作Linux发行版中Linux from Scratch可谓是真正的大师级.Linux from Scratch是在线的社区创建的一本电子书,目的是帮助那些根深蒂固的想方设法提高计算机性能的人(t ...

  8. netperf 网络性能测试

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

  9. CentOS和Redhat发行版linux内核版本的对应关系

    由于Redhat和CentOS的发行版本现在众多,所以我们应该知道CentOS和Redhat及linux内核之间版本的对应关系对维护系统还是很有帮助的.对应的列表如下: Redhat 9.0————— ...

随机推荐

  1. Tunnel Warfare(hdu1540 线段树)

    Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  2. Java - Iterator源码解析

    java提高篇(三十)-----Iterator 迭代其实我们可以简单地理解为遍历,是一个标准化遍历各类容器里面的所有对象的方法类,它是一个很典型的设计模式.Iterator模式是用于遍历集合类的标准 ...

  3. -C++11可变模版参数(转载)

    泛化之美--C++11可变模版参数的妙用 1概述 C++11的新特性--可变模版参数(variadic templates)是C++11新增的最强大的特性之一,它对参数进行了高度泛化,它能表示0到任意 ...

  4. java的XML解析(DOM4J技术)

    DOM4J技术解析XML文件 一,XML简介 xml (可扩展标记语言)  全称: Extended Markup Language 可扩展的含义:允许程序员按照自己的想法去扩展新的标签 注意:但是扩 ...

  5. 【代码笔记】iOS-自定义switch

    一,效果图. 二,工程图. 三,代码. ViewController.h #import <UIKit/UIKit.h> #import "CustomSwitch.h" ...

  6. 【代码笔记】iOS-MBProgressHUDDemo

    一,工程图. 二,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "MBProgressHUD. ...

  7. 记录搭建Odoo框架

    一.获取 Odoo 源码 Odoo 是一个开源项目,我们可以轻松的在 Github 上找到它的源码.本次中使用的是 12.0 版本的 Odoo,所以在拉取代码时选择 12.0 的分支.确保拉取的速度, ...

  8. Vue.js之组件系统

    vue.js既然是框架,那就不能只是简单的完成数据模板引擎的任务,它还提供了页面布局的功能.本文详细介绍使用vue.js进行页面布局的强大工具,vue.js组件系统. Vue.js组件系统 每一个新技 ...

  9. h5向上翻页图标晃动动画,css固定h5向上翻页图标在页面上

    //html结构<div class='upImg'><div> //css .upImg { background-image: url(../images/01.png); ...

  10. SD从零开始03-04

    [原创]SD从零开始3 SD中的主数据 客户主数据Customer master(分层维护) 一般数据general data: 与销售和财务都有关,对所有的组织单元有效: 销售区域数据sales a ...