comments by ‘zhihua’
对于 ASR9000 来说 :
“show interfaces” and “show policy-map interfaces” show L2 frame size.
“show interfaces” does not include FCS bytes, but “show policy-map interfaces” includes FCS bytes(SIP700 是个例外)
L1 frame size 和 L2 frame size #
如上图就是一个以太网帧的物理层具体所包含的内容。
-
Preamble: 前同步码 7 bytes
-
SFD: start frame delimiter 1 byte 帧开始定界符
-
Dst MAC: 6 bytes
-
Src MAC: 6 bytes
-
EtherType: 2 bytes
-
FCS(CRC): 4 bytes
除此之外,每个帧之前还会存在 12 bytes 的最小帧间隙 (Inter Frame Gap min)
-
L1 Size = L2 frame Size + IFG min + Preamble + SFD = L2 frame Size + 20 Bytes
-
L2 Size = Dst MAC+ Src MAC + Ether Type + Payload + FCS
Show interface 计数 #
我们拿测试仪构造一个 66 字节的帧.
Packet size 66 Bytes = Ethernet II Header(14)+ IPv4 (20) + Payload (28) + FCS (4)
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show int tenGigE 0/0/0/0 | in packets input
Tue Feb 14 12:21:00.065 UTC
58992573918 packets input, 4860381127998 bytes, 0 total input drops
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show int tenGigE 0/0/0/0 | in packets input
Tue Feb 14 12:21:03.400 UTC
58992573951 packets input, 4860381130044 bytes, 0 total input drops
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
计算接口数据包的计数:
(4860381130044-4860381127998)/(58992573951-58992573918) = 62 Bytes
即 show interface 显示的计数为 L2 frame 并且不包含 4 字节的 FCS
show policy-map 计数 #
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show policy-map interface tenGigE 0/0/0/1 output | in Matched
Tue Feb 14 12:23:49.045 UTC
Matched : 1342020745/88573369170 5
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 54037745345/4375790026504 0
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show policy-map interface tenGigE 0/0/0/1 output | in Matched
Tue Feb 14 12:24:01.514 UTC
Matched : 1342020905/88573379730 5
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 0/0 0
Matched : 54037745345/4375790026504 0
计算 show policy-map 的输出:
(88573379730-88573369170)/(1342020905-1342020745)=66 Bytes
即 show policy-map 显示的计数为 L2 frame 并且包含 4 字节对 FCS。
关于端口速率 #
正是因为 show interface 的输出显示的 L2 frame size,而 L1 size 会比 L2 size 多 20 字节,这样就会导致我们看接口的 rate 往往跑不满实际的接口带宽,这个 rate 会因为以太网帧的大小而进行浮动,以太网帧越小,show interface 端口速率显示就越少(L1 速率保持一致的情况下)。
以下是以相同的 L1 速率 10Gbps 向 ASR9K 的 TenG 接口打流,不同 frame size 大小 show interface rate 的显示:
1400 字节 frame #
Protocol:General
Interface In(bps) Out(bps) InBytes/Delta OutBytes/Delta
Te0/0/0/0 9.8G/ 98% 0/ 0% 1.3T/0 22780/0
Te0/0/0/1 0/ 0% 9.8G/ 98% 127.2G/0 1.1T/0
Quit='q', Clear='c', Freeze='f', Thaw='t',
Next set='n', Prev set='p', Bytes='y', Packets='k'
(General='g', IPv4 Uni='4u', IPv4 Multi='4m', IPv6 Uni='6u', IPv6 Multi='6m')
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show int tenGigE 0/0/0/1 | in rate
Tue Feb 14 09:10:07.706 UTC
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 9830632000 bits/sec, 880250 packets/sec
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
66 字节 frame #
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#show int tenGigE 0/0/0/1 | in rate
Tue Feb 14 09:21:45.425 UTC
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 7209227000 bits/sec, 14534730 packets/sec
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#
RP/0/RSP1/CPU0:513E.B.31.ASR9K-V2-2#monitor int tenGigE 0/0/0/0 tenGigE 0/0/0/1
Tue Feb 14 09:22:18.975 UTC
513E.B.31.ASR9K Monitor Time: 00:00:02 SysUptime: 15:52:49
Protocol:General
Interface In(bps) Out(bps) InBytes/Delta OutBytes/Delta
Te0/0/0/0 7.2G/ 72% 0/ 0% 2.0T/1.8G 22780/0
Te0/0/0/1 0/ 0% 7.2G/ 72% 0/0 99.7G/1.8G
Quit='q', Clear='c', Freeze='f', Thaw='t',
Next set='n', Prev set='p', Bytes='y', Packets='k'
(General='g', IPv4 Uni='4u', IPv4 Multi='4m', IPv6 Uni='6u', IPv6 Multi='6m')
ifHCInOctets 和 IfHCOutOctets #
这里补充一点,ifHCInOctets 和 IfHCOutOctets SNMP 采集到的计数也是 L2 frame size ,但是包含 FCS。
NCS55 QoS #
前端时间遇到个 NCS55 Qos 的问题, 借用同事的测试环境简单测试下发现:
-
NCS55 入向 policy 用的是 l2 frame size
-
NCS55 出向 shaping 用的是 l1 frame size
如下测试, 测试仪打 700M L1 rate,入向 Ten0/0/0/16 我设置的是 police 600m 然后 700m 的 l1 流量不丢。
出向 Gi0/0/0/0 设置的是 shape 600m,出现丢包了。
RP/0/RP0/CPU0:F340.13.15-NCS-540X-12Z16G-626B#show policy-map interface gigabitEthernet 0/0/0/0 output
Wed Jan 17 03:00:05.610 UTC
GigabitEthernet0/0/0/0 output: test-out
Class class-default
Classification statistics (packets/bytes) (rate - kbps)
Matched : 1145312053/146599942784 605404
Transmitted : 1046153656/133907667968 547219
Total Dropped : 99158397/12692274816 58185
Queueing statistics
Queue ID : 1024
Taildropped(packets/bytes) : 99158397/12692274816
Policy Bag Stats time: 1705460386809 [Local Time: 01/17/24 02:59:46.809]
RP/0/RP0/CPU0:F340.13.15-NCS-540X-12Z16G-626B#show policy-map interface tenGigE 0/0/0/16 input
Wed Jan 17 03:00:15.729 UTC
TenGigE0/0/0/16 input: test-in
Class class-default
Classification statistics (packets/bytes) (rate - kbps)
Matched : 233250825/29856105600 605399
Transmitted : 233250825/29856105600 605399
Total Dropped : 0/0 0
Policing statistics (packets/bytes) (rate - kbps)
Policed(conform) : 233250825/29856105600 605399
Policed(exceed) : 0/0 0
Policed(violate) : 0/0 0
Policed and dropped : 0/0
Policy Bag Stats time: 1705460386796 [Local Time: 01/17/24 02:59:46.796]
NCS55 的 qos 配置可以自定义帧头的大小, 如下设定 20 字节(设置为 20 字节的原因为 L1 Size = L2 frame Size + IFG min + Preamble + SFD = L2 frame Size + 20 Bytes), 这样我们就可以将出向的 shaping 转换为 l2 frame。
service-policy output test-out account user-defined 20