目录

简介

问题

解决方案

IP 分段

简介

本文档介绍在聚合服务路由器(ASR)5000系列平台的CLI中执行ping时，show port命令和ping命令报告的字节数。它还演示了当发送的数据包大于接口中配置的最大传输单位(MTU)时分段的影响。这是排除ping或通常情况下通过机箱的数据包的用户平面问题时应具备的良好背景信息。此外，在节点上尝试ping是确认本文档中介绍的概念的绝佳方法。

问题

指定互联网控制消息协议(ICMP)数据包的大小时，该大小是指封装到数据包中的原始负载。它不包括ICMP报头（8字节）或IP报头（20字节）。 另外值得注意的是以太网报头(14字节=目的MAC(6)+源MAC(6)+以太网帧类型(2))、VLAN标记（4字节）和尾随的以太网帧校验序列（FCS，4字节），后者不会显示在Wireshark跟踪中。

解决方案

查看show port [npu]的输出 | datalink] counters命令，可应用的数学如本例所示。匹配颜色，以便直接了解。本练习在流量很少甚至没有的端口上工作，因为它允许在没有任何其他流量的情况下发送ping命令，以便将结果输出云化。

有效载荷大小:56字节（也是此命令的默认值）

负载+ ICMP报头：64

负载+ ICMP报头+ IP报头：84

负载+ ICMP报头+ IP报头+以太网报头+ VLAN标记：102

负载(56)+ ICMP报头(8)+ IP报头(20)+以太网报头(14)+ VLAN标记(4)+ FCS(4):106

context Ctx

interface 21/1 broadcast

ip address 10.193.82.118 255.255.255.0

ip mtu 1500

#exit

port ethernet 21/1

no shutdown

vlan 30

no shutdown

bind interface 21/1 Ctx

#exit

#exit

[Ctx]ASR5000> show ip arp

Flags codes:

I - Incomplete, R - Reachable, M - Permanent, S - Stale,

D - Delay,      P - Probe,     F - Failed

Address         Link Type Link Address      Flags  Mask            Interface

10.193.82.1     ether     00:00:0C:07:AC:1E R                      21/1

[Ctx]ASR5000> show ip route

"*" indicates the Best or Used route.  S indicates Stale.

Destination         Nexthop          Protocol   Prec Cost Interface

*0.0.0.0/0           10.193.82.1      static     1    0    21/1

[Ctx]ASR5000> clear port data counters 21/1

Saturday April 12 14:06:21 UTC 2014

[Ctx]ASR5000> clear port npu count 21/1

Saturday April 12 14:06:21 UTC 2014

[Ctx]ASR5000> ping 10.193.82.1 count 1 size 56

Saturday April 12 14:06:21 UTC 2014

PING 10.193.82.1 (10.193.82.1) 56(84) bytes of data.

64 bytes from 10.193.82.1: icmp_seq=1 ttl=255 time=0.957 ms

--- 10.193.82.1 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 0.957/0.957/0.957/0.000 ms

Note that the datalink counters include the FCS bytes, while both datalink and npu

counters include the ethernet frame and vlan tags.

[Ctx]ASR5000> show port datalink count 21/1

Saturday April 12 14:06:25 UTC 2014

Counters for port 21/1:

Line Card  Gigabit Ethernet Port

Rx Counter                        Data  |  Tx Counter                       Data

-----------------------  -------------- + -----------------------  -------------

RX Unicast frames                   112 | TX Unicast frames                    1

RX Multicast frames                   3 | TX Multicast frames                  0

RX Broadcast frames                   9 | TX Broadcast frames                  0

RX Size   64 frames                   0 | TX Size   64 frames                  0

RX Size   65 ..  127 fr              14 | TX Size   65 ..  127 fr              1

RX Size  128 ..  255 fr               0 | TX Size  128 ..  255 fr              0

RX Size  256 ..  511 fr             110 | TX Size  256 ..  511 fr              0

