Networking Fundamentals · Topic 5 of 5
Class of Service and Connection-Oriented vs Connectionless Protocols
Learn Junos class of service building blocks, classification, queuing and rewrite, and how connection-oriented TCP differs from connectionless UDP.
- 5 min
- CoS flow: classify, police, queue and schedule, rewrite.
- BA classifiers read DSCP, IP precedence, 802.1p or EXP; multifield classifiers are firewall filters.
- Default forwarding classes: best-effort queue 0, expedited-forwarding 1, assured-forwarding 2, network-control 3.
What it is
Class of service (CoS) lets a device treat traffic differently based on its importance. When a link is congested, CoS decides which packets are sent first, which wait in a queue and which are dropped. Voice and network control traffic can be protected while bulk downloads take what is left.
Connection-oriented protocols, such as TCP, set up a session before sending data and make sure it arrives. Connectionless protocols, such as UDP, just send each packet without setup or delivery checks.
How it works
Why CoS is needed
Without CoS, every packet joins one queue and is served first in, first out. A large file transfer can then delay voice packets and cause jitter. CoS gives each traffic type its own queue and its own share of the link, so delay sensitive traffic is not stuck behind bulk data.
CoS building blocks in Junos OS
| Component | What it does |
|---|---|
| Classifier | Puts an incoming packet into a forwarding class and a loss priority |
| Forwarding class | A traffic group; each forwarding class maps to an output queue |
| Loss priority | Marks how likely a packet is to be dropped under congestion |
| Policer | Limits the rate of traffic, dropping or remarking the excess |
| Scheduler | Sets each queue's transmit rate, buffer size and priority |
| Rewrite rule | Writes a new marking into the packet header on the way out |
There are two kinds of classifier. A behavior aggregate (BA) classifier reads a marking already in the packet, such as the DSCP value, IP precedence, IEEE 802.1p bits or MPLS EXP bits. A multifield classifier is a firewall filter that matches several header fields, such as addresses and ports, and sets the forwarding class.
Default forwarding classes
On most platforms, Junos OS has four forwarding classes by default, mapped to four queues.
| Forwarding class | Queue |
|---|---|
| best-effort | 0 |
| expedited-forwarding | 1 |
| assured-forwarding | 2 |
| network-control | 3 |
With the default scheduler settings, only best-effort and network-control get bandwidth: 95 percent for best-effort and 5 percent for network-control. To use the other queues properly you configure schedulers under [edit class-of-service].
Markings you should recognize
| Marking | Where | Bits | Values |
|---|---|---|---|
| IP precedence | IPv4 ToS byte | 3 | 0 to 7 |
| DSCP | IPv4 ToS byte or IPv6 traffic class | 6 | 0 to 63; EF is 46 |
| IEEE 802.1p | 802.1Q VLAN tag | 3 | 0 to 7 |
| MPLS EXP | MPLS label | 3 | 0 to 7 |
Connection-oriented: TCP
TCP builds a session with a three-way handshake before data flows.
TCP then numbers every byte with sequence numbers, the receiver acknowledges what it gets, and anything lost is sent again. A window controls how much data can be sent before an acknowledgment is needed, which gives flow control. A session closes with FIN segments, or is torn down at once with RST.
Connectionless: UDP
UDP has no handshake, no acknowledgments, no sequence numbers and no retransmission. Each datagram is independent. Its header is only 8 bytes, against at least 20 bytes for TCP, so it is lighter and faster. Applications that need speed over reliability, or that handle loss themselves, use UDP.
TCP and UDP compared
| TCP | UDP | |
|---|---|---|
| Type | Connection-oriented | Connectionless |
| Setup | Three-way handshake | None |
| Reliability | Acknowledgments and retransmission | None at Layer 4 |
| Ordering | Sequence numbers reorder data | No ordering |
| Flow control | Sliding window | None |
| Header | 20 bytes minimum | 8 bytes |
| IP protocol number | 6 | 17 |
Well-known ports
| Protocol | Transport | Port |
|---|---|---|
| FTP | TCP | 20, 21 |
| SSH | TCP | 22 |
| Telnet | TCP | 23 |
| HTTP | TCP | 80 |
| HTTPS | TCP | 443 |
| BGP | TCP | 179 |
| DNS | UDP (TCP for large replies and zone transfers) | 53 |
| TFTP | UDP | 69 |
| NTP | UDP | 123 |
| SNMP | UDP | 161, traps 162 |
| Syslog | UDP | 514 |
ICMP and OSPF run directly over IP with no port numbers: ICMP is IP protocol 1 and OSPF is IP protocol 89.
The exam likes "which protocol uses TCP". BGP, SSH, Telnet, FTP and HTTP use TCP. TFTP, SNMP, NTP, syslog and most DNS queries use UDP.
How CoS and transport interact
When a queue overflows, packets are dropped. TCP notices the loss, slows down and resends. UDP traffic such as voice does not resend, so a dropped voice packet is simply gone. This is why voice is usually placed in a high priority queue such as expedited-forwarding, and why CoS policies protect it.
Common mistakes
Thinking CoS creates bandwidth. CoS only decides who goes first and who is dropped when a link is congested. It cannot make a link faster.
Confusing BA and multifield classifiers. A BA classifier reads an existing marking. A multifield classifier is a firewall filter that looks at several header fields.
Calling UDP unreliable and therefore useless. UDP is the right choice for real time traffic and simple query and response protocols, where a resend would arrive too late anyway.
TFTP uses UDP port 69, while FTP uses TCP ports 20 and 21. The names are close, so read the option carefully.
What to remember for the exam
- CoS flow: classify, police, queue and schedule, rewrite.
- BA classifiers read DSCP, IP precedence, 802.1p or EXP; multifield classifiers are firewall filters.
- Default forwarding classes: best-effort queue 0, expedited-forwarding 1, assured-forwarding 2, network-control 3.
- Default scheduling: best-effort 95 percent, network-control 5 percent.
- DSCP is 6 bits; IP precedence, 802.1p and EXP are 3 bits.
- TCP: three-way handshake, acknowledgments, sequence numbers, windowing; IP protocol 6.
- UDP: no setup or acknowledgments, 8 byte header; IP protocol 17.
Check yourself
What are the three messages of the TCP three-way handshake, in order?
SYN from the client, SYN ACK from the server, then ACK from the client.
Which Junos CoS component places a packet in a forwarding class based on its existing DSCP value?
A behavior aggregate (BA) classifier, which reads the marking already in the packet.
Name two protocols that use UDP and two that use TCP.
SNMP and TFTP use UDP; SSH and BGP use TCP.
Topic 5 of 5 in Networking Fundamentals
Test yourself on Networking Fundamentals
The full Juniper JNCIA-Junos JN0-106 question bank has 1,155 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.