Quality of Service
Objective
Understand QoS concepts, classify traffic, and configure basic traffic shaping on Linux using tc.
Tools & Technologies
DSCPtraffic shapingtcqueuing disciplines
Key Commands
tc qdisc add dev eth0 root tbf rate 100mbittc qdisc show dev eth0tc class add dev eth0 parent 1: classid 1:1 htb rate 50mbitArchitecture Overview
flowchart TD
TRAFFIC[All Traffic] --> CLASS{Classification\nDSCP / Port / Protocol}
CLASS -->|VoIP\nDSCP EF| Q1[Priority Queue\nLow latency]
CLASS -->|Video\nDSCP AF41| Q2[Bandwidth Guaranteed\nQueue]
CLASS -->|Data\nDSCP BE| Q3[Best Effort\nQueue]
CLASS -->|Bulk/Backup\nDSCP CS1| Q4[Scavenger\nQueue]
Q1 --> OUT[Egress\nInterface]
Q2 --> OUT
Q3 --> OUT
Q4 --> OUT
style CLASS fill:#1a1a2e,stroke:#00d4ff,color:#e0e0e0
style Q1 fill:#1a1a2e,stroke:#00ff88,color:#e0e0e0
Step-by-Step Process
01
QoS Concepts
QoS prioritizes traffic to ensure latency-sensitive applications (VoIP, video) get bandwidth over bulk traffic.
# DSCP marking values:
# EF (46) - Expedited Forwarding (VoIP)
# AF41(34) - Assured Forwarding (Video)
# CS3 (24) - Call Signaling
# BE (0) - Best Effort (default)
# CS1 (8) - Scavenger (background)
02
Linux Traffic Control (tc)
Linux tc implements queuing disciplines (qdiscs) for traffic shaping.
# Simple rate limiter (token bucket filter)
tc qdisc add dev eth0 root tbf \
rate 100mbit burst 10mb latency 50ms
# View current qdiscs
tc qdisc show dev eth0
# Remove
tc qdisc del dev eth0 root
03
HTB — Hierarchical Token Bucket
HTB allows bandwidth allocation with guaranteed minimums and shared maximums.
# Root qdisc
tc qdisc add dev eth0 root handle 1: htb default 30
# Parent class
tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit
# VoIP: guaranteed 10mbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 10mbit ceil 100mbit prio 1
# Data: best effort
tc class add dev eth0 parent 1:1 classid 1:30 htb rate 10mbit ceil 100mbit prio 3
Challenges & Solutions
- tc configuration is not persistent — use /etc/network/interfaces or systemd unit
- HTB configuration is complex — start with simple tbf for basic rate limiting
Key Takeaways
- Mark traffic at ingress — remarking at egress is less effective
- VoIP needs low latency (< 150ms) AND low jitter (< 30ms) — prioritize both