假设电脑192.168.1.2在ping路由器192.168.1.1时丢包,想确认中间的交换机转发报文是否有问题,可以在交换机上做流量统计进行准确确认。

 

网络拓扑示例图如下:

 

20170508160529817001.png
在中间的交换机上做流量统计的步骤如下:

 

一、配置流量统计功能

1、从用户视图切换到系统视图

<Huawei>system-view

2、创建ACL3333匹配ping请求报文,ACL3334匹配ping响应报文

[Huawei]acl 3333

[Huawei-acl-adv-3333]rule 5 permit icmp source 192.168.1.2 0 destination 192.168.1.1 0

[Huawei-acl-adv-3333]quit

[Huawei]acl 3334

[Huawei-acl-adv-3334] rule 5 permit icmp source 192.168.1.1 0 destination 192.168.1.2 0

[Huawei-acl-adv-3334]quit

3、配置流分类,引用前面配置的ACL规则

[Huawei]traffic classifier test1

[Huawei-classifier-test1] if-match acl 3333

[Huawei-classifier-test1]quit

[Huawei]traffic classifier test2

[Huawei-classifier-test2] if-match acl 3334

[Huawei-classifier-test2]quit

4、配置流行为,启用计数功能

[Huawei]traffic behavior test1

[Huawei-behavior-test1]statistic enable

[Huawei-behavior-test1]quit

[Huawei]traffic behavior test2

[Huawei-behavior-test2]statistic enable

[Huawei-behavior-test2]quit

5、配置流策略,将流分类和流行为关联

[Huawei]traffic policy test1

[Huawei-trafficpolicy-test1]classifier test1 behavior test1

[Huawei-trafficpolicy-test1]quit

[Huawei]traffic policy test2

[Huawei-trafficpolicy-test2]classifier test2 behavior test2

[Huawei-trafficpolicy-test2]quit

6、在连接电脑的接口上应用流策略

[Huawei]interface GigabitEthernet 0/0/2

[Huawei-GigabitEthernet0/0/2]traffic-policy test1 inbound

[Huawei-GigabitEthernet0/0/2]traffic-policy test2 outbound

[Huawei-GigabitEthernet0/0/2]quit

7、在连接路由器的接口上应用流策略

[Huawei]interface GigabitEthernet 0/0/1

[Huawei-GigabitEthernet0/0/1]traffic-policy test2 inbound

[Huawei-GigabitEthernet0/0/1]traffic-policy test1 outbound

[Huawei-GigabitEthernet0/0/1]quit

 

二、测试并查看统计结果

(1)用电脑192.168.1.2去ping路由器192.168.1.1。

(2)查看统计结果

查看ping请求:

display traffic policy statistics interface GigabitEthernet 0/0/2 inbound

display traffic policy statistics interface GigabitEthernet 0/0/1 outbound

查看ping响应:

display traffic policy statistics interface GigabitEthernet 0/0/1 inbound

display traffic policy statistics interface GigabitEthernet 0/0/2 outbound

 

查看结果示例如下(以ping10个包为例):

 

20161219155307340002.png

上面是查看对ping请求报文转发的结果。结果表明,收到10个报文,并转发了10个报文

 

 

20161219155308825003.png

上面是查看对ping响应报文转发的结果。结果表明,收到10个报文,并转发了10个报文

 

:如果想在下次统计前清除之前的结果,可以使用以下命令进行清除统计计数(注意:需要在用户视图下操作)。

reset traffic policy statistics interface GigabitEthernet 0/0/2 inbound

reset traffic policy statistics interface GigabitEthernet 0/0/1 outbound

reset traffic policy statistics interface GigabitEthernet 0/0/1 inbound

reset traffic policy statistics interface GigabitEthernet 0/0/2 outbound