Example for Configuring Traffic Statistics
Networking Requirements
As shown in Figure 10-2, the tenant device is connected to the external network device through the Switch on the data center network. 802.1p priorities of storage service packets and data service packets are 6 and 2 respectively. The tenant requires that statistics on storage service packets be collected to determine bandwidth allocation.
Configuration Roadmap
- Create VLANs and configure interfaces so that the Switch can connect to external network devices.
- Configure an ACL to match packets with 802.1p priorities of 6.
- Configure a traffic classifier and reference the ACL in the traffic classifier.
- Configure a traffic behavior so that the Switch collects statistics on packets matching rules.
- Configure a traffic policy, bind the traffic policy to the traffic classifier and traffic behavior, and apply the traffic policy to 10GE1/0/2 in the inbound direction so that the Switch collects statistics on packets with 802.1p priorities of 6.
Procedure
- Create a VLAN and configure interfaces.
# Create VLAN 100.
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] vlan 100 [*Switch-vlan100] quit [*Switch] commit
# Configure 10GE1/0/1 and 10GE1/0/2 on the Switch as trunk interfaces and add them to VLAN 100.
[~Switch] interface 10ge 1/0/1 [~Switch-10GE1/0/1] port link-type trunk [*Switch-10GE1/0/1] port trunk allow-pass vlan 100 [*Switch-10GE1/0/1] quit [*Switch] interface 10ge 1/0/2 [*Switch-10GE1/0/2] port link-type trunk [*Switch-10GE1/0/2] port trunk allow-pass vlan 100 [*Switch-10GE1/0/2] quit [*Switch] commit
# Configure 10GE1/0/2 on SwitchA as a trunk interface and add 10GE1/0/1 and 10GE1/0/2 to VLAN 100.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] interface 10ge 1/0/1 [~SwitchA-10GE1/0/1] port default vlan 100 [*SwitchA-10GE1/0/1] quit [*SwitchA] interface 10ge 1/0/2 [*SwitchA-10GE1/0/2] port link-type trunk [*SwitchA-10GE1/0/2] port trunk allow-pass vlan 100 [*SwitchA-10GE1/0/2] quit [*SwitchA] commit
- Configure an ACL.
# Create ACL 4000 (Layer 2 ACL) on the Switch to match packets with 802.1p priorities of 6.
[~Switch] acl 4000 [*Switch-acl-L2-4000] rule permit 8021p 6 [*Switch-acl-L2-4000] quit [*Switch] commit
- Configure a traffic classifier.
Create a traffic classifier c1 on the Switch and reference ACL 4000 in the traffic classifier.
[~Switch] traffic classifier c1 [*Switch-classifier-c1] if-match acl 4000 [*Switch-classifier-c1] quit [*Switch] commit
- Configure a traffic behavior.
# Create a traffic behavior b1 on the Switch and configure the traffic statistics action in the traffic behavior.
[~Switch] traffic behavior b1 [*Switch-behavior-b1] statistics enable [*Switch-behavior-b1] quit [*Switch] commit
- Configure a traffic policy and apply the traffic policy
to an interface.
# Create a traffic policy p1 on the Switch and bind the traffic policy to the traffic classifier and traffic behavior.
[~Switch] traffic policy p1 [*Switch-trafficpolicy-p1] classifier c1 behavior b1 [*Switch-trafficpolicy-p1] quit [*Switch] commit
# Apply the traffic policy p1 to the inbound direction of 10GE1/0/2.
[~Switch] interface 10ge 1/0/2 [~Switch-10GE1/0/2] traffic-policy p1 inbound [*Switch-10GE1/0/2] quit [*Switch] commit [~Switch] quit
- Verify the configuration.
# View the ACL configuration.
<Switch> display acl 4000 L2 ACL 4000, 1 rule ACL's step is 5 rule 5 permit 8021p 6 (0 times matched)
# View the traffic classifier configuration.
<Switch> display traffic classifier c1 Traffic Classifier Information: Classifier: c1 Type: OR Rule(s): if-match acl 4000
# View the traffic policy configuration.
<Switch> display traffic policy p1 Traffic Policy Information: Policy: p1 Classifier: c1 Type: OR Behavior: b1 Statistics: enable
# View the traffic statistics.
<Switch> display traffic-policy statistics interface 10ge 1/0/2 inbound Traffic policy: p1, inbound -------------------------------------------------------------------------------- Slot: 1 Item Packets Bytes pps bps ------------------------------------------------------------------------------- Matched 212185 22067448 1600 1379215 Passed 212185 22067448 1600 1379215 Dropped 0 0 0 0 Filter 0 0 0 0 CAR 0 0 0 0 -------------------------------------------------------------------------------
Configuration Files
Switch configuration file
# sysname Switch # vlan batch 100 # acl number 4000 rule 5 permit 8021p 6 # traffic classifier c1 type or if-match acl 4000 # traffic behavior b1 statistics enable # traffic policy p1 classifier c1 behavior b1 precedence 5 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 100 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 100 traffic-policy p1 inbound # return
SwitchA configuration file
# sysname SwitchA # vlan batch 100 # interface 10GE1/0/1 port default vlan 100 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 100 # return