< Home

Example for Configuring Traffic Statistics Collection

Networking Requirements

In Figure 1, the MAC address of PC1 is 0000-0000-0003, and PC1 connects to GE0/0/1 on the Switch. The Switch is required to collect statistics on packets with the source MAC address of 0000-0000-0003.

Figure 1 Networking for traffic statistics collection

Configuration Roadmap

You can define the traffic statistics collection action in a traffic policy. The configuration roadmap is as follows:
  1. Configure interfaces so that the Switch can connect to the router and PC1.
  2. Configure an ACL to match packets with the source MAC address of 0000-0000-0003.
  3. Configure a traffic classifier and reference the ACL in the traffic classifier.
  4. Configure a traffic behavior so that the Switch collects statistics on packets matching rules.
  5. Configure a traffic policy, bind the traffic classifier and traffic behavior to the traffic policy, and apply the traffic policy to the inbound direction of GE0/0/1 so that the Switch collects statistics on packets with the source MAC address of 0000-0000-0003.

Procedure

  1. Create VLANs and configure interfaces.

    # Create VLAN 20 on the Switch.

    <HUAWEI> system-view
    [HUAWEI] sysname Switch
    [Switch] vlan 20
    [Switch-vlan20] quit
    

    # Configure GE0/0/1 as an access interface and GE0/0/2 as a trunk interface, and add them to VLAN 20.

    [Switch] interface gigabitethernet 0/0/1
    [Switch-GigabitEthernet0/0/1] port link-type access
    [Switch-GigabitEthernet0/0/1] port default vlan 20
    [Switch-GigabitEthernet0/0/1] quit
    [Switch] interface gigabitethernet 0/0/2
    [Switch-GigabitEthernet0/0/2] port link-type trunk
    [Switch-GigabitEthernet0/0/2] port trunk allow-pass vlan 20
    [Switch-GigabitEthernet0/0/2] quit
    

    # Create VLANIF 20 and configure IP address 10.10.10.2/24 for it.

    [Switch] interface vlanif 20
    [Switch-Vlanif20] ip address 10.10.10.2 24
    [Switch-Vlanif20] quit
    

    Configure IP address 10.10.10.1/24 for the router interface connected to the Switch.

  2. Configure an ACL.

    # Create ACL 4000 (Layer 2 ACL) on the Switch to match packets with the source MAC address of 0000-0000-0003.

    [Switch] acl 4000
    [Switch-acl-L2-4000] rule permit source-mac 0000-0000-0003 ffff-ffff-ffff
    [Switch-acl-L2-4000] quit
    

  3. Configure a traffic classifier.

    # Create a traffic classifier c1 on the Switch and reference ACL 4000 in the traffic classifier.

    [Switch] traffic classifier c1 operator and
    [Switch-classifier-c1] if-match acl 4000
    [Switch-classifier-c1] quit
    

  4. Configure a traffic behavior.

    # Create a traffic behavior b1 on the Switch and configure the traffic statistics collection action in the traffic behavior.

    [Switch] traffic behavior b1
    [Switch-behavior-b1] statistic enable
    [Switch-behavior-b1] quit
    

  5. Configure a traffic policy and apply the traffic policy to an interface.

    # Create a traffic policy p1 on the Switch and bind the traffic classifier and traffic behavior to the traffic policy.

    [Switch] traffic policy p1
    [Switch-trafficpolicy-p1] classifier c1 behavior b1
    [Switch-trafficpolicy-p1] quit
    

    # Apply the traffic policy p1 to GE0/0/1.

    [Switch] interface gigabitethernet 0/0/1
    [Switch-GigabitEthernet0/0/1] traffic-policy p1 inbound
    [Switch-GigabitEthernet0/0/1] quit
    

  6. Verify the configuration.

    # View the ACL configuration.

    [Switch] display acl 4000
    L2 ACL 4000, 1 rule
    Acl's step is 5
     rule 5 permit source-mac 0000-0000-0003 
    

    # View the traffic classifier configuration.

    [Switch] display traffic classifier user-defined
      User Defined Classifier Information:                                          
       Classifier: c1                                                               
        Operator: AND                                                                
        Rule(s) : if-match acl 4000  
    
    Total classifier number is 1  

    # View the traffic policy configuration.

    [Switch] display traffic policy user-defined p1
      User Defined Traffic Policy Information:                                      
      Policy: p1                                                                    
       Classifier: c1                                                               
        Operator: AND                                                                
         Behavior: b1                                                               
          Statistic: enable 
    

    # View the traffic statistics.

    [Switch] display traffic policy statistics interface gigabitethernet 0/0/1 inbound
                                                                                    
     Interface: GigabitEthernet0/0/1                                                       
     Traffic policy inbound: p1                                                     
     Rule number: 1                                                                 
     Current status: success                                                            
     Statistics interval: 300                         
    ---------------------------------------------------------------------           
     Board : 0                           
    ---------------------------------------------------------------------       
     Matched          |      Packets:                             0                 
                      |      Bytes:                               0                 
                      |      Rate(pps):                           0                 
                      |      Rate(bps):                           0                 
    ---------------------------------------------------------------------           
       Passed         |      Packets:                             0                 
                      |      Bytes:                               0                 
                      |      Rate(pps):                           0                 
                      |      Rate(bps):                           0                 
    ---------------------------------------------------------------------           
       Dropped        |      Packets:                             0                 
                      |      Bytes:                               0                 
                      |      Rate(pps):                           0                 
                      |      Rate(bps):                           0                 
    ---------------------------------------------------------------------           
         Filter       |      Packets:                             0                 
                      |      Bytes:                               0                 
    ---------------------------------------------------------------------           
         Car          |      Packets:                             0                 
                      |      Bytes:                               0                 
    ---------------------------------------------------------------------

Configuration Files

  • Switch configuration file

    #
    sysname Switch
    #
    vlan batch 20
    #
    acl number 4000
     rule 5 permit source-mac 0000-0000-0003 
    #
    traffic classifier c1 operator and
     if-match acl 4000
    #
    traffic behavior b1
     statistic enable
    #
    traffic policy p1 match-order config
     classifier c1 behavior b1 
    #
    interface Vlanif20
     ip address 10.10.10.2 255.255.255.0
    #                                                                               
    interface GigabitEthernet0/0/1
     port link-type access                                                           
     port default vlan 20                                                   
     traffic-policy p1 inbound                                                      
    #                                                                               
    interface GigabitEthernet0/0/2
     port link-type trunk                                                           
     port trunk allow-pass vlan 20                                                   
    #
    return
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic