当前位置:网站首页>网络各层性能测试
网络各层性能测试
2022-07-28 18:42:00 【为了维护世界和平_】
目录
一、性能指标
- 带宽:链路的最大传输速率。b/s(比特/秒) 常用带宽100M,1000M
- 吞吐量:表示没有丢包时的最大数据传输速率,b/s(比特/秒),受带宽影响。经常听到的带宽测试,就是吞吐量,一般比带宽小,对于专用交换机来说,吞吐量接近带宽。
- 延时:数据发出到远端响应的时间。
- pps:(packet per second )包/秒,表示以网络包为单位的传输速率。评估网络转发能力。对于TCP或者Web来说,更多用并发连接数和每秒请求数(QPS)为指标,反应应用程序的性能。
二、网络基准测试
各层协议性能
2.1 PPS测试方法
Linux 内核自带的高性能网络测试工具 pktgen。pktgen 支持丰富的自定义选项,方便你根据实际需要构造所需网络包,从而更准确地测试出目标服务器的性能。
pktgen 在每个 CPU 上启动一个内核线程,并可以通过 /proc/net/pktgen 下面的同名文件,跟这些线程交互;而 pgctrl 则主要用来控制这次测试的开启和停止。
# 定义一个工具函数pgset
function pgset() {
local result
echo $1 > $PGDEV
result=`cat $PGDEV | fgrep "Result: OK:"`
if [ "$result" = "" ]; then
cat $PGDEV | fgrep Result:
fi
}
# 为0号线程绑定eth0网卡
PGDEV=/proc/net/pktgen/kpktgend_0
pgset "rem_device_all" # 清空网卡绑定
pgset "add_device ens33" # 添加eth0网卡
# 配置eth0网卡的测试选项
PGDEV=/proc/net/pktgen/ens33
pgset "count 1000000" # 总发包数量
pgset "delay 5000" # 不同包之间的发送延迟(单位纳秒)
pgset "clone_skb 0" # SKB包复制
pgset "pkt_size 64" # 网络包大小
pgset "dst 192.168.0.38" # 目的IP
pgset "dst_mac fe80::xxxx:b8a0:xxxx:1791" # 目的MAC
# 启动测试
PGDEV=/proc/net/pktgen/pgctrl
pgset "start" [email protected]:/home/wy/misc/net# ./pgset.sh
./pgset.sh: line 5: echo: write error: Invalid argument
[email protected]:/home/wy/misc/net# cat /proc/net/pktgen/ens33
Params: count 1000000 min_pkt_size: 64 max_pkt_size: 64
frags: 0 delay: 5000 clone_skb: 0 ifname: ens33
flows: 0 flowlen: 0
queue_map_min: 0 queue_map_max: 0
dst_min: 192.168.0.38 dst_max:
src_min: src_max:
src_mac: 00:0c:29:a0:24:13 dst_mac: 00:00:00:00:00:00
udp_src_min: 9 udp_src_max: 9 udp_dst_min: 9 udp_dst_max: 9
src_mac_count: 0 dst_mac_count: 0
Flags:
Current:
pkts-sofar: 1000000 errors: 0
started: 790002417us stopped: 824829444us idle: 53604us
seq_num: 1000001 cur_dst_mac_offset: 0 cur_src_mac_offset: 0
cur_saddr: 192.168.0.133 cur_daddr: 192.168.0.38
cur_udp_dst: 9 cur_udp_src: 9
cur_queue_map: 0
flows: 0
Result: OK: 34827026(c34773421+d53604) usec, 1000000 (64byte,0frags)
28713pps 14Mb/sec (14701056bps) errors: 0- 第一部分的 Params 是测试选项;
- 第二部分的 Current 是测试进度,其中, packts so far(pkts-sofar)表示已经发送了 100 万个包,也就表明测试已完成。
- 第三部分的 Result 是测试结果,包含测试所用时间、网络包数量和分片、PPS、吞吐量以及错误数。
2.2 TCP/UDP性能
工具: iperf netperf等
启动服务(服务器)
iperf3 -s -i 1 -p 10000
//-s 启动服务器, -i间隔时间 -p监听端口客户端(客户端)
iperf3 -c 192.168.0.38 -b 1G -t 15 -P 2 -p 10000参数说明:
-c 服务器IP地址
-b 速度 目标带宽(1G)
-t 时间
-P 并发数量
-p 端口
性能报告
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-15.00 sec 1.10 GBytes 632 Mbits/sec 96 sender
[ 5] 0.00-15.00 sec 1.10 GBytes 631 Mbits/sec receiver
[ 7] 0.00-15.00 sec 1.25 GBytes 715 Mbits/sec 64 sender
[ 7] 0.00-15.00 sec 1.25 GBytes 714 Mbits/sec receiver
[SUM] 0.00-15.00 sec 2.35 GBytes 1.35 Gbits/sec 160 sender
[SUM] 0.00-15.00 sec 2.35 GBytes 1.35 Gbits/sec receiver
2.3 HTTP 性能
工具: ab、webbench 等
ab的安装
apt-get install -y apache2-utils开启lighttpd服务器(服务端)
lighttpd -f lighttpd.conf 客户端测试(客户端)
ab -c 1000 -n 10000 http://192.168.0.30/参数说明 : -c 并发数,-n请求总数
[email protected]:/# ab -c 1000 -n 10000 http://192.168.0.38/
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.0.38 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: lighttpd/1.4.64
Server Hostname: 192.168.0.38
Server Port: 80
Document Path: /
Document Length: 1330 bytes
Concurrency Level: 1000
Time taken for tests: 2.248 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 15430000 bytes
HTML transferred: 13300000 bytes
//请求
Requests per second: 4448.19 [#/sec] (mean)
//平均延迟224.810
Time per request: 224.810 [ms] (mean)
//实际响应时间
Time per request: 0.225 [ms] (mean, across all concurrent requests)
//吞吐量6702.69
Transfer rate: 6702.69 [Kbytes/sec] received
//连接时间 最大 最小 连接 等待 总时间
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 79 211.7 31 1080
Processing: 16 83 70.2 63 987
Waiting: 6 52 54.7 38 913
Total: 35 163 219.8 99 1451
//延迟 50%在99ms内完成 90%在263ms内完成
Percentage of the requests served within a certain time (ms)
50% 99
66% 121
75% 142
80% 159
90% 263
95% 437
98% 1101
99% 1122
100% 1451 (longest request)
吞吐量:6702.69 [Kbytes/sec] received 响应时间: 0.225 [ms]
2.4 应用负载
上面都是空测,没有带负载。带负载的测试工具wrk
wrk安装
apt install wrk同样测试lighttpd性能(服务端)
lighttpd -f lighttpd.conf (客户端)
//参数说明: -c并发数1000,-t 表示线程数2
[email protected]:/# wrk -c 1000 -t 2 http://192.168.0.38/
Running 10s test @ http://192.168.0.38/
2 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 83.15ms 58.80ms 1.68s 91.10%
Req/Sec 6.09k 1.95k 14.41k 73.98%
120441 requests in 10.06s, 177.60MB read
Requests/sec: 11972.18
Transfer/sec: 17.65MB每秒请求数 11972.18,吞吐量17.65MB, 平均延迟83.15
与ab相比有很大不同,吞吐量17.65MB而ab只有6MB左右
参考链接
https://course.0voice.com/v1/course/intro?courseId=2&agentId=0
边栏推荐
- FPGA programming experience
- Install keras, tensorflow, and add the virtual environment to the Jupiter notebook
- TCP.IP
- Character device drive structure
- Clock distribution of jesd204 IP core (ultrascale Series)
- Classes and objects (medium)
- MySQL error: specified key was too long; max key length is 767 bytes
- [POC - proof of concept]
- C language data 3 (1)
- 树行表达方式
猜你喜欢
关于链接到其他页面的标题

【pytorch】LSTM神经网络
![[C语言刷题篇]链表运用讲解](/img/44/1de4e3f0712780680fbdc904dfe39a.png)
[C语言刷题篇]链表运用讲解

太空射击第15课: 道具

leetcode:2141. 同时运行 N 台电脑的最长时间【最值考虑二分】

Related concepts of multitasking programming

太空射击第13课: 爆炸效果

Scheduled backup of MySQL database under Windows system

Voice controlled robot based on ROS (II): implementation of upper computer

【CodeForces】Educational Codeforces Round 132 (Rated for Div. 2)
随机推荐
Raspberry pie 4B deploy yolov5 Lite using ncnn
Shanghai Jiaotong University joined hands with Taobao to set up a media computing laboratory: promoting the development of key technologies such as video super score
Soft raid
Mongoose condition queries the data of a certain time period
Raspberry pie 4B ffmpeg RTMP streaming
Explain RESNET residual network in detail
h5微信射击小游戏源码
太空射击第09课:精灵动画
微信公众号授权登录后报redirect_uri参数错误的问题
华为云数字资产链,“链”接数字经济无限精彩
太空射击第14课: 玩家生命
[POC - proof of concept]
Raspberrypico analytic PWM
Does any elder brother know how to solve the huge flinksql log
System. ArgumentException: Object of type ‘System. Int64‘ cannot be converted to type ‘System.Int32‘
Mysql报错:Specified key was too long; max key length is 767 bytes
Other IPS cannot connect to the local redis problem solving and redis installation
js图片悬挂样式照片墙js特效
一文了解 Rainbond 云原生应用管理平台
关于链接到其他页面的标题