Differentiated Services and ECN: Marking Packets for Priority and Congestion
How the second byte of the IP header marks packets: DSCP classes such as EF, AF, CS and LE, how routers turn marks into priority, and how ECN lets routers signal congestion without dropping packets, measured with real queues.
kvi5hnuCode Sprout team member16 min readOn this page
The second byte of the IPv4 header, and the matching Traffic Class byte in IPv6, lets packets carry two kinds of information that routers act on. The first 6 bits mark how a packet would like to be treated (priority, low delay, or "send me last"). The last 2 bits let a congested router say it is congested without throwing the packet away. This article covers both, with lab measurements of what a priority mark and an ECN mark actually do.
From Type of Service to DSCP and ECN
The original IPv4 specification (RFC 791) called this byte Type of Service (ToS). It had a 3-bit Precedence value, from 0 (routine) to 7 (network control), taken from military telephone systems in which higher-precedence calls could cut off lower ones. It also had three flag bits asking for low delay (D), high throughput (T) and high reliability (R). Very few networks ever acted on these fields.
In 1998, RFC 2474 redefined the first 6 bits as the Differentiated Services Code Point (DSCP). In 2001, RFC 3168 made the last 2 bits the Explicit Congestion Notification (ECN) field. The layout is the same in IPv4 and IPv6, and the old names "ToS byte" and "Traffic Class byte" are still used for the whole byte. The figure puts the old and new layouts of the byte one above the other.

Be careful which number a tool expects. A DSCP value such as 46 occupies the top 6 bits, so the whole byte is that value shifted left by 2: 46 is 101110, shifted it becomes 10111000, which is 46 × 4 = 184 = 0xB8. ping -Q and the IP_TOS socket option take the whole byte, while nft and tc's DSCP matching usually take the 6-bit DSCP.
Differentiated Services: per-hop behaviors
The Differentiated Services (DiffServ) architecture (RFC 2475) works like this:
- Traffic is classified and marked at the edge of a network: by the sending host, by the first switch, or by a router at the boundary of an ISP (internet service provider).
- Inside the network, routers don't look at ports or applications. They read only the DSCP and apply the matching per-hop behavior (PHB): which queue the packet goes into, how much bandwidth that queue gets, and which packets are dropped first.
- At the boundary between two networks, marks may be trusted, rewritten to the neighbor's scheme, or reset to 0.
The main code points:
| Name | DSCP | Binary | Meaning |
|---|---|---|---|
| CS0 / Default | 0 | 000000 | Best effort, the normal Internet service |
| LE | 1 | 000001 | Lower Effort: send only when the link is otherwise idle (RFC 8622) |
| CS1 | 8 | 001000 | Historically "scavenger" or low priority. RFC 8622 now recommends LE for this |
| AF11, AF12, AF13 | 10, 12, 14 | 001010, 001100, 001110 | Assured Forwarding class 1, drop precedence 1 to 3 |
| AF21–AF23 | 18, 20, 22 | 010xx0 | AF class 2 |
| AF31–AF33 | 26, 28, 30 | 011xx0 | AF class 3 |
| AF41–AF43 | 34, 36, 38 | 100xx0 | AF class 4 (often interactive video) |
| CS2 to CS5 | 16, 24, 32, 40 | xxx000 | Class selectors, matching old precedence 2 to 5 |
| VOICE-ADMIT | 44 | 101100 | Voice that passed admission control (RFC 5865) |
| NQB | 45 | 101101 | Non-queue-building traffic, such as DNS and game updates (RFC 9956, 2026) |
| EF | 46 | 101110 | Expedited Forwarding: low delay, low loss, low jitter (variation in delay) (RFC 3246) |
| CS6 | 48 | 110000 | Network control: routing protocols such as BGP and OSPF |
| CS7 | 56 | 111000 | Reserved for network control |
Some details:
- Class selectors (CSx) are the values ending in
000. They exist for backward compatibility: a router that understood old Precedence gives CS5 traffic roughly what it gave precedence 5. - Assured Forwarding (AFxy) has four classes (x = 1 to 4), each with its own queue and share of bandwidth, and three drop precedences (y = 1 to 3). When a class's queue is under pressure, packets with a higher drop precedence number are discarded first: AF13 goes before AF12, which goes before AF11. A network can mark a customer's traffic AF11 up to the agreed rate and AF12 or AF13 above it, so the excess is the first to go.
- Expedited Forwarding (EF) is meant for voice and other real-time traffic. The router serves the EF queue at least as fast as EF traffic arrives, so EF packets wait only behind other EF packets. Networks must police EF to a modest rate, or it would starve everything else.
- Lower Effort (LE) is the opposite of priority: backups, software updates and other background traffic that should yield to everything else.
The 64 DSCP values are split into pools by their last bits. Values ending in 0 (pool 1) are assigned by standards. Values ending in 11 (pool 2) are for experimental and local use. Values ending in 01 (pool 3) started out as experimental too, but RFC 8436 (2018) opened them for standards, which is how LE got DSCP 1 and NQB got 45. The IANA "Differentiated Services Field Codepoints" registry has the full list, and RFC 4594 gives configuration guidelines for which traffic should use which class.
Marking a packet
Applications can set the byte on a socket, and hosts or routers can set it with firewall rules:
- In code, set the
IP_TOSsocket option (IPv4) orIPV6_TCLASS(IPv6) to the whole byte. - On Linux,
ping -Q 0xb8sends pings with DSCP EF. - On a Linux router, nftables can rewrite marks:
ip dscp set eforip6 dscp set cs1inside a rule. - On Windows, marks are set with Group Policy QoS (quality of service) policies (
New-NetQosPolicyin PowerShell). Applications can't simply set the byte themselves.
In the lab, a Python program on client set IP_TOS, and then ping sent one packet marked EF and one unmarked. The server's capture shows the byte, the DSCP and the ECN field of each:
IP_TOS set to 0xb8 = DSCP 46
ip.dsfield ip.dsfield.dscp ip.dsfield.ecn
0xb8 46 0
0x00 0 0
What a mark buys you: a measurement
A mark does nothing on its own. It matters only when a router has a queue of packets waiting and decides which one goes next. To show the effect, the lab router r1 limited its link toward the server to 20 Mbit/s and gave packets marked DSCP 46 a strict-priority class. Two TCP streams then filled the link, while two pings ran side by side, one unmarked and one marked EF:
DSCP 0 (default): rtt min/avg/max/mdev = 104.134/130.221/149.979/10.155 ms, pipe 2
DSCP 46 (EF): rtt min/avg/max/mdev = 0.022/0.054/0.111/0.018 ms

