
经常有人在群里问vpp有支持查询接口速率吗?12月9号有一个commit提交增加了监控指定接口速率和pps的命令行,如下:
#commit 链接:https://gerrit.fd.io/r/c/vpp/+/34415
interface: Add interface monitor cli
This adds an interface CLI 'monitorinterface <interface>' that periodicallyreports rx/tx pps & bandwidth for a given interface.
迫不及待的就来验证一下,cli说明如下:
monitor interface <interface> [interval <intv>] [count <count>]
#interval 监控周期 1s或0.1s
#count:监控次数
在一端ping当前接口的ip地址 ping 192.168.100.1 repeat 10000 interval 0.1 size 1000,设置监控接口周期1s,监控10次,打印信息如下所示:
DBGvpp# monitor interface GigabitEthernet2/2/0 interval 1 count 10
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbpsz
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
rx: 9pps 10.49Kbps tx: 9pps 10.49KbpsV
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps´
rx: 9pps 10.49Kbps tx: 9pps 10.49KbpsY
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
rx: 9pps 10.49Kbps tx: 9pps 10.49Kbps
有没有发现每次打印偶尔会多一个字符,查看了一下代码是打印多了一个%c,"rx: %Upps %Ubps tx: %Upps %Ubps%c"
这里有个疑问policer限速的cir速率Kbps和Mbps换算单位是1000还是1024,查询了一下在wiki中(https://en.wikipedia.org/wiki/Kilobyte): 在SI中,K是指1000,M是指1000000。这种用法通常用于 数据传输速率、计算机网络、cpu时钟等。通常用于通信领域。而1024的用法通常用于存储领域,像内存、硬盘、cache。像Mbps这样通信类的单位,用的是十进制的。在存储系统中的MB,用的是二进制的。
下面是vpp代码中将速率换算成字节计算是按照1000来换算的。
const int BYTES_PER_KBIT = (1000 / 8);
本文分享自 DPDK VPP源码分析 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!