点击"Python测试和开发"关注我
后台回复1024,解锁无限快乐!
安装
被测环境选择是某云的Ubuntu云主机,版本信息如下:
Ubuntu 18.04.1 LTS
执行安装:
apt install netperf
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列【新】软件包将被安装:
netperf
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 74 个软件包未被升级。
需要下载 550 kB 的归档。
解压缩后会消耗 1,155 kB 的额外空间。
获取:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/multiverse amd64 netperf amd64 2.6.0-2.1 [550 kB]
已下载 550 kB,耗时 1秒 (493 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
正在选中未选择的软件包 netperf。
(正在读取数据库 ... 系统当前共安装有 16082 个文件和目录。)
正准备解包 .../netperf_2.6.0-2.1_amd64.deb ...
正在解包 netperf (2.6.0-2.1) ...
正在设置 netperf (2.6.0-2.1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
➜ RemoteWorking
确认安装结果:
➜ RemoteWorking netperf -V
Netperf version 2.6.0
开始测试
因为我们当前只有一台测试机,所以我们就在同一台机器上启动服务端和客户端进行测试演示。
启动服务端:
➜ RemoteWorking netserver
Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
启动客户端开始测试:
➜ RemoteWorking netperf -H localhost
MIGRATED TCP STREAM TEST from ::0 (::) port 0 AF_INET6 to localhost (::1) port 0 AF_INET6 : demo
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 10.00 37435.93
结果分析:
从上面的结果中我们可以看到:测试机的端口0的吞吐量为37435.93b/s。
转换成Mb结果为:4679.49Mb/s,约为4.57Gb/s。
更多
全部参数:
➜ RemoteWorking 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.
常用参数:
-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:设置本地系统发送测试分组的大小,测试PPS时值为1。测试BPS时为1400。
-M size:设置远端系统接收测试分组的大小
-p port:设置测试连接Server端的端口
-D:对本地与远端系统的socket设置TCP_NODELAY选项
-r req,resp:设置request和reponse分组的大小
常用的组合命令:
TCP吞吐测试:
netperf -H 10.18.201.3 -l 60 -- -S 87380 -s 16384 -M 16384 -m 16384
UDP吞吐测试:
netperf -t UDP_STREAM -H 10.18.201.201 -l 60 -- -S 87380 -s 16384 -M 16384 -m 16384
数据库应用测试:
netperf -t TCP_RR -H 10.18.201.3 -l 60 -- -S 87380 -s 16384 -M 16384 -m 16384 -r 1024,32(发出去1024比特的包,收到32比特的包)
HTTP应用测试:
netperf -t TCP_CRR -H 10.18.201.3 -l 60 -- -S 87380 -s 16384 -M 16384 -m 16384 -r 1024,1024(发出去1024比特的包,收到1024比特的包)
完
往期推荐
点亮在看!