Hello Muhammad
QoS functions at various levels in routers and switches. Specifically, QoS functions at Layer 2 with a Class of Service (CoS) value in the VLAN tag, and at Layer 3 with the DSCP values in the IP header. Each is used in a different scenario.
CoS is used to prioritize frames on any link that carries more than one VLAN. It specifically exists in the VLAN Tag found on trunks. So CoS values are used to ensure that frames with a higher priority are given precedence over a trunk when there is congestion. Now this is also the case on any link using a Voice VLAN. In the example in the lesson, we have FastEthernet0/1 where the voice packets are tagged, and the data packets are untagged. If a CoS value in the tagged (voice) frames is configured, then if there is congestion on the link (due to a user on the connected computer downloading a movie for example), CoS can be used to ensure that voice frames will be given priority over the data frames.
Now Layer 3 switches also have the capability of decapsulating to Layer 3 and examining the info in the IP packet header. This allows a switch to use DSCP values as well to determine priority, and to determine the QoS mechanism that will take place in the event of congestion.
I hope this has been helpful!
Laz