RX Size  512 .. 1023 fr               0 | TX Size  512 .. 1023 fr              0

RX Size 1024 .. 1518 fr               0 | TX Size 1024 .. 1518 fr              0

RX Size > 1518 frames                 0 | TX Size > 1518 frames                0

RX Bytes OK                       43966 | TX Bytes OK                        106

RX Bytes BAD                          0 | TX Bytes BAD                         0

RX SHORT OK                           0 | TX PAUSE                             0

RX SHORT CRC                          0 | TX ERR                               0

RX OVF                                0 |

RX NORM CRC                           0 |

RX LONG OK                            0 |

RX LONG CRC                           0 |

RX PAUSE                              0 |

RX FALS CRS                           0 |

RX SYM ERR                            0 |

-----------------------  -------------- + -----------------------  -------------

[Ctx]ASR5000> show port npu count 21/1

Saturday April 12 14:06:25 UTC 2014

Counters for port 21/1

Counter                  Rx Frames       Rx Bytes      Tx Frames        Tx Bytes

-------------------- ------------- --------------- ------------- ---------------

Unicast                          1             102             1             102

Multicast                        3             202             0               0

Broadcast                        8             512             0               0

IPv4 unicast                     1             102             1             102

IPv4 non-unicast                 1              66             0               0

IPv6 unicast                     0               0             0               0

IPv6 non-unicast                 0               0             0               0

Fragments received               0               0           n/a             n/a

Packets reassembled              0               0           n/a             n/a

Fragments to kernel              0               0           n/a             n/a

HW error                         0               0           n/a             n/a

Port non-operational             0               0             0               0

SRC MAC is multicast             0               0           n/a             n/a

Unknown VLAN tag                 0               0           n/a             n/a

Other protocols                  2             136           n/a             n/a

Not IPv4                         0               0           n/a             n/a

Bad IPv4 header                  0               0           n/a             n/a

IPv4 MRU exceeded                0               0           n/a             n/a

TCP tiny fragment                0               0             0               0

No ACL match                     0               0             0               0

Filtered by ACL                  0               0             0               0

TTL expired                      0               0           n/a             n/a

Flow lookup twice                0               0           n/a             n/a

Unknown IPv4 class               0               0           n/a             n/a

Too short: IP                    0               0           n/a             n/a

Too short: ICMP                  0               0             0               0

Too short: IGMP                  0               0             0               0

Too short: TCP                   0               0             0               0

Too short: UDP                   0               0             0               0

Too short: IPIP                  0               0           n/a             n/a

Too short: GRE                   0               0           n/a             n/a

Too short: GRE key               0               0           n/a             n/a

Don't frag discards            n/a             n/a             0               0

Fragment packets               n/a             n/a             0               0

Fragment fragments             n/a             n/a             0               0

IPv4VlanMap dropped              0               0           n/a             n/a

IPSec NATT keep alive            0               0           n/a             n/a

MPLS Flow not found              0               0           n/a             n/a

MPLS unicast                     0               0             0               0

Size < 17                        0               0             0               0

Size   17 ..   64                8             512             0               0

Size   65 ..  127                4             304             1             102

Size  128 ..  255                0               0             0               0

Size  256 ..  511                0               0             0               0

Size  512 .. 1023                0               0             0               0

Size 1024 .. 2047                0               0             0               0

Size 2048 .. 4095                0               0             0               0

Size 4096 .. 4500                0               0             0               0

Size > 4500                      0               0             0               0

IP 分段

IP数据包分段是指数据包的大小（包括IP报头，但不包括任何第2层数据，如源/目的MAC、VLAN ID或FSC）被分割成多个网段以符合接口的“ip mtu”设置（默认值1500）。  在本示例中，当MTU设置为默认大小1500时，尝试发送的ICMP负载大小为1472时，不会分段(1472 + ICMP报头(8)+ IP报头(20)= 1500)，但会分段任何大于此大小的ICMP负载。当发生分段时，端口npu和datalink计数器中会计到两个数据包分段，每个适当大小的桶中会计一个。完成500个数据包的泛洪ping操作后，将发送1000个分段；500表示大型，500表示小型。此示例在ASR 5500上运行（与ASR 5000上的前一个输出示例相比），但在两个平台上都同样适用。

