关于asr9k上“show interface”和“show policy -map”计数的一些解释

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。

参考

Spirent TestCenter: How do I calculate Layer 1 and Layer 2 bits per second and verify with the reported results?

Ethernet frame(wiki)

           

No comments

Comments feed for this article

Reply

Your email address will not be published. Required fields are marked *