Configuring CoS Rules
To configure a CoS rule, include the rule rule-name statement at the [edit services cos] hierarchy level:
Each CoS rule consists of a set of terms, similar to a filter configured at the [edit firewall] hierarchy level. A term consists of the following:
- from statement—Specifies the match conditions and applications that are included and excluded.
- then statement—Specifies the actions and action modifiers to be performed by the router software.
In addition, each rule must include a match-direction statement that specifies the direction in which the rule match is applied. To configure where the match is applied, include the match-direction statement at the [edit services cos rule rule-name] hierarchy level:
If you configure match-direction input-output, bidirectional rule creation is allowed.
The match direction is used with respect to the traffic flow through the Services PIC. When a packet is sent to the Services PIC, direction information is carried along with it.
With an interface service set, packet direction is determined by whether a packet is entering or leaving the interface on which the service set is applied.
With a next-hop service set, packet direction is determined by the interface used to route the packet to the Services PIC. If the inside interface is used to route the packet, the packet direction is input. If the outside interface is used to direct the packet to the Services PIC, the packet direction is output. For more information on inside and outside interfaces, see the Junos OS Services Interfaces Library for Routing Devices.
On the Services PIC, a flow lookup is performed. If no flow is found, rule processing is performed. All rules in the service set are considered. During rule processing, the packet direction is compared against rule directions. Only rules with direction information that matches the packet direction are considered.
The following sections describe CoS rule content in more detail:
Configuring Match Conditions in a CoS Rule
To configure CoS match conditions, include the from statement at the [edit services cos rule rule-name term term-name] hierarchy level:
You can use either the source address or the destination address as a match condition, in the same way that you would configure a firewall filter; for more information, see the Firewall Filters Feature Guide for Routing Devices.
If you omit the from term, the router accepts all traffic and the default protocol handlers take effect:
- User Datagram Protocol (UDP), Transmission Control Protocol (TCP), and Internet Control Message Protocol (ICMP) create a bidirectional flow with a predicted reverse flow.
- IP creates a unidirectional flow.
You can also include application protocol definitions that you have configured at the [edit applications] hierarchy level; for more information, see the Junos OS Services Interfaces Library for Routing Devices.
- To apply one or more specific application protocol definitions, include the applications statement at the [edit services cos rule rule-name term term-name from] hierarchy level.
- To apply one or more sets of application protocol definitions
you have defined, include the application-sets statement
at the [edit services cos rule rule-name term term-name from] hierarchy level.
Note: If you include a statement that specifies application protocols, the router derives port and protocol information from the corresponding configuration at the [edit applications] hierarchy level; you cannot specify these properties as match conditions.
Configuring Actions in a CoS Rule
To configure CoS actions, include the then statement at the [edit services cos rule rule-name term term-name] hierarchy level:
The principal CoS actions are as follows:
- dscp—Marks the packet with the specified DiffServ code point (DSCP) value or alias.
- forwarding-class—Assigns the packet to the specified forwarding class.
You can optionally set the configuration to record information in the system logging facility by including the syslog statement at the [edit services cos rule rule-name term term-name then] hierarchy level. This statement overrides any syslog setting included in the service set or interface default configuration.
For information about some additional CoS actions, see the following sections:
Configuring Application Profiles
You can optionally define one or more application profiles for inclusion in CoS actions. To configure, include the application-profile statement at the [edit services cos] hierarchy level:
The application-profile statement includes two main components and three traffic types: ftp with the data traffic type and sip with the video and voice traffic types. You can set the appropriate dscp and forwarding-class values for each component within the application profile.
![]() | Note: The ftp and sip statements are not supported on Juniper Network MX Series 3D Universal Edge Routers. |
You can apply the application profile to a CoS configuration by including it at the [edit services cos rule rule-name term term-name then] hierarchy level.
Configuring Reflexive and Reverse CoS Actions
It is important to understand that CoS services are unidirectional. It might be necessary to specify different treatments for flows in opposite directions.
Regardless of whether a packet matches the input, output, or input-output direction, flows in both directions are created. The difference is that a forward, reverse, or forward-and-reverse CoS action is associated with each flow. You should bear in mind that the flow in the opposite direction might end up having a CoS action associated with it, which you have not specifically configured.
To control the direction in which service is applied, separate from the direction in which the rule match is applied, you can configure the reflexive or reverse statement at the [edit services cos rule rule-name term term-name then] hierarchy level:
The two actions are mutually exclusive. If nothing is specified, data flows inherit the CoS behavior of the forward control flow.
- reflexive causes the equivalent reverse CoS action to be applied to flows in the opposite direction.
- reverse allows you to define the CoS behavior for flows in the reverse direction.