This section provides an example of how to configure traffic policing and traffic shaping on interfaces.
Networking Requirements
GE 0/3/0 of Device A is connected to GE 0/1/0 of Device B. Server, PC1, and PC2 can access the Internet through Devices A and B.
Server, PC1, and GE 0/1/0 of Device A are on the same network segment. PC2 and GE 0/2/0 of Device A are on the same network segment.
The traffic from Server and PC1 to GE 0/1/0 is controlled on Device A as follows:
-
A maximum of 6 Mbit/s bandwidth is assured for the traffic from Server. The bandwidth is always 5 Mbit/s in this example. For traffic of which the rate exceeds 5 Mbit/s but is less than or equal to 6 Mbit/s, packets are forwarded properly. When the traffic rate exceeds 6 Mbit/s, nonconforming traffic is treated and forwarded as BE traffic.
-
The rate limit on the traffic from PC1 is 2 Mbit/s. When the traffic rate exceeds the rate limit, nonconforming traffic is dropped.
GE 0/3/0 on Device A and GE 0/2/0 on Device B have the following requirements for sending and receiving packets:
-
The rate of the EF traffic arriving at Device B through GE 0/3/0 of Device A is limited to 20 Mbit/s. When the traffic rate exceeds the rate limit, nonconforming traffic is dropped.
-
The rate of the EF traffic arriving at the Internet through GE 0/2/0 of Device B is limited to 30 Mbit/s. When the traffic rate exceeds the rate limit, nonconforming traffic is dropped.
Table 1
|
||
Device name
|
Interface
|
IP address
|
DeviceA
|
GE0/1/0
|
1.1.1.3/24
|
GE0/3/0
|
2.1.1.2/24
|
|
DeviceB
|
GE0/1/0
|
2.1.1.3/24
|
GE0/2/0
|
2.2.2.1/24
|
Precautions
When configuring traffic shaping, note the following points:
-
If the CoS of a packet is re-marked as EF, BE, CS6, or CS7, the packet can be re-marked green only.
-
To view the statistics about a traffic policy, you can use the statistics enable command to enable the statistics function for the traffic policy.
Configuration Roadmap
The configuration roadmap is as follows:
-
On the inbound interface GE 0/1/0 of Device A, perform complex traffic classification based-traffic policing for traffic from Server and PC1.
-
On the outbound interface GE 0/3/0 of Device A, configure traffic shaping so that the rate of the EF traffic that arrives at Device B is limited to 20 Mbit/s.
-
On the outbound interface GE 0/2/0 of Device B, configure traffic shaping so that the rate of the EF traffic entering the Internet from this interface is limited to 30 Mbit/s.
Data Preparation
To complete the configuration, you need the following data:
-
Access Control List (ACL) numbers, traffic classifier names, traffic behavior names, traffic policy names, and the interfaces on which traffic policies are applied, for the traffic from Server and PC1
-
Committed information rate (CIR), peak information rate (PIR), committed burst size (CBS), and peak burst size (PBS) for traffic shaping
-
Traffic rate for traffic shaping and the interface on which traffic shaping is configured
Procedure
- Configure an IP address for each interface. The configuration details are not provided here.
- Configure Device A.
# Configure ACL rules for data flows from Server and PC1.
<DeviceA> system-view
[~DeviceA] acl number 2001
[*DeviceA-acl4-basic-2001] rule permit source 1.1.1.1 0.0.0.0
[*DeviceA-acl4-basic-2001] commit
[~DeviceA-acl4-basic-2001] quit
[~DeviceA] acl number 2002
[*DeviceA-acl4-basic-2002] rule permit source 1.1.1.2 0.0.0.0
[*DeviceA-acl4-basic-2002] commit
[~DeviceA-acl4-basic-2002] quit
# Configure traffic classifiers and define ACL-based matching rules.[~DeviceA] traffic classifier class1
[*DeviceA-classifier-class1] if-match acl 2001
[*DeviceA-classifier-class1] commit
[~DeviceA-classifier-class1] quit
[~DeviceA] traffic classifier class2
[*DeviceA-classifier-class2] if-match acl 2002
[*DeviceA-classifier-class2] commit
[~DeviceA-classifier-class2] quit
# Define a traffic behavior. Set the bandwidth for the traffic from Server to 5 Mbit/s and the maximum bandwidth to 6 Mbit/s. The traffic of which the rate exceeds 5 Mbit/s but is lower than or equal to 6 Mbit/s is forwarded. When the traffic rate exceeds 6 Mbit/s, nonconforming traffic is treated and forwarded as BE traffic.[~DeviceA] traffic behavior behavior1
[*DeviceA-behavior-behavior1] car cir 5000 pir 6000 green pass yellow pass red pass service-class be color green
[*DeviceA-behavior-behavior1] commit
[~DeviceA-behavior-behavior1] quit
# Define a traffic behavior. Set the rate limit on the traffic from PC1 to 2 Mbit/s. When the traffic rate exceeds 2 Mbit/s, nonconforming traffic is dropped.[~DeviceA] traffic behavior behavior2
[*DeviceA-behavior-behavior2] car cir 2000 green pass yellow discard red discard
[*DeviceA-behavior-behavior2] commit
[~DeviceA-behavior-behavior2] quit
# Define a traffic policy to associate traffic classifiers with traffic behaviors.[~DeviceA] traffic policy policy1
[*DeviceA-trafficpolicy-policy1] classifier class1 behavior behavior1
[*DeviceA-trafficpolicy-policy1] classifier class2 behavior behavior2
[*DeviceA-trafficpolicy-policy1] commit
[~DeviceA-trafficpolicy-policy1] quit
# Apply the traffic policy to GE 0/1/0.[~DeviceA] interface gigabitethernet 0/1/0
[~DeviceA-GigabitEthernet0/1/0] undo shutdown
[*DeviceA-GigabitEthernet0/1/0] traffic-policy policy1 inbound
[*DeviceA-GigabitEthernet0/1/0] commit
# Configure traffic shaping on GE 0/3/0 of Device A to shape the traffic sent from this interface (dropping traffic of which the rate is greater than 20 Mbit/s) so that the packet loss ratio on GE 0/1/0 of Device B is lowered.[~DeviceA] interface gigabitethernet 0/3/0
[~DeviceA-GigabitEthernet0/3/0] undo shutdown
[*DeviceA-GigabitEthernet0/3/0] port shaping 20
[*DeviceA-GigabitEthernet0/3/0] commit
- Configure Device B.
# Configure traffic shaping on GE 0/2/0.
<*DeviceB> system-view
[~DeviceB] interface gigabitethernet0/2/0
[~DeviceB-GigabitEthernet0/2/0] undo shutdown
[*DeviceB-GigabitEthernet0/2/0] port shaping 30
[*DeviceB-GigabitEthernet0/2/0] commit
[~DeviceB-GigabitEthernet0/2/0] return
- Verify the configuration.
Run the display interface command to check traffic information on Device B.
Configuration Files
-
Configuration file of Device A
#
sysname DeviceA
#
acl number 2001
rule 5 permit source 1.1.1.1 0
#
acl number 2002
rule 5 permit source 1.1.1.2 0
#
traffic classifier class1 operator or
if-match acl 2001
traffic classifier class2 operator or
if-match acl 2002
#
traffic behavior behavior1
car cir 5000 pir 6000 green pass yellow pass red pass service-class be color green
traffic behavior behavior2
car cir 2000 green pass yellow discard red discard
#
traffic policy policy1
classifier class1 behavior behavior1 precedence 5
classifier class2 behavior behavior2 precedence 10
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 1.1.1.3 255.255.255.0
traffic-policy policy1 inbound
#
interface GigabitEthernet0/3/0
undo shutdown
ip address 2.1.1.2 255.255.255.0
port shaping 20
#
ospf 1
area 0.0.0.0
network 1.1.1.0 0.255.255.255
network 2.1.1.0 0.0.0.255
#
return
-
Configuration file of Device B
#
sysname DeviceB
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 2.2.2.1 255.255.255.0
port shaping 30
#
ospf 1
area 0.0.0.0
network 2.2.2.0 0.0.0.255
network 2.1.1.0 0.0.0.255
#
return
(Visited 657 times, 1 visits today)