Skip to main content

XR Embedded Packet Tracer

·381 words·2 mins
Rory
Author
Rory
Step by step the ladder is ascended

喜大普奔,XR 终于出了内置的 Packet Tracer 工具了(类似的 XE 中也提供类似的 feature,不过应该是很早就支持了)。该工具作用是用于跟踪数据包进入路由器后经过的组件,监视数据包信息,查找数据包丢失或最后一次见到的位置 .

如我们常用的 ACL 匹配数据包一样,需要设定特定的匹配条件,然后执行该内置的工具进行数据包的匹配。

Packet Tracer Conditions - Offset/Value/Mask
#

如何生成这个匹配条件,我们提供了一个 web 工具,如下,包含丰富的数据包类型:

该 Web 工具发布在 Github,可以参考以下 link 完成安装使用:

https://github.com/xr-packet-tracer/xr-embedded-packet-tracer-condition-generator

[root@xuxing ~]# wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
[root@xuxing ~]# nvm install 12.14.1    <<< 安装12.14.1的node
[root@xuxing ~]# git clone https://github.com/xr-packet-tracer/xr-embedded-packet-tracer-condition-generator
[root@xuxing ~]# cd xr-embedded-packet-tracer-condition-generator/
[root@xuxing xr-embedded-packet-tracer-condition-generator]# npm install
[root@xuxing xr-embedded-packet-tracer-condition-generator]# npm start

Compiled successfully!

You can now view packet-tracer-condition in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://10.75.49.238:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.
  • 2023-01-26 更新如下:

上述 install 过程是在一台 centos7 上操作了,默认安装 nvm 后 node 和 npm 的 version 都很高;这样就导致后续执行 npm install 和 start 的时候会有很多的报错,导致服务起不来,所以这里使用了nvm install 12.14.1 更改 node 的 version 为 12.14.1,这个时候执行 node -v 和 npm -v 就会看到以下的版本:

$ node -v
v12.14.1
$ npm -v
6.13.4

后续我又尝试在 MAC OS 上装了一遍,发现 MAC OS 上即使 node/npm 的 version 很高有报错, 最后的服务也可以起起来,不得不服!!!

# brew install node
# git clone https://github.com/xr-packet-tracer/xr-embedded-packet-tracer-condition-generator
# npm install
# npm start

~ ❯ npm -v
9.3.1

~ ❯ node -v
v19.5.0

~ ❯

Packet Trace Use Case
#

这里使用一个很简单的环境测试下这个 feature,用来抓取 ICMP 数据包进入路由器后的路径。

RP/0/RSP0/CPU0:9901-2#packet-trace condition interface tenGigE 0/0/0/30
RP/0/RSP0/CPU0:9901-2#packet-trace condition 1 Offset 23 Value 0x01 Mask 0xff
RP/0/RSP0/CPU0:9901-2#packet-trace condition 2 Offset 26 Value 0x7b7b7a02 Mask 0xffffffff
RP/0/RSP0/CPU0:9901-2#packet-trace condition 3 Offset 30 Value 0x7b7b7a01 Mask 0xffffffff
RP/0/RSP0/CPU0:9901-2#packet-trace start
RP/0/RSP0/CPU0:9901-2#ping 123.123.122.2 count  1000
Wed Aug 26 04:11:01.157 HKT
Type escape sequence to abort.
Sending 1000, 100-byte ICMP Echos to 123.123.122.2, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (1000/1000), round-trip min/avg/max = 1/1/12 ms
RP/0/RSP0/CPU0:9901-2#show packet-trace results
Wed Aug 26 04:11:14.893 HKT
T: D - Drop counter; P - Pass counter
Location     | Source       | Counter                   | T | Last-Attribute                           | Count
------------ ------------ ------------------------- - ---------------------------------------- ---------------
0/0/CPU0       NP1            PACKET_MARKED               P   TenGigE0_0_0_30                            1000
0/0/CPU0       NP1            PACKET_TO_PUNT              P                                              1000
0/RSP0/CPU0    SPP_PD         PKT_SPP_PD_PUNT_DROP        D                                              1

Other userful command
#

// 清除之前的一些设置
#packet-trace atop
#clear packet-trace conditions all
#clear packet-trace counters all

//show command
#show packet-trace status
#show packet-trace status detail
#show packet-trace descriptions
#show packet-trace results counter PACKET_MARKED location 0/0/CPU0
#show packet-trace results counter PACKET_MARKED source NP1 location 0/0/CPU0

限制
#

7.1.2 开始,5th, 4th and 3rd generation line cards (aka Lightspeed Plus, Lighstpeed, Tomahawk).

Reference
#

XR Embedded Packet Tracer