[ECS]ASR500> show ip interface

Thursday July 16 00:31:39 UTC 2015

Intf Name:       5/29-ECS

Intf Type:       Broadcast

Description:

VRF:             None

IP State:        UP (Bound to 5/29 vlan id 31, 802.1P prior 0, ifIndex 85786626)

IP Address:      10.213.137.105       Subnet Mask:     255.255.255.0

Bcast Address:   10.213.137.255       MTU: 1500

Resoln Type:     ARP                  ARP timeout:     60 secs

L3 monitor LC-port switchover: Disabled

Number of Secondary Addresses: 0

port ethernet 5/29

no shutdown

vlan 31

no shutdown

bind interface 5/29-ECS ECS

#exit

#exit

首先，为计数器建立基线。指定NPU计数器的VLAN ID（以确认所有ping都附加了VLAN ID）。

[ECS]ASR5500> clear port datalink counters 5/29

Friday July 17 23:53:46 UTC 2015

[ECS]ASR5500> show port datalink counters 5/29

Friday July 17 23:53:46 UTC 2015

rCounters for port 5/29:

Line Card 10 Gigabit Ethernet Port

Rx Counter                        Data  |  Tx Counter                       Data

-----------------------  -------------- + -----------------------  -------------

RX Bytes                            406 | TX Bytes                             0

RX Unicast frames                     0 | TX Unicast frames                    0

RX Multicast frames                   4 | TX Multicast frames                  0

RX Broadcast frames                   1 | TX Broadcast frames                  0

RX Size 64 frames                     0 | TX Size 64 frames                    0

RX Size   65 ..  127 fr               5 | TX Size   65 ..  127 fr              0

RX Size  128 ..  255 fr               0 | TX Size  128 ..  255 fr              0

RX Size  256 ..  511 fr               0 | TX Size  256 ..  511 fr              0

RX Size  512 .. 1023 fr               0 | TX Size  512 .. 1023 fr              0

RX Size 1024 .. 1518 fr               0 | TX Size 1024 .. 1518 fr              0

RX Size 1519 .. 1522 fr               0 | TX Size 1519 .. 1522 fr              0

-----------------------  -------------- + -----------------------  -------------

[ECS]ASR5500> clear port npu counters 5/29 vlan 31

Friday July 17 23:53:47 UTC 2015

[ECS]ASR5500> show port npu counters 5/29 vlan 31

Friday July 17 23:53:47 UTC 2015

Counters for port 5/29 vlan id 31:

Counter                  Rx Frames       Rx Bytes      Tx Frames        Tx Bytes

-------------------- ------------- --------------- ------------- ---------------

Unicast                          0               0             0               0

Multicast                        3             196             0               0

Broadcast                        1              64             0               0

IPv4 unicast                     0               0             0               0

IPv4 non-unicast                 3             196             0               0

IPv6 unicast                     0               0             0               0

IPv6 non-unicast                 0               0             0               0

Fragments received               0               0           n/a             n/a

Packets reassembled              0               0           n/a             n/a

Fragments to kernel              0               0           n/a             n/a

HW error                         0               0           n/a             n/a

Port non-operational           539           38520             0               0

SRC MAC is multicast             0               0           n/a             n/a

Unknown VLAN tag                 0               0           n/a             n/a

Other protocols                  2             128           n/a             n/a

包含IP报头的大小为1500字节的Ping将不分段地发送出去。数据链路层（离开端口时）的总大小为：

1472（负载）+ 8（ICMP报头）+ 20（IP报头）+ 14（MAC源/目的）+ 4(VLAN ID)+ 4(FSC)= 1522

