QoS/CAKE
Per-subscriber traffic shaping with CAKE qdisc.
Overview
AthenaBNG applies per-subscriber QoS using CAKE (Common Applications Kept Enhanced), a modern qdisc that provides:
- Fair bandwidth allocation
- Low latency
- Automatic overhead calculation
- Per-flow fairness
- Built-in SQM (Smart Queue Management)
CAKE Qdisc
CAKE is a modern replacement for fq_codel that:
- Automatically detects and isolates flows
- Provides fair bandwidth allocation
- Reduces latency and jitter
- Handles overhead calculation
- Supports diffserv (QoS classes)
CAKE Parameters
tc qdisc add dev ppp0 root cake \
bandwidth 100Mbit \
overhead 34 \
mpu 64 \
rtt 20ms \
ack-filter \
split-gst \
diffserv4 \
nat \
nowash
| Parameter | Value | Purpose |
|---|---|---|
bandwidth | Rate | Download/upload rate |
overhead | Bytes | Encapsulation overhead |
mpu | Bytes | Minimum packet unit |
rtt | Time | Round-trip time estimate |
ack-filter | — | Filter duplicate ACKs |
split-gst | — | Split GST (get-set-test) |
diffserv4 | — | 4-class QoS |
nat | — | NAT detection |
nowash | — | Disable wash |
Overhead Profiles
Different encapsulations require different overhead calculations:
PPPoE over Ethernet
pppoe_ethernet:
overhead: 34
mpu: 64
Breakdown:
- Ethernet: 14 bytes
- PPPoE: 6 bytes
- PPP: 2 bytes
- IP: 20 bytes (minimum)
- FCS: 4 bytes
- Total: 46 bytes (rounded to 34)
IPoE over Ethernet
ipoe_ethernet:
overhead: 22
mpu: 64
Breakdown:
- Ethernet: 14 bytes
- VLAN: 4 bytes
- FCS: 4 bytes
- Total: 22 bytes
PPPoE over QinQ
pppoe_qinq:
overhead: 38
mpu: 64
Breakdown:
- Ethernet: 14 bytes
- Outer VLAN: 4 bytes
- Inner VLAN: 4 bytes
- PPPoE: 6 bytes
- PPP: 2 bytes
- IP: 20 bytes
- FCS: 4 bytes
- Total: 54 bytes (rounded to 38)
Ingress Shaping
For upload rate limiting, abng-qos creates IFB (Intermediate Functional Block) devices:
# Create IFB device
ip link add ifb-ppp0 type ifb
# Redirect ingress to IFB
tc filter add dev ppp0 parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev ifb-ppp0
# Apply CAKE to IFB
tc qdisc add dev ifb-ppp0 root cake bandwidth 40Mbit ...
# Bring up IFB
ip link set ifb-ppp0 up
Configuration
qos:
enabled: true
default_down: "100mbit"
default_up: "40mbit"
default_overhead_profile: "pppoe_ethernet"
overhead_profiles:
pppoe_ethernet:
overhead: 34
mpu: 64
ipoe_ethernet:
overhead: 22
mpu: 64
Per-Subscriber Rates
Default Rates
All subscribers get default rates:
qos:
default_down: "100mbit"
default_up: "40mbit"
RADIUS Override
RADIUS can override rates per-subscriber:
Athena-Rate-Down = "50mbit"
Athena-Rate-Up = "20mbit"
Dynamic Rate Changes (CoA)
RADIUS server can change rates on-the-fly:
Acct-Session-Id = "abng-1709312400-1"
Athena-Rate-Down = "25mbit"
Athena-Rate-Up = "10mbit"
abng-qos applies new rates without packet loss.
Monitoring
View QoS Status
abng> show qos
Check CAKE Qdisc
tc qdisc show
tc -s qdisc show dev ppp0
View IFB Devices
ip link show | grep ifb
Monitor abng-qos Logs
sudo journalctl -u abng-qos -f
Testing
Verify Download Rate
# From subscriber
iperf -c <bng-ip> -t 10 -R
Verify Upload Rate
# From subscriber
iperf -c <bng-ip> -t 10
Check Latency
# From subscriber
ping <bng-ip>
Troubleshooting
QoS Not Applying
- Check QoS is enabled:
show configuration | match qos - Check CAKE qdisc exists:
tc qdisc show - Check abng-qos logs:
journalctl -u abng-qos -f - Check session is active:
show subscribers
Rates Not Matching Expected
- Check overhead profile:
show configuration | match overhead_profiles - Verify with
iperf:iperf -c <subscriber-ip> -t 10 - Check CAKE stats:
tc -s qdisc show dev ppp0 - Adjust overhead if needed
IFB Ingress Shaping Not Working
- Check IFB device exists:
ip link show | grep ifb - Check ingress qdisc:
tc qdisc show dev ifb-ppp0 - Check abng-qos logs:
journalctl -u abng-qos -f
Best Practices
- Overhead Profile — Match your actual encapsulation
- Default Rates — Set reasonable defaults for your subscriber base
- RADIUS Override — Use RADIUS for per-subscriber customization
- Testing — Test with
iperfto verify rates - Monitoring — Monitor CAKE stats for congestion
- Ingress Shaping — Enable IFB for upload rate limiting
- Documentation — Document your overhead calculations
Next Steps
- RADIUS AAA — RADIUS integration
- CGNAT — Carrier-Grade NAT
- Monitoring — Prometheus and syslog