Quality of Service (QoS) is a tool that allows our network to prioritize certain types of traffic. QoS defines the actions that a device can apply to a message between the time it enters the device until it exits the device. These actions are called per-hop behaviors (PHBs). With PHBs, we can discard, delay, or even change the header field of each packet. The goal of a PHB is to provide a specified amount of network resources to a class of traffic on a contiguous network.
PHB uses a set of codepoints to mark packets with different levels of priority. These codepoints are embedded in the Differentiated Services Code Point (DSCP) field of the Type Of Service (ToS) field of the IP header.
The key components of PHB are listed below:
+ Classification: When receiving a packet, the first thing a networking device does is to examine the packet’s header to determine what kind of data is inside. This is called classification and involves categorizing network traffic into different groups based on specific criteria like IP address, protocol, port, or application type. An example of classification is shown below:
class-map match-all CLASSIFICATION_HTTP
match access-group 100
!
access-list 100 permit tcp any any eq 80
In this example, we have created a class map named “CLASSIFICATION_HTTP” that matches all traffic matching access-group 100. Access-group 100 permits TCP traffic with destination port 80.
+ Marking: A packet can be classified when entering or leaving a device but there may be many other devices on its journey to the destination and this repeated process is time-consuming. A more efficient way is to classify the packets once as close to the source as possible and mark them to a QoS standard. This is called marking, which is the process of changing the packet’s header so that other devices know which level (quality) of service should be applied to the packets by just reading the marking. With IP packets, we can mark with either a precedence or DSCP value.
An example of marking is shown below:
policy-map MARKING_HTTP
class CLASSIFICATION_HTTP
set dscp af21
!
In this example, we have created a policy map named “MARKING_HTTP” that marks all traffic matching the “CLASSIFICATION_HTTP” class with DSCP value of “af21”.
Apply (activate) the policy-map to an interface:
interface FastEthernet0/1
service-policy output MARKING_HTTP
!
In this example, we have applied the “MARKING_HTTP” policy map to FastEthernet0/1 interface for outbound traffic.
+ Queuing: the process of holding packets in a queue and scheduling their transmission based on priority. Utilizing algorithms such as Weighted Fair Queuing (WFQ), this process ensures high-priority packets are transmitted before their low-priority counterparts.
An example of configuring queuing is shown below:
interface FastEthernet0/1
priority-queue out
+ Congestion: occurs when network bandwidth is insufficient to accommodate all traffic. PHB includes mechanisms like Random Early Detection (RED) to manage congestion by discarding low-priority packets before higher-priority ones.
+ Policing: involves monitoring network traffic and enforcing predetermined traffic rate limits. Packets exceeding specified rate limits may be discarded or marked with a lower priority.
+ Shaping: Shaping is the control of the rate at which packets enter the network, preventing congestion and ensuring timely transmission of all packets. Excess traffic is stored in a buffer and released at a controlled rate, shaping the traffic to conform to the desired profile. Shaping is a more gentle approach that attempts to smooth out bursts of traffic. Traffic shaping is applicable only on outbound interfaces as buffering and queuing happens only on outbound interfaces
The figure above shows the difference between Policing and Shaping. With traffic policing, excess traffic is usually dropped while with traffic shaping, excess traffic is buffered and sent again with a little delay.