[ECS]ASR5500> ping  10.213.137.1 size 1472 flood

Friday July 17 23:53:48 UTC 2015

PING 10.213.137.1 (10.213.137.1) 1472(1500) bytes of data.

--- 10.213.137.1 ping statistics ---

500 packets transmitted, 500 received, 0% packet loss, time 422ms

rtt min/avg/max/mdev = 0.405/0.800/0.994/0.143 ms, ipg/ewma 0.845/0.802 ms

[ECS]ASR5500> show port datalink counters 5/29

Friday July 17 23:53:54 UTC 2015

Counters for port 5/29:

Line Card 10 Gigabit Ethernet Port

Rx Counter                        Data  |  Tx Counter                       Data

-----------------------  -------------- + -----------------------  -------------

RX Bytes                         771008 | TX Bytes                        765656

RX Unicast frames                   536 | TX Unicast frames                  524

RX Multicast frames                  45 | TX Multicast frames                  0

RX Broadcast frames                  20 | TX Broadcast frames                  0

RX Size 64 frames                     0 | TX Size 64 frames                    0

RX Size   65 ..  127 fr              75 | TX Size   65 ..  127 fr              0

RX Size  128 ..  255 fr              24 | TX Size  128 ..  255 fr             18

RX Size  256 ..  511 fr               2 | TX Size  256 ..  511 fr              6

RX Size  512 .. 1023 fr               0 | TX Size  512 .. 1023 fr              0

RX Size 1024 .. 1518 fr               0 | TX Size 1024 .. 1518 fr              0

RX Size 1519 .. 1522 fr             500 | TX Size 1519 .. 1522 fr            500

RX OverSize frames                    0 | TX OverSize frames                   0

RX UnderSize frames                   0 | TX UnderSize frames                  0

RX ExceedMaxSize frames               0

RX Fragment frames                    0 | TX Fragment frames                   0

RX Jabber frames                      0 | TX Jabber frames                     0

RX Control frames                     0 | TX Control frames                    0

RX Pause frames                       0 | TX Pause frames                      0

RX FCS Error frames                   0 | TX FCS Error frames                  0

RX Length Error frames                0 | TX Length Error frames               0

RX Code Error frames                  0

RX ExMaxSize Err frames               0

-----------------------  -------------- + -----------------------  -------------

[ECS]ASR5500> show port npu counters 5/29 vlan 31

Friday July 17 23:53:54 UTC 2015

Counters for port 5/29 vlan id 31:

Counter                  Rx Frames       Rx Bytes      Tx Frames        Tx Bytes

-------------------- ------------- --------------- ------------- ---------------

Unicast                        520          761900           520          762800

Multicast                       38            2811             0               0

Broadcast                       18            1408             0               0

IPv4 unicast                   538          763308           520          762800

IPv4 non-unicast                30            2027             0               0

IPv6 unicast                     0               0             0               0

IPv6 non-unicast                 8             784             0               0

Fragments received               0               0           n/a             n/a

Packets reassembled              0               0           n/a             n/a

Fragments to kernel              0               0           n/a             n/a

HW error                         0               0           n/a             n/a

Port non-operational          9482          681251             0               0

SRC MAC is multicast             0               0           n/a             n/a

Unknown VLAN tag                 0               0           n/a             n/a

Other protocols                 20            1280           n/a             n/a

Not IPv4                         8             784           n/a             n/a

...

Size    0 ..   63                0               0             0               0

Size   64 ..  127               70            5193             0               0

Size  128 ..  255               24            3408            18            2580

Size  256 ..  511                0               0             6            1980

Size  512 .. 1023                0               0             0               0

Size 1024 .. 2047              500          759000           500          759000

Size 2048 .. 4095                0               0             0               0

Size 4096 .. 8191                0               0             0               0

Size >= 8192                     0               0             0               0

