一直以来SPAN都是作为排查丢包问题很好用的feature, 但是在XR低版本上存在很多的限制,比如只支持local SPAN, 只能要求现场有人协助连个PC,将流量SPAN到PC上进行抓包,现在从XR 7.1.2 版本开始我们支持将SPAN的流量保存成一个文件,可以直接远程从设备上copy 出来。
SPAN Feature Support
| ASR9k | DNX | SpitFire | |
|---|---|---|---|
| Local SPAN | Supported-3.9.1 | NCS5500: Supported-6.1.1 | Being targetted for 7.2.1 |
| Remote SPAN | Supported-3.9.1 | ||
| Sampled SPAN | Supported-5.1.0 | ||
| ERSPAN | No | NCS5500: Supported- 6.1.31 | Supported-7.2.1 |
| MPLS-ERSPAN | |||
| PW-SPAN | Supported- 4.0.1 | Supported- 7.0.1 ( no support in 71x) | No |
| ACL Based Traffic Mirroring | Supported-4.0.1 | NCS5500: Supported-6.1.1NCS560: SupportedNCS540: Supported | Supported |
| SPAN to File | 7.1.2 | 7.1.2 | 7.2.2 |
| SPAN to File PCAPng | No | 7.3.1 | No |
| CloudSpan | No | No | No |
配置说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #### 不同版本或许有些许出入, 一切以CCO文档为准monitor-session [span_name] ethernet destination file size [size] [buffer-type linear]interface [interface_name] monitor-session [span_name] ethernet [direction rx-only] port-level buffer type 有两种, Linear/Circular, 默认不配置是Circular。Linear:一旦缓冲区已满,就不会记录更多数据包。Circular:一旦缓冲区已满,开始覆盖存储数据包。SPAN to File 提供了 1000-1000000 KB 的缓冲区范围。默认缓冲区大小设置为 1000 KB。 ### Start/stop packet capture默认配置完以上的配置是不会自动开启capture的,需要额外命令start/stopmonitor-session <name> packet-collection startmonitor-session <name> packet-collection stop [ discard-data | write directory <dir> filename <filename> ]如果添加discard-data选项,则简单地清除缓冲区,而如果write指定了该选项,则在清除之前将缓冲区写入磁盘。 |
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | IXIA ---Ten0/0/0/1--- NCS55A1---- Other RouterIXIA 会持续发送100Mbps的穿越流量给NCS55, 100Mbps = 12.5MB/sRP/0/RP0/CPU0:NCS-55A2-12#monitor interface TenGigE0/0/0/0 TenGigE0/0/0/1 Sun Jun 6 05:54:07.887 UTCNCS-55A2-12 Monitor Time: 00:00:40 SysUptime: 75:42:59Protocol:GeneralInterface In(bps) Out(bps) InBytes/Delta OutBytes/DeltaTe0/0/0/0 1000/ 0% 100.4M/ 1% 48.5M/0 37.3G/25.0M <<<<<<<Te0/0/0/1 99.6M/ 0% 0/ 0% 304.1G/24.8M 8.0G/170 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/RP0/CPU0:NCS-55A2-12#show run monitor-session % Incomplete command.RP/0/RP0/CPU0:NCS-55A2-12#show run monitor-session span_to_fileSun Jun 6 06:06:37.404 UTCmonitor-session span_to_file ethernet destination file size 1000000!RP/0/RP0/CPU0:NCS-55A2-12#show run int tenGigE 0/0/0/1Sun Jun 6 06:06:50.713 UTCinterface TenGigE0/0/0/1 cdp vrf GLOBAL ipv4 address 100.1.1.1 255.255.255.0 ipv6 address 2012::1/64 monitor-session span_to_file ethernet port-level ! load-interval 30!RP/0/RP0/CPU0:NCS-55A2-12#monitor-session span_to_file packet-collection startSun Jun 6 05:51:48.480 UTCRP/0/RP0/CPU0:NCS-55A2-12#monitor-session span_to_file packet-collection stop write directory /misc/disk1 filename span_to_fileSun Jun 6 05:52:22.473 UTC</misc/disk1> 为harddisk:, Ten0/0/0/1 属于板卡0/0/CPU0 ,所以文件会存储在node0_0_CPU0 中[xr-vm_node0_RP0_CPU0:~]$cd /misc/disk1/node0_0_CPU0[xr-vm_node0_RP0_CPU0:/misc/disk1/node0_0_CPU0]$ls -lhtotal 157M-rw-r--r--. 1 root root 157M Jun 6 05:52 span_to_file.pcap[xr-vm_node0_RP0_CPU0:/misc/disk1/node0_0_CPU0]$或者RP/0/RP0/CPU0:NCS-55A2-12#dir harddisk:/node0_0_CPU0Sun Jun 6 06:20:03.560 UTCDirectory of harddisk:/node0_0_CPU0783365 -rw-r--r--. 1 164039152 Jun 6 05:52 span_to_file.pcap |
把文件从设备上COPY出来, 这里用了SCP
1 2 3 4 5 6 | xuxing@XUXING-WT1:/mnt/c/Users/xuxing.CISCO/Desktop$ scp admin@10.122.166.235:/misc/disk1/node0_0_CPU0/span_to_file.pcap .Password:span_to_file.pcap 4% 7088KB 225.7KB/s 11:18 ETAspan_to_file.pcap |
注意
- 2021-06-06
测试发现, SPAN采集了34s, 理论上应该是34X12.5=425MB的流量被存储下来, 但是只生成的157MB的文件,是有些数据包没有被dump下来, 因为我使用的软件版本是测试版本,不确认这个情况为该feature的问题还是因为我这个测试版本不完善导致, 后续如果有时间再找个设备测试下。
the blog from link: http://imxing.cn/?p=1195
No comments:
Post a Comment