I implemented QoS by marking latency-sensitive traffic with DSCP and shaping bandwidth using Linux tc with hierarchical token bucket (HTB) classes. Under simulated congestion, priority traffic held low latency while bulk transfers were capped to their allocation.

Objective & Context

Without QoS, bulk transfers starve interactive flows during congestion. This lab classifies traffic with DSCP and enforces per-class bandwidth and priority with HTB, the mechanism behind voice/video prioritization on shared links.

Environment & Prerequisites

  • Linux host with tc (iproute2) and iperf3.
  • A constrained test link to create congestion.
  • Defined traffic classes (priority vs bulk).

Step-by-Step Execution

1. Build the HTB hierarchy [PRIVILEGED]

tc qdisc add dev eth0 root handle 1: htb default 30 && tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit

2. Add priority and bulk classes

tc class add dev eth0 parent 1:1 classid 1:10 htb rate 60mbit prio 0 && tc class add dev eth0 parent 1:1 classid 1:30 htb rate 40mbit prio 1

3. Mark and verify under load with iperf3

iperf3 -c 192.168.10.30 -S 0xb8 && tc -s class show dev eth0
class htb 1:10 rate 60Mbit  sent 71MB  (priority held)
class htb 1:30 rate 40Mbit  sent 48MB  (bulk capped)

Validation & Testing

Generate simultaneous priority and bulk flows and measure latency/throughput per class. Pass criteria: priority class retains low latency and its rate, while bulk is shaped to its ceiling under contention.

Advanced: Troubleshooting
  • No shaping effect: tc shapes egress; apply on the correct outbound interface or use IFB for ingress.
  • Wrong class match: verify the filter maps DSCP/marks to the intended classid.
  • Bursty behaviour: tune burst and cburst for HTB.

Key Results

  • Held priority-class latency low under simulated link saturation.
  • Capped bulk flows to a 40mbit ceiling during contention.
  • Classified traffic by DSCP into 2 enforced HTB classes.
  • Verified per-class throughput with tc statistics under iperf3 load.