大小增加一个字节会导致分段(> 1500)，因此500个数据包将作为两组500个数据包发送。请注意，在本示例中，ping失败。这可能是因为网络无法处理大于已配置MTU的大小，但这不是本文的重点。

[ECS]ASR5500> ping 10.213.137.1 size 1473 flood

Friday July 17 23:53:55 UTC 2015

PING 10.213.137.1 (10.213.137.1) 1473(1501) bytes of data.

................................................................................

................................................................................

................................................................................

................................................................................

................................................................................

................................................................................

....................^C

--- 10.213.137.1 ping statistics ---

500 packets transmitted, 0 received, 100% packet loss, time 7124ms

, ipg/ewma 14.277/0.000 ms

[ECS]ASR5500> show port datalink counters 5/29

Friday July 17 23:54:05 UTC 2015

Counters for port 5/29:

Line Card 10 Gigabit Ethernet Port

Rx Counter                        Data  |  Tx Counter                       Data

-----------------------  -------------- + -----------------------  -------------

RX Bytes                         786615 | TX Bytes                       1566628

RX Unicast frames                   601 | TX Unicast frames                 1567

RX Multicast frames                 111 | TX Multicast frames                  0

RX Broadcast frames                  47 | TX Broadcast frames                  0

RX Size 64 frames                     0 | TX Size 64 frames         501

RX Size   65 ..  127 fr             190 | TX Size   65 ..  127 fr              2

RX Size  128 ..  255 fr              64 | TX Size  128 ..  255 fr             48

RX Size  256 ..  511 fr               5 | TX Size  256 ..  511 fr             16

RX Size  512 .. 1023 fr               0 | TX Size  512 .. 1023 fr              0

RX Size 1024 .. 1518 fr               0 | TX Size 1024 .. 1518 fr              0

RX Size 1519 .. 1522 fr             500 | TX Size 1519 .. 1522 fr   1000

RX ExceedMaxSize frames               0

RX Fragment frames                    0 | TX Fragment frames                   0

RX Jabber frames                      0 | TX Jabber frames                     0

RX Control frames                     0 | TX Control frames                    0

RX Pause frames                       0 | TX Pause frames                      0

RX FCS Error frames                   0 | TX FCS Error frames                  0

RX Length Error frames                0 | TX Length Error frames               0

RX Code Error frames                  0

RX ExMaxSize Err frames               0

-----------------------  -------------- + -----------------------  -------------

[ECS]ASR5500> show port npu counters 5/29 vlan 31

Friday July 17 23:54:06 UTC 2015

Counters for port 5/29 vlan id 31:

Counter                  Rx Frames       Rx Bytes      Tx Frames        Tx Bytes

-------------------- ------------- --------------- ------------- ---------------

Unicast                        554          766984          1562         1549040

Multicast                       94            6962             0               0

Broadcast                       53            4294             0               0

IPv4 unicast                   607          771278          1562         1549040

IPv4 non-unicast                73            4904             0               0

IPv6 unicast                     0               0             0               0

IPv6 non-unicast                21            2058             0               0

Fragments received               0               0           n/a             n/a

Packets reassembled              0               0           n/a             n/a

Fragments to kernel              0               0           n/a             n/a

HW error                         0               0           n/a             n/a

Port non-operational         25146         1805666             0               0

SRC MAC is multicast             0               0           n/a             n/a

Unknown VLAN tag                 0               0           n/a             n/a

Other protocols                 68            4742           n/a             n/a

Not IPv4                        21            2058           n/a             n/a

...

Size 0 .. 63                0               0           501  19546

Size   64 ..  127              188           14154             2             140

Size  128 ..  255               60            8520            45            6450

Size  256 ..  511                0               0            15            4950

Size  512 .. 1023                0               0             0               0

Size 1024 .. 2047          500 759000 1000         1518000

Size 2048 .. 4095                0               0             0               0

Size 4096 .. 8191                0               0             0               0

Size >= 8192                     0               0             0               0