Compare the avg values: about 130 ms unmarked against 0.05 ms marked. The chart plots both pings over the whole run. The unmarked pings waited in the same queue as the bulk data. That queue held up to 375,000 bytes (3 million bits), which takes 3,000,000 / 20,000,000 = 0.15 s, or 150 ms, to drain at 20 Mbit/s, so every unmarked ping waited more than 100 ms. The EF pings jumped the queue and saw almost no delay. The router's counters show the two classes. Class 1:10 (prio 0, served first) is the priority class and carried only the 101 EF pings. Class 1:20 carried the bulk data and the unmarked pings, and it's the one that had to drop packets:
class htb 1:10 parent 1:1 leaf 10: prio 0
Sent 9898 bytes 101 pkt
(dropped 0, overlimits 0 requeues 0)
class htb 1:20 parent 1:1 leaf 20: prio 1
Sent 35661603 bytes 23673 pkt
(dropped 20, overlimits 10797 requeues 0)
Where DSCP is honored in practice
- Wi-Fi. Wi-Fi has four access categories (voice, video, best effort and background) with different chances of winning the radio. Access points and phones map DSCP onto them, as RFC 8325 describes: EF goes to voice, AF4x to video, LE and CS1 to background. This is the place where marks most often help ordinary users.
- Enterprise and carrier networks. Voice and video systems mark their traffic, and the network gives it priority queues and policing.
- Across the public Internet, marks often don't survive. Providers are free to re-mark or reset ("bleach") them at their boundaries, and many do, because otherwise any customer could mark everything EF.
Explicit Congestion Notification
When a router's queue fills, the traditional signal to slow down is a dropped packet: TCP notices the loss and reduces its sending rate (article 72). That works, but it wastes the packet, costs a retransmission and adds delay. ECN (RFC 3168) lets a router mark a packet instead of dropping it.
The two ECN bits have four values:
| Bits | Name | Meaning |
|---|---|---|
| 00 | Not-ECT | The sender doesn't support ECN, so a congested router must drop instead |
| 10 | ECT(0) | ECN-capable transport (classic ECN) |
| 01 | ECT(1) | ECN-capable transport, now used to identify L4S traffic |
| 11 | CE | Congestion Experienced: set by a router instead of dropping |
The full loop for TCP:
- In the handshake, the client's SYN (the packet that opens a TCP connection, article 59) sets the TCP ECE (ECN-Echo) and CWR (Congestion Window Reduced) flags to ask for ECN, and the server's SYN-ACK sets ECE to agree.
- The sender marks its data packets ECT(0).
- A router whose queue is building up, and that would otherwise drop the packet, changes the field to CE and forwards it.
- The receiver sees CE and sets ECE on its ACKs, repeating it until the sender responds.
- The sender reduces its rate as if a packet had been lost, and sets CWR ("congestion window reduced") on its next segment.
Here is the negotiation, captured in the lab after enabling ECN on both hosts (sysctl net.ipv4.tcp_ecn=1). In tcp.flags.str, C is CWR, E is ECE, A is ACK and S is SYN, and the last column is the IP header's ECN field:
ip.src tcp.flags.str tcp.flags.ece tcp.flags.cwr ip.dsfield.ecn
192.0.2.10 ····CE····S· True True 0
198.51.100.10 ·····E·A··S· True False 0
The SYN and SYN-ACK themselves are sent Not-ECT. RFC 3168 doesn't allow marking them, because the sender doesn't yet know whether the other side supports ECN.
Marks instead of drops: a measurement
The lab router limited its output to 20 Mbit/s and managed the queue with RED (Random Early Detection), an active queue management algorithm that starts signaling congestion before the queue is full: it drops packets, or marks them if they're ECN-capable. One 10-second TCP transfer ran with ECN on, then another with ECN off:
tcp_ecn=1: 19.0 Mbit/s, retransmitted segments 0, data packets by ECN field: Not-ECT 1, ECT(0) 16496, CE 54, ACKs with ECE 596
tcp_ecn=0: 19.1 Mbit/s, retransmitted segments 52, data packets by ECN field: Not-ECT 16546, ACKs with ECE 0
The router's RED counters, which add up over both runs: marked counts the CE marks of the ECN run, and early counts the early drops of the run without ECN. min and max are the queue lengths, in bytes, between which RED signals with rising probability.
qdisc red 10: parent 1:1 limit 400000b min 30000b max 90000b ecn
Sent 50086266 bytes 33121 pkt (dropped 51, overlimits 105 requeues 0)
backlog 0b 0p requeues 0
marked 54 early 51 pdrop 0 other 0

