What is Packet Shaping?
The typical function of traffic shaping is to limit the traffic and bursts of a certain connection out of a certain network, so that this type of packets are sent out at a relatively uniform speed. Traffic shaping is usually accomplished by using buffers and token buckets. When messages are sent too quickly, they are buffered in the buffer first, and then these buffered messages are sent uniformly under the control of the token bucket.
- Chinese name
- Traffic shaping
- Foreign name
- traffic shaping
- Concept
- Measures to actively adjust the flow output rate
- Packets that do not participate in traffic shaping continue to be sent directly.
- For packets participating in traffic shaping, if there is a shaping queue, the message directly enters the queue, and the waiting queue schedules and forwards the message according to the shaping algorithm.
- For packets participating in traffic shaping, if there is no shaping queue, it is determined whether the packets are sent according to the shaping algorithm.
- Traffic shaping buffers packets that exceed the traffic specifications during traffic policing. When the shaping algorithm allows messages to be sent, these buffered messages are sent out evenly.
- Traffic shaping may increase latency, while traffic policing hardly introduces additional latency.
- The typical function of traffic shaping is to limit the traffic and bursts of a certain connection out of a certain network, so that this type of packets are sent out at a relatively uniform speed. Traffic shaping is usually accomplished by using buffers and token buckets. When messages are sent too quickly, they are buffered in the buffer first, and then these buffered messages are sent uniformly under the control of the token bucket.
Definition of traffic shaping
- Traffic Shaping is a measure to actively adjust the rate of traffic output.
- Traffic shaping [1]
- A typical application is to control the output of local traffic based on the TP index of downstream network nodes. The main difference between traffic shaping and traffic policing is that traffic shaping buffers the packets that need to be discarded in traffic policing-usually they are placed in a buffer or queue, also known as traffic shaping (TS). When the token bucket has enough tokens, these buffered packets are sent out evenly. Another difference between traffic shaping and traffic policing is that shaping may increase latency, while policing rarely introduces additional delays.
- As shown in the figure above, when a packet arrives at an interface, it is first classified and processed according to the following situations.
- When the packet reaches the interface and the shaping queue is full, the packet is discarded.
Core algorithms for traffic shaping
- The core algorithms of traffic shaping are the following two. The specific technology used is Generic Traffic Shaping (GTS) and general traffic shaping:
Traffic Shaping Leaky Bucket Algorithm
- Leaky Bucket Algorithm
- The leaky bucket algorithm is an algorithm often used in traffic shaping or rate limiting in the network world. Its main purpose is to control the rate of data injection into the network and smooth the burst traffic on the network. The leaky bucket algorithm provides a mechanism through which burst traffic can be shaped to provide a stable flow to the network.
Traffic Shaping Token Bucket Algorithm
- Token Bucket Algorithm
- Sometimes people mistake the leaky bucket algorithm with the token bucket algorithm. In fact, these two algorithms have very different characteristics and are used for very different purposes. The main difference between them is that the leaky bucket algorithm can forcibly limit the data transmission rate, while the token bucket algorithm can limit the average data transmission rate while also allowing some degree of burst transmission.
- In some cases, the leaky bucket algorithm cannot effectively use network resources. Because the leak rate of leaky buckets is a fixed parameter, even if there is no resource conflict in the network (no congestion occurs), the leaky bucket algorithm cannot burst a single flow to the port rate. Therefore, the leaky bucket algorithm is inefficient for traffic with burst characteristics. The token bucket algorithm can meet these bursty traffic. Generally, the leaky bucket algorithm and the token bucket algorithm can be combined to provide greater control over network traffic.
Traffic shaping common traffic shaping classification
GTS Traffic Shaping GTS General Traffic Shaping
- Traffic shaping forces traffic to follow certain bandwidth allocation limits by reducing the rate of outgoing traffic. Unlike traffic policing, which discards traffic that exceeds the burst size, it puts burst traffic into a traffic shaping buffer and sends it when bandwidth is available, or when the number of buffered packets When it is below the configured limit, it is sent out again.
- Traffic shaping uses a system of token buckets to decide whether to transmit, delay, or discard new packets. With this token bucket system, each interface has a committed information rate (CIR), which is the rate at which the interface can transmit data packets in a period of time. The continuous burst rate (Bc) defines the maximum number of tokens that a token bucket can contain in another time interval. When a packet arrives on an interface, it takes a token from the token bucket. When the data packet is sent, the token is released. When the time interval (Tc) elapses, the token is returned to the token bucket. If the token bucket is empty, any new packets arriving on that interface will be placed in the queue until the time interval elapses and the tokens will be refilled. If the CIR continues to exceed, the tokens will be removed from the token bucket at a faster rate than they were added, filling the queue and causing the packets to be dropped.
- Traffic shaping can be applied to a number of different Layer 2 technologies, such as Ethernet, ATM, HDLC, PPP (not supported by ISDN and dial-up interfaces), and Frame Relay. With the exception of Frame Relay, all of these technologies support General Traffic Shaping (GTS). GTS can also shape certain types of traffic defined in the re-access control list by specifying groups in traffic shaping.
- In order to configure GTS, you must know the destination bit rate for the interface, that is, the committed information rate (CIR), which refers to the rate at which traffic is sent under normal circumstances. Continuous burst rate (Bc) refers to the rate at which traffic is allowed to burst beyond the normal traffic rate in each time interval, expressed in bits. Excess Burst Rate (Be) refers to the rate at which traffic is allowed to burst beyond the continuous burst rate during the first interval. At every interval (Tc), traffic is filled into the token bucket of traffic shaping.
- Tc = Bc / CIR
- The time interval for traffic shaping cannot be less than 10ms or greater than 125ms. The router finds the best time interval based on the formula of Tc = Bc / CIR. The default time interval is 125ms. This time interval is the result of CIR and Bc configuration and is used for non-configurable. Cisco recommends that Bc should be 1/8 of the CIR. It will produce 8 125ms intervals in every second.
- Configure GTS for all interface traffic, and use the traffic-shaping rate command on the interface that needs traffic shaping. For specific traffic, use the traffic-shaping group command and an access control list.
- traffic-shaping {rate | group access-list-number} target-bit-rate [sustained] [excess] [buffer-limit]
- group access-list-number specifies that all traffic that matches the access control list (1-2699) is shaped.
- rate specifies that all traffic on this interface is shaped.
- target-bit-rate The normal rate (CIR) at which this traffic will be transmitted, ranging from 8000 to the full CIR of the interface in bits per second.
- Sustained continuous bit rate (Bc) refers to the value of the allowed burst of traffic, expressed as the number of bits in each time interval.
- The excess excess bit rate (Be) refers to the burst of traffic that exceeds the continuous bit rate during the first time interval, expressed as the number of bits in each time interval. It is an optional parameter, it will assume that the token bucket is completely full: Be = Bc * 2.
- buffer is used to specify a cache limit, ranging from 1 to 4096.
- GTS configuration requires two steps: discover the value of traffic shaping, and configure traffic shaping on the interface.
- 1. Find the correct value for traffic shaping. CIR, Bc, Be
- Bc specifies the number of bits that the interface can transmit during a certain time interval. Bc = CIR * Tc
- Be specifies the burst of traffic that can be supported when the interface is filled with enough tokens, usually within the first interval. Be = Bc * 2
- If the interface does not support bursts, the following formula can be used: Be = Bc
- 2. In interface mode, use the traffic-shaping command to enable traffic shaping.
- In order to view the GTS configuration, use the show traffic-shaping [statistics] command
FRTS Traffic Shaping Frame Relay Traffic Shaping (FRTS)
- FRTS is used in the following 4 cases: 1 center high speed, branch low speed. 2 A single physical line carries many VCs to different destinations. 3 If the FR is congested, you want the router to block the data flow (Throttle). 4 It is necessary to transmit data streams of multiple protocols (IP, SNA) on the VC of the same FR, and hope that each data stream can occupy a certain BW.
- FECN and BECN in FR are used to indicate the occurrence of congestion on the network. When receiving a packet with a BECN mark, FR Traffic Shaping (FRTS) will dynamically shape the traffic. Note: FRTS can only be used on FR's PVC and SVC. Among them is an adaptive FRTS. During each Tc interval, the process will check whether it has received a BECN from the Frame Relay network. If it receives a BECN at a Tc interval, the transmission rate is reduced by 25% until it reaches half of the CIR. until. If and only if no BECN is received within 16 Tc, the communication rate is restored to CIR.
- FRTS configuration steps
- 1) Create a MAP-CLASS, with case-sensitive names.
- 2) Define the method of traffic shaping, such as setting the average rate and the highest rate.
- 3) Encapsulate FRAME-RELAY on the interface.
- 4) Apply MAP-CLASS 5 on the port to enable traffic shaping, which is generally used for the source interface.
Traffic shaping traffic policing
- Router A sends packets to Router B. To reduce the unnecessary loss of packets, you can perform traffic shaping on the packets at the exit of Router A. Buffers that exceed the traffic shaping characteristics are stored in Router A. When the shaping algorithm allows the next batch of messages to be sent, the message is taken from the buffer queue and sent. In this way, the packets sent to Router B will all meet the traffic regulations of Router B.
- The main differences between traffic shaping and traffic policing are: