Example for Configuring MQC to Implement Traffic Policing
Networking Requirements
As shown in Figure 5-11, Tenant 1, Tenant 2, and Tenant 3 are connected to SwitchA and the Switch and connect to the external network through the egress router. The servers of Tenant 1, Tenant 2, and Tenant 3 belong to VLAN 10, VLAN 20, and VLAN 30 respectively.
The rates of traffic from tenants must be limited within proper ranges on the Switch. Table 5-11 lists the required CIRs for the tenants.
Configuration Roadmap
- Create VLANs and add interfaces on the Switch to respective VLANs to enable servers to connect to the external network.
- Configure traffic classifiers on the Switch to classify packets based on VLAN IDs.
- Configure traffic behaviors on the Switch to limit the rates of traffic from the servers.
- Configure a traffic policy on the Switch, associate the traffic behaviors with the traffic classifiers in the traffic policy, and apply the traffic policy to the inbound interface on the Switch.
Procedure
- Create VLANs and configure interfaces.
# Create VLAN 10, VLAN 20, and VLAN 30 on SwitchA.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan batch 10 20 30 [*SwitchA] commit
# Configure 10GE1/0/4 on SwitchA as a trunk interface. Add 10GE1/0/1 to VLAN 10, 10GE1/0/2 to VLAN 20, 10GE1/0/3 to VLAN 30, and 10GE1/0/4 to VLAN 10, VLAN 20, and VLAN 30.
[~SwitchA] interface 10ge 1/0/1 [~SwitchA-10GE1/0/1] port default vlan 10 [*SwitchA-10GE1/0/1] quit [*SwitchA] interface 10ge 1/0/2 [*SwitchA-10GE1/0/2] port default vlan 20 [*SwitchA-10GE1/0/2] quit [*SwitchA] interface 10ge 1/0/3 [*SwitchA-10GE1/0/3] port default vlan 30 [*SwitchA-10GE1/0/3] quit [*SwitchA] interface 10ge 1/0/4 [*SwitchA-10GE1/0/4] port link-type trunk [*SwitchA-10GE1/0/4] port trunk allow-pass vlan 10 20 30 [*SwitchA-10GE1/0/4] quit [*SwitchA] commit
# Create VLANs 10, 20, and 30 on the Switch.
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] vlan batch 10 20 30 [*Switch] commit
# Configure 10GE1/0/1 and 10GE1/0/2 on the Switch as trunk interfaces. Add both 10GE1/0/1 and 10GE1/0/2 to VLAN 10, VLAN 20, and VLAN 30.
[~Switch] interface 10ge 1/0/1 [~Switch-10GE1/0/1] port link-type trunk [*Switch-10GE1/0/1] port trunk allow-pass vlan 10 20 30 [*Switch-10GE1/0/1] quit [*Switch] commit [~Switch] interface 10ge 1/0/2 [~Switch-10GE1/0/2] port link-type trunk [*Switch-10GE1/0/2] port trunk allow-pass vlan 10 20 30 [*Switch-10GE1/0/2] quit [*Switch] commit
- Configure traffic classifiers.
# Configure traffic classifiers c1, c2, and c3 on the Switch to classify service flows from the servers based on VLAN IDs.
[~Switch] traffic classifier c1 [*Switch-classifier-c1] if-match vlan 10 [*Switch-classifier-c1] quit [*Switch] traffic classifier c2 [*Switch-classifier-c2] if-match vlan 20 [*Switch-classifier-c2] quit [*Switch] traffic classifier c3 [*Switch-classifier-c3] if-match vlan 30 [*Switch-classifier-c3] quit [*Switch] commit
- Configure traffic behaviors.
# Create traffic behaviors b1, b2, and b3 on the Switch to limit the rates of service flows.
[~Switch] traffic behavior b1 [*Switch-behavior-b1] car cir 2000 [*Switch-behavior-b1] statistics enable [*Switch-behavior-b1] quit [*Switch] traffic behavior b2 [*Switch-behavior-b2] car cir 4000 [*Switch-behavior-b2] statistics enable [*Switch-behavior-b2] quit [*Switch] traffic behavior b3 [*Switch-behavior-b3] car cir 8000 [*Switch-behavior-b3] statistics enable [*Switch-behavior-b3] quit [*Switch] commit
- Configure a traffic policy and apply it to the inbound interface.
# Create a traffic policy p1 on the Switch, associate the traffic behaviors with traffic classifiers in the traffic policy, and apply the traffic policy to the inbound direction on 10GE1/0/1.
[~Switch] traffic policy p1 [*Switch-trafficpolicy-p1] classifier c1 behavior b1 [*Switch-trafficpolicy-p1] classifier c2 behavior b2 [*Switch-trafficpolicy-p1] classifier c3 behavior b3 [*Switch-trafficpolicy-p1] quit [*Switch] interface 10ge 1/0/1 [*Switch-10GE1/0/1] traffic-policy p1 inbound [*Switch-10GE1/0/1] quit [*Switch] commit
- Verify the configuration.
# View the traffic classifier configuration.
[~Switch] display traffic classifier Traffic Classifier Information: Classifier: c1 Type: OR Rule(s): if-match vlan 10 Classifier: c2 Type: OR Rule(s): if-match vlan 20 Classifier: c3 Type: OR Rule(s): if-match vlan 30 Total classifier number is 3
# View the traffic policy configuration.
[~Switch] display traffic policy p1 Traffic Policy Information: Policy: p1 Classifier: c1 Type: OR Behavior: b1 Committed Access Rate: CIR 2000 (Kbps), PIR 2000 (Kbps), CBS 250000 (Bytes), PBS 250000 (Bytes) Color Mode: color blind Statistics: enable Classifier: c2 Type: OR Behavior: b2 Committed Access Rate: CIR 4000 (Kbps), PIR 4000 (Kbps), CBS 500000 (Bytes), PBS 500000 (Bytes) Color Mode: color blind Statistics: enable Classifier: c3 Type: OR Behavior: b3 Committed Access Rate: CIR 8000 (Kbps), PIR 8000 (Kbps), CBS 1000000 (Bytes), PBS 1000000 (Bytes) Color Mode: color blind Statistics: enable
# View the traffic policy configuration on 10GE1/0/1.
[~Switch] display traffic-policy statistics interface 10ge 1/0/1 inbound Traffic policy: p1, inbound -------------------------------------------------------------------------------- Slot: 1 Item Packets Bytes pps bps ------------------------------------------------------------------------------- Matched 262685 26268500 2000 1600744 Passed 262685 26268500 2000 1600744 Dropped 0 0 0 0 Filter 0 0 0 0 CAR 0 0 0 0 -------------------------------------------------------------------------------
Configuration Files
Switch configuration file
# sysname Switch # vlan batch 10 20 30 # traffic classifier c1 type or if-match vlan 10 # traffic classifier c2 type or if-match vlan 20 # traffic classifier c3 type or if-match vlan 30 # traffic behavior b1 statistics enable car cir 2000 kbps # traffic behavior b2 statistics enable car cir 4000 kbps # traffic behavior b3 statistics enable car cir 8000 kbps # traffic policy p1 classifier c1 behavior b1 precedence 5 classifier c2 behavior b2 precedence 10 classifier c3 behavior b3 precedence 15 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 20 30 traffic-policy p1 inbound # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 10 20 30 # return
SwitchA configuration file
# sysname SwitchA # vlan batch 10 20 30 # interface 10GE1/0/1 port default vlan 10 # interface 10GE1/0/2 port default vlan 20 # interface 10GE1/0/3 port default vlan 30 # interface 10GE1/0/4 port link-type trunk port trunk allow-pass vlan 10 20 30 # return