Wiki DE Start in the browser

Wiki › Protocols

Quality of Service (DiffServ, 802.1p)

Prefer important traffic when a line is full: DSCP in the IP header, PCP in the VLAN tag, priority queues.

Layer
3 (DSCP) und 2 (PCP)
Standard
RFC 2474, RFC 2475, RFC 3246 …
See an example
See demo

When QoS helps

As long as a line has enough bandwidth, every packet gets through immediately and QoS changes nothing. But when more arrives than a port can send (typically: fast LAN, slow WAN line), packets have to wait. A queue without rules treats all of them the same: voice waits behind large data packets and is lost when the queue is full (tail drop). QoS makes sure important traffic goes first. It does not create more bandwidth.

Marking: DSCP and PCP

With Differentiated Services (DiffServ, architecture RFC 2475) the sender or the first network device marks each packet, and the devices along the way treat it according to that marking.

WhereFieldSizeStandard
IPv4 header, byte 2 (formerly TOS)DSCP6 bits (0–63) + 2 bits ECNRFC 2474, RFC 3168
IPv6 headerTraffic Classsame as IPv4RFC 2474
802.1Q tag (trunks only)PCP3 bits (0–7)IEEE 802.1Q

Recommended classes according to RFC 4594:

TrafficDSCPValuePCP
Network control (routing)CS6486
Telephony (voice)EF (RFC 3246)465
Signalling (SIP)CS5405
Video, conferencingAF41 (RFC 2597)344
Business dataAF21182
NormalDefault (best effort)00
BackgroundCS181

The class selectors (CS0–CS7) are compatible with the old IP precedence values: the top three bits of the DSCP give the class. This is how a switch maps DSCP to PCP: EF = 101110 → 101 = 5.

IPv4Packet · RFC 791, RFC 2474, RFC 3168
0481216202428
Version4 bits4
IHL4 bits5
DSCP6 bits0
ECN2 bits0
Total length16 bits140
Identification16 bits0x0006
Flags3 bitsDF
Fragment offset13 bits0
TTL8 bits64
Protocol8 bits6
Header checksum16 bits0x9aa7
Source IP32 bits192.168.10.100
Destination IP32 bits192.168.20.10
Options0–40 bytes
Payload≤ 65515 bytes120 Byte
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
FieldLengthExample valueMeaning
Version4 bits44 for IPv4.
IHL4 bits5Internet header length in 32-bit words: 5 = 20 bytes without options.
DSCP6 bits0Differentiated services: traffic class for quality of service (RFC 2474), 0 = best effort.
ECN2 bits0Explicit congestion notification: routers signal congestion without dropping packets (RFC 3168).
Total length16 bits (2 bytes)140Length of header and payload in bytes, at most 65,535.
Identification16 bits (2 bytes)0x0006Packet number; all fragments of a packet carry the same one.
Flags3 bitsDFBit 0 reserved, DF = don't fragment, MF = more fragments follow.
Fragment offset13 bits0Position of the fragment in the original packet, in steps of 8 bytes.
TTL8 bits64Time to live: each router subtracts 1; at 0 the packet is dropped (ICMP time exceeded).
Protocol8 bits6What is inside: 1 ICMP, 6 TCP, 17 UDP, 50 ESP, 89 OSPF.
Header checksum16 bits (2 bytes)0x9aa7Checksum over the header only (RFC 1071); each router recalculates it because of the TTL.
Source IP32 bits (4 bytes)192.168.10.100Sender, unchanged along the whole path (except with NAT).
Destination IP32 bits (4 bytes)192.168.20.10Destination, routers decide the path by it.
Options (optional)0–40 bytesRarely used (e.g. record route); IHL is then greater than 5.
Payload≤ 65515 bytes120 ByteThe segment or message of the next layer (TCP, UDP, ICMP …).
Values: Real frame from the demo “DNS, TCP and HTTP” (no. 36, 158 bytes), exactly as the packet list in leyoNET shows it.

Queues

A device with QoS has several queues per port. With strict priority (priority queuing) it always sends from the most important non-empty queue first. That is ideal for voice, which needs little bandwidth but cannot tolerate delay. For a lot of high-class traffic, devices additionally use weighted methods (e.g. weighted fair queuing) so that the lower classes do not starve.

Trust: a switch port to a PC should not accept markings, otherwise anyone could mark their traffic as “voice”. Without trust, the device resets the DSCP of incoming packets to 0.

In leyoNET

  • Router, switch, layer 3 switch, firewall: settings → QoS. “Enable QoS” activates four strict-priority queues: voice (EF), signalling and network control (CS5–CS7), preferred data (AF, CS2–CS4), best effort.
  • Bandwidth per port (e.g. 2M): congestion only happens there; without an entry the port sends at unlimited speed. At most 40 frames per queue, then tail drop (in the packet list: “dropped (queue full)”).
  • IP phones mark voice with EF and SIP with CS5; iperf -c <IP> -u -b 4M on a PC generates load.
  • On trunks the 802.1Q tag carries the PCP derived from the DSCP; the bytes show both.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Quality of Service (QoS)

QoS prefers important traffic when a line is full. Without congestion no QoS is needed.

  • Marking: the 6-bit DSCP field in the IP header (RFC 2474) says how important a packet is. IP phones mark voice with EF (46, RFC 3246) and SIP with CS5 (40), as recommended by RFC 4594. In the 802.1Q tag, PCP (3 bits) carries the priority across trunks.
  • Bottleneck: enter a bandwidth per port under QoS (e.g. 2M for a WAN line). If more arrives than the port can send, the rest waits in a queue; when it is full, packets are lost.
  • Priority queues: with “Enable QoS” there are four queues; voice always goes first (strict priority).
  • Trust: without “Trust DSCP” the device resets incoming markings to 0, e.g. on ports to PCs.
  • Generate load: “iperf -c <IP> -u -b 3M” on a PC. Check: call with “call” and the quality in the Telephony tab.

See an example

  • Telephony with QoS over a WAN line

    Two sites, connected by a 2 Mbit/s line. A PC loads it with 4 Mbit/s while phones 201 and 202 call each other via the phone system (SIP, RTP). Thanks to QoS the voice still arrives cleanly.

    Filter “sip”: REGISTER, INVITE, 180 Ringing, 200 OK, ACK, BYE. Filter “rtp”: the voice packets with DSCP EF. After the call the phone shows loss, delay and jitter.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★★★★☆ Calling despite a full line (QoS) · 2 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

What leyoNET simplifies

ProtocolLayerSimplification in the simulation
DiffServ (DSCP), 802.1p3DSCP in the IPv4 header, PCP in the 802.1Q tag from the top three DSCP bits; four strict-priority queues only on ports with a configured bandwidth, tail drop at 40 frames; no WRED, no policing, no custom class rules (marking by the phones)

Standards

  • RFC 2474 – Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers
  • RFC 2475 – An Architecture for Differentiated Services
  • RFC 3246 – An Expedited Forwarding PHB (Per-Hop Behavior)
  • RFC 2597 – Assured Forwarding PHB Group
  • RFC 4594 – Configuration Guidelines for DiffServ Service Classes
  • IEEE 802.1Q – Bridges and Bridged Networks (current edition: IEEE 802.1Q-2022)

Read on

Found a mistake or have an idea? Source of this page on GitHub.