The chart compares the two runs. The router signaled congestion about the same number of times in both runs, because both transfers pushed the same queue just as hard. With ECN, the signal was delivered as CE marks and almost nothing had to be sent twice. Without ECN, the same signal cost about 50 lost packets. Both transfers got the full rate, so the gain isn't throughput. It's lower delay: no waiting for retransmissions, which matters most for short web transfers and interactive traffic.
Look again at the "ACKs with ECE" count: around ten times the number of CE marks. In classic ECN, the receiver keeps setting ECE on every ACK until it sees CWR, so the sender learns "there was congestion" but not how much. Accurate ECN (AccECN), published as RFC 9768 in April 2026, fixes this by feeding back a count of CE marks, which newer congestion controls need. Linux has been adding AccECN in stages since kernel 6.18 (article 77): tcp_ecn values 3 to 5 enable it (3 for both directions, 4 to accept AccECN but request classic ECN, 5 to accept AccECN only), while the default stays 2.
L4S: ECN for very low latency
L4S (Low Latency, Low Loss and Scalable throughput), defined in RFCs 9330, 9331 and 9332 (2023: an informational architecture plus two experimental protocol specifications), takes ECN further. L4S senders mark their packets ECT(1). Routers put them in a separate, very short queue that marks CE as soon as the queue starts to build, often within a millisecond. The senders use congestion controls such as TCP Prague, or L4S modes of BBR (a model-based congestion control, article 76) and QUIC stacks, that respond smoothly to many small marks instead of halving their rate. The result is near-full throughput with queuing delays of a millisecond or two. Several cable and fiber broadband providers began deploying L4S in 2024–2026. Article 77 covers queue management and L4S in detail.
Common questions
What is the difference between DSCP and the ToS byte?
The ToS byte is the old name for the whole 8-bit field. DSCP is its first 6 bits, and ECN is the last 2. A DSCP value is the byte divided by 4: byte 0xB8 (184) is DSCP 46.
If I mark all my traffic EF, will my downloads get faster?
Almost certainly not. Your ISP probably ignores or resets marks from customers, and the marks on downloads are set by the server, not by you. Inside a network that does honor EF, the traffic is usually policed to a small rate, and excess EF traffic may be dropped or re-marked.
Does ECN make transfers faster?
Usually not in raw throughput, as the lab showed: both runs got the full link rate. ECN reduces loss and the delay of retransmissions. That makes short transfers finish sooner and keeps interactive traffic responsive.
Who sets the CE mark: the sender or the router?
A router, when its queue management decides to signal congestion. The sender sets only ECT(0) or ECT(1) to say "I can understand marks". The receiver never changes the IP ECN field. It reports CE back to the sender in the transport protocol: with TCP's ECE flag, or with ACK frame counters in QUIC.
Why are retransmitted packets sent as Not-ECT?
RFC 3168 forbids marking retransmissions as ECN-capable, to keep a situation where marks hide repeated losses from going unnoticed. That's why the lab's ECN run showed one or two Not-ECT data packets. RFC 8311 (2018) relaxed this rule for experiments, but classic TCP stacks still follow it.
Do IPv6 and IPv4 use the same DSCP values?
Yes. The Traffic Class byte in IPv6 has exactly the same DSCP and ECN layout and the same code points.
What does AF stand for, and does AF41 beat AF11?
Assured Forwarding. AF classes are separate queues with configured bandwidth shares, not a strict ranking, so AF41 isn't automatically "higher" than AF11. It depends on how much bandwidth the operator gives each class. Within a class, the drop precedence number orders who is dropped first.
Summary
- The second byte of the IP header holds a 6-bit DSCP and a 2-bit ECN field. It replaced the old ToS byte, and the class selector code points keep backward compatibility with IP Precedence.
- DSCP selects a per-hop behavior: EF for low delay, AF classes with drop precedences, CS values, CS6 for network control, LE for background traffic, NQB for small non-queue-building flows.
- Marks matter only where a router has a queue and is configured to honor them. In the lab, EF pings stayed under 1 ms while unmarked pings waited more than 100 ms. Across the Internet, marks are often reset.
- ECN lets a congested router set CE instead of dropping. TCP negotiates it in the handshake and feeds marks back with ECE and CWR. In the lab, about 50 marks replaced about 50 drops.
- AccECN (RFC 9768) gives precise mark counts, and L4S (ECT(1)) uses frequent marks to keep queuing delay around a millisecond.
Practice questions
1. What whole-byte value do you pass to ping -Q to send DSCP AF41? What is it in hexadecimal?
Answer
AF41 is DSCP 34 (binary 100010). The whole byte is 34 × 4 = 136 = 0x88, with the ECN bits 00.
2. A capture shows a Traffic Class byte of 0x03 on an IPv6 packet. What do the DSCP and ECN fields say?
Answer
0x03 is 000000 11. DSCP is 0 (default best effort), and ECN is 11, Congestion Experienced: a router on the path signaled congestion instead of dropping the packet.
3. An operator marks a customer's traffic AF31 up to 50 Mbit/s and AF33 above it. During congestion in class 3, which packets are dropped first?
Answer
The AF33 packets: within an AF class, a higher drop precedence number means a higher chance of being dropped, so the excess above 50 Mbit/s goes first.
4. Why does a router need active queue management, such as RED or fq_codel, to use ECN effectively?
Answer
ECN replaces a drop with a mark, so a router marks only when it would otherwise drop early. A plain tail-drop queue does nothing until it's completely full, then has to drop: there's no buffer left to keep the marked packet. AQM signals congestion early, while there is still room to forward marked packets, and a queue that signals early also stays short.
5. Two hosts both use net.ipv4.tcp_ecn=2. Will their connections use ECN?
Answer
No. A value of 2 means "accept ECN when the peer requests it, but don't request it". Neither side's SYN asks for ECN, so it's never negotiated. At least one side, the one opening the connection, must use 1.
6. Which code point would you choose for a nightly backup that should never slow down other traffic, and why not CS1?
Answer
LE, DSCP 1 (RFC 8622). CS1 was historically used for "scavenger" traffic, but some networks treat CS1 as ordinary or even elevated priority, because it maps to old precedence 1 ("priority"). RFC 8622 defined LE so that low-priority traffic has a code point with an unambiguous meaning.
Previous: The Internet Checksum: How It's Computed and What It Catches
Next: IPv4 Options and IPv6 Extension Headers: Hop-by-Hop, Routing and Fragment Headers

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.