Traffic shaping controls the rate of outgoing packets to allow the traffic rate to match that on the downstream device. When traffic is transmitted from a high-speed link to a low-speed link or a traffic burst occurs, the inbound interface of the low-speed link is prone to severe data loss. To prevent this problem, traffic shaping must be configured on the outbound interface of the device connecting to the low-speed link, as shown in Figure 1.
As shown in Figure 2, traffic shaping can be configured on the outbound interface of an upstream device to make irregular traffic transmitted at an even rate, preventing traffic congestion on the downstream device.
Traffic shaping buffers overspeed packets and uses token buckets to transmit these packets afterward at an even rate.
On router, tokens are added at an interval, which is calculated in the format of CBS/CIR, with the quantity equal to the CBS for traffic shaping.
On router, the length of the frame header and CRC field are calculated in the bandwidth for packets to which CAR applies but not calculated in the bandwidth for packets that have been implemented with traffic shaping. For example, if the traffic shaping value is set to 23 Mbit/s for IPoE packets, the IP packets are transmitted at a rate of 23 Mbit/s with the lengths of the frame header and CRC field not counted.
In addition, whether the CBS can be modified in traffic shaping is determined by the product model, product version, and board type.
Traffic shaping is implemented for packets that have been implemented with queue scheduling and are leaving the queues. For details about queues and queue scheduling, see Congestion Management and Avoidance.
There are two traffic shaping modes: queue-based traffic shaping and interface-based traffic shaping.
No. |
Time |
Packet Length |
Tokens in Bucket C Before Packet Processing |
Tokens in Bucket C After Packet Processing |
Processing Result |
Queue Status Before Packet Processing |
Queue Status After Packet Processing |
---|---|---|---|---|---|---|---|
- |
- |
- |
2000 |
2000 |
- |
Schedulable |
Schedulable |
1 |
0 |
1500 |
2000 |
500 |
First packet being forwarded |
Schedulable |
Schedulable |
2 |
First ms |
1500 |
625 |
-875 |
Second packet being forwarded |
Scheduling suspended |
Scheduling suspended |
3 |
Second ms |
1000 |
-750 |
-750 |
Third packet being forwarded |
Scheduling suspended |
Scheduling suspended |
4 |
Eighth ms |
1500 |
0 |
0 |
Fourth packet being forwarded |
Scheduling suspended |
Scheduling suspended |
5 |
Ninth ms |
1500 |
125 |
-875 |
Third packet being forwarded |
Schedulable |
Scheduling suspended |
The principle of traffic shaping on an interface is the same as that of traffic shaping for queues and is not described here.
Traffic shaping controls the traffic output to minimize packet loss.
Interface-based traffic shaping
As shown in Figure 6, enterprise headquarters are connected to branches through leased lines on an ISP network in Hub-Spoke mode. The bandwidth of each leased line is 1 Gbit/s. If all branches send data to headquarters, traffic congestion occurs on the nodes connecting to headquarters at the ISP network edge. To prevent packet loss, configure traffic shaping on outbound interfaces of the nodes at the branch network edge.
Queue-based traffic shaping
As shown in Figure 7, enterprise headquarters are connected to branches through leased lines on an ISP network in Hub-Spoke mode. The bandwidth of each leased line is 1 Gbit/s. Branches access the Internet through headquarters, but the link bandwidth between headquarters and the Internet is only 100 Mbit/s. If all branches access the Internet at a high rate, the rate of web traffic sent from headquarters to the Internet may exceed 100 Mbit/s, causing web packet loss on the ISP network.
To prevent web packet loss, configure queue-based traffic shaping for web traffic on outbound interfaces of branches and outbound interfaces connecting to the Internet on headquarters.
Last mile indicates the link between the user and the access switch (such as the Ethernet DSLAM), as shown in Figure 8. Residential and enterprise users generally access the Ethernet DSLAM using IPoE, PPPoE and the DSLAM is connected to the BRAS or SR, edge device on the backbone network, through a metropolitan area network (MAN).
In a broadband service access scenario, an Ethernet link connects a BRAS or SR and a DSLAM. The BRAS or SR encapsulates Ethernet packets, and traffic shaping is implemented based on the Ethernet packets.
Even if the link connects the user and DSLAM is also an Ethernet link, the encapsulation cost of the packets sent between the user and DSLAM can possibly exceed that on the user side of the BRAS or SR. For example, the Ethernet packet encapsulated on the BRAS or SR does not carry a VLAN tag, but the packet sent between the user and DSLAM carries a single or double VLAN tags due to VLAN or QinQ encapsulation.
To resolve this problem, last-mile QoS can be configured on the BRAS or SR. Last-mile QoS allows a device to calculate the length of headers to be added to packets based on the bandwidth purchased by users and the bandwidth of the downstream interface on the DSLAM for traffic shaping.
Therefore, the BRAS or SR cannot automatically infer the sum length of the packets that has been encapsulated on the DSLAM and requires compensation bytes.
After compensation bytes are configured, if the DSLAM connects to the CPE through an Ethernet link, the BRAS or SR can automatically infer the sum length of the packet encapsulated on the DSLAM based on the length of the forwarded packet and the configured compensation bytes, and determine the shaped rate to be adjusted.
The following tables provide common encapsulation-costs and compensation bytes.
Encapsulation Type |
Encapsulation-cost (Bytes) |
|
---|---|---|
Eth header |
14 |
|
VLAN header |
4 |
|
QinQ header |
8 |
|
AAL5 encapsulation |
VC |
AAL5 Header + AAL5 tail = 0 + 8 = 8 |
LLC Type1 (connection-less mode, such as IPoE, PPPoE) |
AAL5 Header + AAL5 tail = 8 + 8 = 16 |
Scenario |
Compensation Bytes |
---|---|
= VLAN header - QinQ header = - 4 |
|
= 0 - QinQ header = - 8 |