QoS: Giving Priority to Calls and Video Conferences
The upload bottleneck, queues and bufferbloat, latency and jitter, DSCP (EF, AF41) and 802.1p classification and marking, queues and priorities, traffic shaping below the real speed, FQ-CoDel, an example with the OPNsense shaper, QoS on switches and Wi-Fi (WMM), latency under load measurements and common mistakes.
At the office a colleague uploads a video of a few gigabytes to the cloud, or the NAS starts its backup. Within seconds the video conference freezes, the picture stops and the voice breaks up. Yet the line is fibre and the local network runs at 1 Gbit/s. The problem is not so much the amount of bandwidth as the order in which packets leave for the Internet. Let's see why it happens, what latency, jitter and bufferbloat are, how packets are classified and marked with DSCP, how traffic shaping brings the queue back to the firewall and how to configure an example with OPNsense, measuring before and after.
Why the voice breaks up during a backup
Every network has a bottleneck: the slowest link along the path. In a small business or at home it is almost always the Internet line, and usually in the upload direction. An FTTC or FWA line may offer, for example, 100 Mbit/s download and 20 Mbit/s upload, while the NAS sending the backup is connected to the switch at 1 Gbit/s. The NAS transmits much faster than the line can carry.
Excess packets do not disappear: they pile up in a queue (buffer) in the device just before the slow section, that is in the provider's router or in the firewall. The simplest queue is FIFO (first in, first out): whoever arrives first leaves first. A packet of the phone call, small and urgent, lines up behind hundreds of large backup packets and waits its turn.
Let's do the maths, with indicative values. A 1500-byte packet contains 12,000 bits: at 20 Mbit/s it occupies the line for 0.6 ms. If there are 600 backup packets in the queue, the last one to arrive waits about 360 ms before leaving. For the backup this changes almost nothing; for a conversation it is a huge delay.
Latency, jitter and bufferbloat
To understand QoS (Quality of Service) we need to tell three quantities apart.
- Bandwidth: how many bits per second get through. A VoIP call with the G.711 codec uses between 80 and 90 kbit/s in each direction, depending on which headers are counted; a video call from 1.5 to 4 Mbit/s, depending on quality. These are small values compared with the line.
- Latency: how long a packet takes to arrive. ITU-T Recommendation G.114 advises staying below 150 ms of one-way delay for a natural conversation; beyond that, people start talking over each other.
- Jitter: how much latency varies from one packet to the next. The phone receives a packet every 20 ms and puts them back in order in a small playout buffer. If a packet arrives too late it is discarded, and the voice loses a syllable.
For voice, latency and jitter matter far more than bandwidth. A 1 Gbit/s line with 300 ms of queue performs worse than a 20 Mbit/s line with a steady 20 ms.
The term bufferbloat describes exactly this flaw: routers and modems with very large queues which, under load, fill up and add hundreds of milliseconds of delay. The backup's TCP keeps increasing its rate until it loses packets; if the queue is huge, the loss comes late and in the meantime the queue stays full. The result is the classic network that is “great” in speed tests and terrible in video conferences.
The three operations of QoS
QoS does not create bandwidth. It decides who goes first when there is not enough bandwidth for everyone. It relies on three operations:
- classification: recognising the type of traffic, for example from the IP phone's address, from the ports of the conferencing service or from a marking already present;
- marking: writing a value into the packet that tells the following devices which class it belongs to;
- queue management: giving each class its own queue, with different priorities or weights, and deciding which packets to drop when the queue grows.
Queue management only has an effect where a queue forms, that is at the bottleneck. Everything else depends on that point.
DSCP: marking in the IP header
The IPv4 header contains a byte now called the DS field (Differentiated Services, RFC 2474); in IPv6 it is the Traffic Class field. The first 6 bits are the DSCP (Differentiated Services Code Point), with values from 0 to 63; the last 2 bits are used by ECN, explicit congestion notification. Some values have a standard meaning:
| Class | DSCP | Bits | Typical use |
|---|---|---|---|
| EF (Expedited Forwarding, RFC 3246) | 46 | 101110 | Voice: few packets, low latency, low jitter |
| AF41 (Assured Forwarding, RFC 2597) | 34 | 100010 | Interactive video and video conferences |
| CS3 / AF31 | 24 / 26 | 011000 / 011010 | Call signalling, important data |
| Best effort (default) | 0 | 000000 | Everything else: browsing, e-mail, updates |
| CS1 | 8 | 001000 | Low-priority traffic, such as backups and synchronisation |
RFC 4594 collects these mappings as guidelines; they are the most common examples, not an obligation. Many IP phones already mark voice with EF and signalling with CS3; some conferencing applications do the same, others do not. This is why the firewall and the switches can also re-mark packets: trust the marking only on the ports and in the networks you control, and rewrite it elsewhere.
DSCP belongs to layer 3. There is also a layer 2 marking: in the 802.1Q VLAN tag, next to the VLAN number, there is the PCP field (Priority Code Point, “802.1p”), 3 bits wide, with values from 0 to 7. It only applies on tagged links, between switches or between a switch and a phone, and it is lost when the router removes the tag. Many switches translate PCP into DSCP and vice versa. A VLAN dedicated to phones, like the one described in VLANs, security and organisation, makes classification much simpler.
Queues and priorities
Once traffic is classified, the device spreads it over several queues and decides in which order to serve them. There are two main models.
- Strict priority: the voice queue is always emptied first. Delay is minimal, but an unlimited priority queue could take all the bandwidth away from the others: this is why it is given a ceiling, for example 10–20% of the line.
- Weighted queues (weighted fair queueing): each queue receives a share proportional to its weight. Voice, with a high weight and very little traffic, is served at once; the backup gets all the bandwidth left over.
All this works only if the queue forms in the device that applies the rules. If the firewall sends 1 Gbit/s towards a provider router that can carry 20, the queue forms in the provider's router, which is FIFO and often the bloated one. The firewall's priorities are never used, because nothing ever waits in the firewall.
Traffic shaping: keeping the queue on the firewall
The solution is traffic shaping: the firewall itself limits outgoing traffic to a rate slightly lower than the line's real speed, for example 19 Mbit/s on a measured upload of 20. The provider router's queue then stays empty and the queue forms on the firewall, where we manage it. We give up 5–10% of the bandwidth in exchange for low and stable latency.
Inside the shaper we need a good queue management algorithm. A widely used example is FQ-CoDel (RFC 8290):
- FQ, flow queueing: it splits traffic into many flows (by addresses and ports) and serves them in turn. A phone call, which sends few small packets, no longer waits behind the backup;
- CoDel (RFC 8289): it measures how long packets stay in the queue. If the wait stays above a target for too long, by default 5 ms over a 100 ms interval, it drops or ECN-marks a few packets of the largest flow. The backup's TCP slows down and the queue stays short.
In many home and small office networks, a shaper with FQ-CoDel solves most of the problem even without marking anything. Classification and priorities become useful when lines are very slow or there are many simultaneous calls.
What about the download? There the bottleneck is on the other side of the line, in the provider's network, and packets arrive already delayed. An inbound shaper, set at around 90% of the download speed, still helps: by dropping a few packets before the provider's queue fills up, it makes TCP slow down. Control, however, is less precise than for upload.
An example with OPNsense
An office with a line of 100 Mbit/s download and 20 Mbit/s upload, measured in the evening with the network idle, LAN network 192.168.1.0/24 and IP phones in VLAN 30, network 192.168.30.0/24. In OPNsense the shaper is under Firewall › Shaper, with three tabs: Pipes, Queues and Rules. Menus may vary with the version: the names below are indicative and should be checked in the official documentation for the installed version.
- Upload pipe: in Pipes, a pipe called “Upload”, with a bandwidth of 19 Mbit/s and FlowQueue-CoDel (FQ-CoDel) as the scheduler. It is the overall ceiling for outgoing traffic.
- Download pipe: a second pipe, “Download”, with a bandwidth of 90 Mbit/s and the same scheduler.
- Weighted queues (optional, as an alternative to FQ-CoDel): if you want explicit priority, the “Upload” pipe uses a weighted scheduler (weighted fair queueing) and in Queues you create inside it a “Voice” queue with a high weight, for example 90, and an “Other” queue with a low weight, for example 10. Weights only count with a scheduler that uses them.
- Shaper rules: in Rules, on the WAN interface, one rule with the outbound direction (out) towards the “Upload” pipe and one with the inbound direction (in) towards the “Download” pipe. If queues are used, a more specific rule, placed first, sends traffic with source 192.168.30.0/24 to the “Voice” queue; depending on the version, the DSCP value can also be matched.
- Test: apply the configuration and measure latency under load, as described below.
Shaper rules are separate from the normal firewall rules: they do not decide what gets through, but how it gets through. Filter rules remain the ones described in how a firewall rule works, and the firewall keeps recognising connections with the state table, as explained in stateful firewalls and the state table. With two lines, each WAN has its own speed and therefore its own pipes: a case to plan together with the failover described in OPNsense with two Internet connections.
QoS on switches and Wi-Fi
Managed switches usually have 4 to 8 queues per port and can read PCP or DSCP. They are useful when a switch port is genuinely congested: for example a 1 Gbit/s link between two cabinets where many users converge, or a phone and a PC daisy-chained on the same wall socket. In a small network with 1 Gbit/s links and a 20 Mbit/s line, switch QoS hardly ever comes into play: its queues are always empty.
Wi-Fi is often a second bottleneck. The WMM standard (Wi-Fi Multimedia, from IEEE 802.11e) defines four access categories: voice, video, best effort and background. With WMM enabled, the access point and the clients transmit voice with shorter waiting times, and packets are mapped to the categories according to DSCP (RFC 8325 describes the mappings). WMM has been mandatory for Wi-Fi certification since 802.11n: do not disable it. If, however, the signal is weak or the channel is crowded, no priority is enough: in that case the cause should be investigated as explained in slow Wi-Fi with an excellent signal.
Marking counts where you control the network
DSCP travels inside the packet all the way to the destination, but providers usually ignore it or reset it at the edges of their network. On the Internet there is no fast lane for packets marked EF. QoS works on the sections we manage: LAN, Wi-Fi, firewall and, above all, the output queue towards the line. The exceptions are links managed by the provider under a contract that includes classes of service, such as some business lines or VoIP services supplied by the same provider.
Measuring before and after
A speed test on its own says nothing about call quality. What you need is a latency under load test: measure the delay while the line is full. The simplest method is a continuous ping to an address on the Internet while a heavy upload starts. Here is an example on Windows, with addresses reserved for documentation and illustrative values. Before, without a shaper:
C:\> ping -n 6 192.0.2.80
Reply from 192.0.2.80: bytes=32 time=14ms TTL=58
Reply from 192.0.2.80: bytes=32 time=15ms TTL=58
Reply from 192.0.2.80: bytes=32 time=212ms TTL=58
Reply from 192.0.2.80: bytes=32 time=348ms TTL=58
Reply from 192.0.2.80: bytes=32 time=371ms TTL=58
Reply from 192.0.2.80: bytes=32 time=366ms TTL=58
The first two replies arrive with the network idle; from the third one the upload has started and the delay rises by more than 300 ms. After, with the shaper at 19 Mbit/s and FQ-CoDel, under the same load:
C:\> ping -n 6 192.0.2.80
Reply from 192.0.2.80: bytes=32 time=14ms TTL=58
Reply from 192.0.2.80: bytes=32 time=15ms TTL=58
Reply from 192.0.2.80: bytes=32 time=19ms TTL=58
Reply from 192.0.2.80: bytes=32 time=17ms TTL=58
Reply from 192.0.2.80: bytes=32 time=21ms TTL=58
Reply from 192.0.2.80: bytes=32 time=18ms TTL=58
The upload proceeds at almost the same speed, but latency stays close to the idle value. To read these values properly, see ping and traceroute. There are also online tests that measure latency during download and upload; whatever tool you use, repeat the test at different times of day and keep a note of the results.
Common mistakes
- Marking everything as priority. If backups and updates also end up in the EF class, the EF class becomes an ordinary FIFO queue again. Priority is for a few small, urgent flows.
- Setting the shaper above the real speed. With a 25 Mbit/s pipe on a 20 Mbit/s upload, the firewall never holds anything back: the queue goes back to the provider's router and QoS has no effect. Start from the measured speed, not the contract speed, and go 5–10% lower.
- QoS only on the switch. Carefully configuring the switch queues when the bottleneck is the line changes nothing: the queue that hurts is the one towards the Internet.
- Forgetting the download. An update downloading at full speed also degrades incoming voice. An inbound pipe slightly below the real speed reduces the problem.
- Trusting everyone's marking. Any PC can mark its own packets with EF. Trust DSCP only from the phones or their VLAN; rewrite it elsewhere.
- Not measuring. Without a latency under load test before and after, you cannot know whether the configuration works. After a change of line or contract, the values must be reviewed.
Conclusions
Video calls freeze during a backup because voice packets wait in the queue behind large ones, on the slowest link. In practice:
- identify the bottleneck: almost always the upload of the Internet line;
- measure the real speed and the latency under load, with the network idle and during an upload;
- enable on the firewall an outbound shaper at 90–95% of the measured upload, with FQ-CoDel, and an inbound one at around 90% of the download;
- if needed, classify and mark voice (EF 46) and video conferencing (AF41), ideally with the phones in a dedicated VLAN;
- keep WMM enabled on the access points and check switch QoS only where links are genuinely congested;
- repeat the latency under load test and keep the results for future comparisons.
To go further into Internet access, VLANs and OPNsense configuration with complete examples, the books and courses listed below are useful.
The video
Further reading
- Book: LOCAL AREA NETWORKS (LAN) — Volume 3: Switching, VLANs, and Business Networks (English edition)
- Book: LOCAL AREA NETWORKS (LAN) — Volume 4: Routing, NAT, and Internet Access (English edition)
- Book: OPNsense® in Practice — Volume 1: The Foundations of a Professional Journey (English edition)
- Video course: Capire i Firewall con OPNsense (video course in Italian)
- Video course: VLAN con OPNsense®: progettazione e configurazione (video course in Italian)
- Related article: Why Is Wi-Fi Slow Even When the Signal Is Excellent?
- Related article: How a Firewall Rule Works
- Related article: VLANs: Why Separating Networks Improves Security and Organisation
- Related article: Ping and Traceroute: How to Really Read the Results
- Related article: Stateful Firewalls: Why Replies Get Through Without a Rule
- Related article: OPNsense with Two Internet Connections: Failover and Load Balancing
- Specialization: LAN Networks
Technical sources
- RFC 2474 e RFC 3168 — Differentiated Services Field; Explicit Congestion Notification — The DS field of the IPv4 header and the IPv6 Traffic Class: 6 bits of DSCP, values from 0 to 63, and 2 bits for ECN.
- RFC 3246, RFC 2597 e RFC 4594 — Expedited Forwarding, Assured Forwarding, linee guida per le classi di servizio — EF (DSCP 46) for low-latency traffic such as voice, AF classes (AF41 = 34), low-priority CS1; recommended mappings between applications and classes.
- RFC 8289 e RFC 8290 — Controlled Delay (CoDel); FlowQueue-CoDel — Active queue management based on sojourn time (default target 5 ms, interval 100 ms) and per-flow queues served in turn.
- IEEE 802.1Q e IEEE 802.11e (WMM); RFC 8325 — The 3-bit PCP field in the VLAN tag (802.1p); Wi-Fi access categories for voice, video, best effort and background; mapping between DSCP and Wi-Fi priority.
- ITU-T G.114 — One-way transmission time — Guidance to stay below 150 ms of one-way delay for conversations.
- RFC 5737 e RFC 1918 — Addresses used in the examples: 192.0.2.0/24 reserved for documentation and the private networks 192.168.1.0/24 and 192.168.30.0/24.
- Documentazione ufficiale di OPNsense — Traffic Shaping — The shaper under Firewall › Shaper with pipes, queues and rules, the FlowQueue-CoDel scheduler and queue weights; menus and options depend on the version.
Standards and official documentation available from the respective organisations.