Supported Platforms
Related Documentation
- ACX, EX, J, M, MX, PTX, SRX, T Series
- Stateless Firewall Filter Overview.
- EX, M, MX, T Series
- Order of Policer and Firewall Filter Operations
- EX, M, MX, PTX, T Series
- Packet Flow Through the CoS Process Overview
- M, MX, PTX, T Series
- Traffic Policer Types
Traffic Policing Overview
This topic covers the following information:
Congestion Management for IP Traffic Flows
Traffic policing, also known rate limiting, is an essential component of network access security that is designed to thwart denial-of-service (DoS) attacks. Traffic policing enables you to control the maximum rate of IP traffic sent or received on an interface and also to partition network traffic into multiple priority levels, also known as classes of service. A policer defines a set of traffic rate limits and sets consequences for traffic that does not conform to the configured limits. Packets in a traffic flow that does not conform to traffic limits are either discarded or marked with a different forwarding class or packet loss priority (PLP) level.
With the exception of policers configured to rate-limit aggregate traffic (all protocol families and logical interfaces configured on a physical interface), you can apply a policer to all IP packets in a Layer 2 or Layer 3 traffic flow at a logical interface.
With the exception of policers configured to rate-limit based on physical interface media rate, you can apply a policer to specific IP packets in a Layer 3 traffic flow at a logical interface by using a stateless firewall filter.
You can apply a policer to inbound or outbound interface traffic. Policers applied to inbound traffic help to conserve resources by dropping traffic that does not need to be routed through a network. Dropping inbound traffic also helps to thwart denial-of-service (DoS) attacks. Policers applied to outbound traffic control the bandwidth used.
![]() | Note: Traffic policers are instantiated on a per-PIC basis. Traffic policing does not work when the traffic for one local policy decision function (L-PDF) subscriber is distributed over multiple Multiservices PICs in an AMS group. |
Traffic Limits
Junos® OS policers use the token-bucket algorithm to enforce a limit on average transmit or receive rate of IP traffic at an interface while allowing bursts of traffic up to a maximum value based on the overall traffic load. The token-bucket algorithm offers more flexibility than the leaky-bucket algorithm in that you can allow a specified amount of bursting before starting to discard packets or apply a penalty to packet output-queuing priority or packet drop priority.
In the token-bucket model, the bucket represents the policing function. Tokens are added to the bucket at a fixed rate, but only up to the specified depth of the bucket. Each token represents a “credit” for some number of bits, and tokens in the bucket are “cashed in” for the ability to transmit or receive traffic at the interface. When sufficient tokens are present in the bucket, a traffic flow continues unrestricted. Otherwise, packets might be dropped or else re-marked with a lower forwarding class, a higher packet loss priority (PLP) level, or both.
- The rate at which tokens are added to the bucket represents the highest average transmit or receive rate in bits per second allowed for a given service level. You specify this highest average traffic rate as the bandwidth limit of the policer. If the traffic arrival rate is so high that at some point insufficient tokens are present in the bucket, then the traffic flow is no longer conforming to the traffic limit.
- The depth of the bucket in bytes controls the amount of
back-to-back bursting allowed. You specify this factor as the burst-size limit of the policer. This second limit
affects the average transmit or receive rate by limiting the number
of bytes permitted in a transmission burst for a given interval of
time. Bursts exceeding the current burst-size limit are dropped until
there are sufficient tokens available to permit the burst to proceed.
Figure 1: Network Traffic and Burst Rates
As shown in the figure above, a UPC bar code is a good facsimile of what traffic looks like on the line; an interface is either transmitting (bursting at full rate) or it is not. The black lines represent periods of data transmission and the white space represents periods of silence when the token bucket can replenish.
Depending on the type of policer used, packets in a policed traffic flow that surpasses the defined limits might be implicitly set to a higher PLP level, assigned to a configured forwarding class or set to a configured PLP level (or both), or simply discarded. If packets encounter downstream congestion, packets with a low PLP level are less likely to be discarded than those with a medium-low, medium-high, or high PLP level.
Traffic Color Marking
Based on the particular set of traffic limits configured, a policer identifies a traffic flow as belonging to one of either two or three categories that are similar to the colors of a traffic light used to control automobile traffic.
A two-color-marking policer categorizes traffic as either conforming to the traffic limits (green) or violating the traffic limits (red):
- Green—Two-color-marking policers implicitly set the packets in a green flow to the low PLP level, and you cannot configure any policer actions for conforming traffic.
- Red—Two-color-marking policers do not perform
any implicit actions on packets in a red flow. Instead, those packets
are handled according to the actions specified in the policer configuration.
You can configure a two-color-marking policer to simply discard packets
if the traffic flow is red. Alternatively, you can configure a two-color-marking
policer to handle the packets in a red flow by setting the PLP level
to either low or high, assigning the packets to
any forwarding class already configured, or both.
On MX Series, M120, and M320 routers and M7i and M10i routers with the Enhanced CFEB (CFEB-E) and EX Series switches only, you can specify two additional PLP levels for packets in a red flow: medium-low or medium-high.
Three-color-marking policers categorize traffic as conforming to the traffic limits (green), violating the traffic limits (red), or exceeding the traffic limits but within an allowed range (yellow):
- Green—Like two-color-marking policers, three-color-marking policers implicitly set the packets in a green flow to the low PLP level, and you cannot configure any policer actions for conforming traffic.
- Yellow—Unlike two-color-marking policers, three-color-marking
policers categorize a second type of nonconforming traffic: yellow.
Single-rate three-color policing categorizes as yellow traffic that exceeds the traffic limits while conforming to a second defined burst-size limit. Two-rate three-color policing categorizes as yellow traffic that exceeds the traffic limits while conforming to both a second defined burst-size limit and a second defined bandwidth limit.
Three-color-marking policers implicitly set the packets in a yellow flow to the medium-high PLP level so that the packets incur a less severe penalty than those in a red flow. You cannot configure any policer actions for yellow traffic.
- Red—Unlike two-color-marking policers, three-color-marking policers implicitly set the packets in a red flow to the high PLP level, which is the highest PLP value. You can also configure a three-color-marking policer to discard the packets in a red flow instead of forwarding them with a high PLP setting.
Two-color-marking policers allows bursts of traffic for short periods, whereas three-color-marking policers allow more sustained bursts of traffic.
Forwarding Classes and PLP Levels
A packet’s forwarding class assignment and PLP level are used by the Junos OS class of service (CoS) features. The Junos CoS features include a set of mechanisms that you can use to provide differentiated services when best-effort traffic delivery is insufficient. For router (and switch) interfaces that carry IPv4, IPv6, and MPLS traffic, you can configure CoS features to take in a single flow of traffic entering at the edge of your network and provide different levels of service across the network—internal forwarding and scheduling (queuing) for output—based on the forwarding class assignments and PLP levels of the individual packets.
![]() | Note: Forwarding-class or loss-priority assignments performed by a policer or a stateless firewall filter override any such assignments performed on the ingress by the CoS default IP precedence classification at all logical interfaces or by any configured behavior aggregate (BA) classifier that is explicitly mapped to a logical interface. |
Based on CoS configurations, packets of a given forwarding class are transmitted through a specific output queue, and each output queue is associated with a transmission service level defined in a scheduler.
Based on other CoS configurations, when packets in an output queue encounter congestion, packets with higher loss-priority values are more likely to be dropped by the random early detection (RED) algorithm. Packet loss priority values affect the scheduling of a packet without affecting the packet’s relative ordering within the traffic flow.
Policer Application to Traffic
After you have defined and named a policer, it is stored as a template. You can later use the same policer name to provide the same policer configuration each time you want to use it. This eliminates the need to define the same policer values more than once.
You can apply a policer to a traffic flow in either of two ways:
- You can configure a standard stateless firewall filter
that specifies the policer policer-name nonterminating action or the three-color-policer (single-rate | two-rate) policer-name nonterminating
action. When you apply the standard filter to the input or output
at a logical interface, the policer is applied to all packets of the
filter-specific protocol family that match the conditions specified
in the filter configuration.
With this method of applying a policer, you can define specific classes of traffic on an interface and apply traffic rate-limiting to each class.
- You can apply a policer directly to an interface so that traffic rate-limiting applies to all traffic on that interface, regardless of protocol family or any match conditions.
You can configure policers at the queue, logical interface, or Layer 2 (MAC) level. Only a single policer is applied to a packet at the egress queue, and the search for policers occurs in this order:
- Queue level
- Logical interface level
- Layer 2 (MAC) level
Related Documentation
- ACX, EX, J, M, MX, PTX, SRX, T Series
- Stateless Firewall Filter Overview.
- EX, M, MX, T Series
- Order of Policer and Firewall Filter Operations
- EX, M, MX, PTX, T Series
- Packet Flow Through the CoS Process Overview
- M, MX, PTX, T Series
- Traffic Policer Types
Published: 2013-04-15
Supported Platforms
Related Documentation
- ACX, EX, J, M, MX, PTX, SRX, T Series
- Stateless Firewall Filter Overview.
- EX, M, MX, T Series
- Order of Policer and Firewall Filter Operations
- EX, M, MX, PTX, T Series
- Packet Flow Through the CoS Process Overview
- M, MX, PTX, T Series
- Traffic Policer Types