Dynamic and Automated Allocation and Management of Network Bandwidth and Traffic Priority to Preserve Critical Service QoS under Network Congestion.
Modern enterprise, telecom, and industrial networks experience sudden bandwidth saturation, asymmetric WAN/wireless link degradation, and priority spoofing. Traditional static QoS policies and unmanaged FIFO queues either suffer severe bufferbloat (pushing real-time latency to tens or hundreds of milliseconds) or fail to defend mission-critical services when upstream capacity fluctuates or bulk elephant streams spoof high DiffServ code points.
Dynamic Bandwidth & QoS Manager is a complete, memory-safe (#![forbid(unsafe_code)]) traffic classification, shaping, Active Queue Management (AQM), and autonomous closed-loop congestion control system built from the ground up in Rust.
It combines:
- Multi-Layer Traffic Classification & Behavioral Anti-Spoofing (
qos-classifier) - Hierarchical Token Bucket (HTB) + Hybrid Strict Priority / Weighted DRR + RFC 8289 CoDel AQM (
qos-scheduler) - Autonomous Closed-Loop Congestion Controller with Hysteresis & PID Bottleneck Adaptation (
qos-controller) - Zero-Allocation Wire Packet Parser, RFC 1624 DSCP/ECN Rewriter, OS Policy Exporters & Live Async UDP Shaper Proxy (
qos-dataplane) - Deterministic Multi-Scenario Congestion Simulator (
qos-sim) - Embedded REST Control API, Prometheus
/metricsExporter & Real-Time Web NOC Dashboard (qos-telemetry+qos-cli)
flowchart TB
Ingress["Network / UDP Proxy Ingress"] --> Parser["qos-dataplane: Wire Parser (Ethernet / VLAN / IPv4 / IPv6 / L4)"]
Parser --> Classifier["qos-classifier: 5-Stage Classifier + Anti-Spoofing Flow Table"]
Classifier -->|"Service Tier (0..3) + DSCP Remark"| Scheduler["qos-scheduler: HTB + Strict Priority / WDRR + CoDel AQM"]
Scheduler -->|"Paced Wire Egress + ECN-CE / DSCP"| Egress["Upstream Link / Live UDP Forwarder / OS tc & NetQoS"]
Scheduler -->|"Per-Tier Delay (p50/p95/p99), Jitter, Drops & ECN"| Controller["qos-controller: Closed-Loop Optimizer & Hysteresis FSM"]
Controller -->|"Dynamic CIR/PIR, CoDel Targets & Virtual Link Cap"| Scheduler
Controller -->|"Snapshots, Flows & Audit Events"| Telemetry["qos-telemetry: REST API, Prometheus /metrics & Web NOC"]
| Priority | Tier | Target Workloads | Default SLA Bounds | DiffServ DSCP |
|---|---|---|---|---|
| Tier 0 | critical_realtime |
VoIP/SIP/RTP, SCADA/Modbus, DNP3, BGP, NTP, Emergency Telemetry | p95 <= 8 ms, jitter <= 2.5 ms, loss <= 0.05% |
EF (46) |
| Tier 1 | interactive_high |
WebRTC Video, SSH/RDP, DNS, Financial/Low-Latency RPC | p95 <= 20 ms, jitter <= 6.0 ms, loss <= 0.50% |
AF41 (34) |
| Tier 2 | business_standard |
Enterprise HTTPS/gRPC APIs, Database Sync, Transactional Apps | p95 <= 60 ms, jitter <= 20 ms, loss <= 2.00% |
AF21 (18) |
| Tier 3 | bulk_best_effort |
Cloud Backups, OS Updates, SMB/FTP/rsync, Demoted Elephants | Elastic shedding under congestion (3% emergency floor) |
CS0 (0) |
-
5-Stage Classification & Behavioral Anti-Spoofing (
qos-classifier)- Matches priority-ordered IPv4/IPv6 CIDR + port + protocol rules, application hints, well-known service signatures, and RFC 4594 DSCP values.
- Tracks flows in a memory-bounded hash table (
max_tracked_flows, default65,536) to prevent flow-flood memory exhaustion. - DSCP Spoof Detection: Automatically detects large-packet, sustained high-bitrate elephant flows falsely tagged with
EF (46)/AF41 (34)and demotes them toBulkBestEffort, preserving critical capacity. - Interactive Mice Boost: Temporarily promotes short, small-packet transactional flows for snappy responsiveness.
-
Hybrid Strict Priority HTB + WDRR + CoDel AQM (
qos-scheduler)- Pass 1 (Strict Priority CIR): Guarantees low-latency dispatch for active
CriticalRealtimeandInteractiveHighpackets within their committed rates. - Pass 2 (Surplus Borrowing + WDRR): Shares idle link bandwidth across eligible classes up to dynamic PIR ceilings so link utilization stays high under normal loads without starving critical tiers.
- RFC 8289 CoDel + ECN: Monitors per-packet sojourn time; marks
ECN-CEon ECN-capable transports or head-drops stale packets viainterval / sqrt(count)before queues bloat. - RFC 2698 Dual-Rate Three-Color Policer (
trTCM): Available as a modular Green/Yellow/Red meter.
- Pass 1 (Strict Priority CIR): Guarantees low-latency dispatch for active
-
Autonomous Closed-Loop Control & Hysteresis (
qos-controller)- Asymmetric EWMA Demand Estimation: Reacts rapidly to surges while decaying smoothly without self-locking on throttled bulk queues.
- Hysteresis State Machine: Transitions across
Normal -> Elevated -> Congested -> CriticalSaturationwith immediate critical SLA escalation and damped recovery (recovery_hold_ticks) to eliminate policy flapping. - PID Bottleneck Virtual Capacity Adaptation: Detects upstream link degradation (e.g., LTE/WAN fade) from rising critical queuing delay and dynamically scales
effective_capacity_bpsdown to keep queue ownership inside the local HTB/CoDel scheduler, then probes back up once healthy.
-
Data Plane, Live Async Proxy & OS Exporters (
qos-dataplane)- Zero-allocation parser for Ethernet II, 802.1Q VLAN, IPv4, IPv6, TCP, UDP, and ICMP headers.
- In-place DSCP and ECN header rewriting with exact RFC 1624 incremental IPv4 checksum recalculation.
- Live asynchronous
tokioUDP QoS shaper proxy (qosd) supporting real-time policy hot-reloading. - Production policy script exporters for Linux
tc(htb+fq_codel+u32DSCP filters) and Windows PowerShell (New-NetQosPolicy).
-
Observability & Live Web NOC Dashboard (
qos-telemetry)- Embedded zero-dependency dark-mode NOC dashboard at
GET /. - Prometheus metrics at
GET /metrics, JSON status/flows/decisions endpoints under/api/v1/*, and bearer-token-protected policy updates (PUT /api/v1/policy).
- Embedded zero-dependency dark-mode NOC dashboard at
All results below were produced directly by qosctl sim --scenario all --link-mbps 100 and qosctl bench --packets 200000 on a 100.0 Mbps nominal link over 12.0 s deterministic runs:
| Engine Mode | critical_realtime P95 / P99 |
critical_realtime Loss |
interactive_high P95 / P99 |
Critical & Interactive SLA |
|---|---|---|---|---|
| Baseline FIFO | 20.50 ms / 20.75 ms |
0.00% |
20.50 ms / 20.75 ms |
FAIL |
| Static HTB | 1.50 ms / 1.50 ms |
0.00% |
1.50 ms / 1.50 ms |
PASS |
| Adaptive Dynamic QoS | 0.00 ms / 1.50 ms |
0.00% |
0.00 ms / 1.50 ms |
PASS |
| Engine Mode | critical_realtime P95 |
critical_realtime Loss |
interactive_high P95 / Loss |
business_standard P95 / Loss |
Outcome |
|---|---|---|---|---|---|
| Baseline FIFO | 46.25 ms |
0.02% |
46.25 ms / 1.04% |
46.50 ms / 6.75% |
ALL FAIL |
| Static HTB | 58.00 ms |
0.06% |
58.00 ms / 1.26% |
58.00 ms / 6.91% |
ALL FAIL |
| Adaptive Dynamic QoS | 3.75 ms |
0.00% |
3.75 ms / 0.00% |
3.75 ms / 0.00% |
ALL PASS (23 control adaptations) |
| Engine Mode | critical_realtime P95 / P99 |
critical_realtime Loss |
critical_realtime Goodput |
Spoofer Demoted | SLA |
|---|---|---|---|---|---|
| Baseline FIFO | 20.50 ms / 20.75 ms |
0.00% |
6.00 Mbps |
No | FAIL |
| Static HTB | 109.50 ms / 116.25 ms |
5.59% |
5.69 Mbps |
No | FAIL |
| Adaptive Dynamic QoS | 0.00 ms / 1.50 ms |
0.00% |
6.00 Mbps |
Yes (1 flow) |
PASS |
- Processed Packets:
200,000(mixed SIP/VoIP, WebRTC, HTTPS, SMB traffic) - Elapsed Time:
32.994 ms - Sustained Throughput: ~6.06 million packets/sec (
165.0 ns/packetaverage)
Dynamic-Bandwidth-QoS-Manager/
├── Cargo.toml # Workspace manifest & shared dependency pinning
├── LICENSE # MIT License (Copyright (c) 2026 AMISEF)
├── SECURITY.md # Security model, invariants & disclosure policy
├── ARCHITECTURE.md # Detailed control-theoretic & queueing architecture
├── config/
│ └── default-policy.toml # Production-ready default policy template
└── crates/
├── qos-core/ # Domain types, policies, CIDR/port matchers, clocks, SLA models
├── qos-classifier/ # 5-stage classifier, bounded flow table & anti-spoofing guard
├── qos-scheduler/ # HTB + Strict Priority / WDRR + RFC 8289 CoDel + trTCM Policer
├── qos-controller/ # Closed-loop EWMA, hysteresis FSM & PID bottleneck controller
├── qos-dataplane/ # Wire parser, RFC 1624 DSCP/ECN rewriter, Linux tc/Windows exporters & UDP proxy
├── qos-sim/ # Multi-scenario deterministic congestion & resilience simulator
├── qos-telemetry/ # HTTP/1.1 REST API, Prometheus /metrics & embedded NOC dashboard
└── qos-cli/ # qosd (autonomous daemon) & qosctl (operator CLI) + E2E tests
- Rust
1.80+(cargo,rustc,rustfmt,clippy)
git clone https://github.com/AMISEF/Dynamic-Bandwidth-QoS-Manager.git
cd Dynamic-Bandwidth-QoS-Manager
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace# Compare Baseline FIFO vs Static HTB vs Adaptive Dynamic QoS across all 4 scenarios
cargo run --release --bin qosctl -- sim --scenario all --link-mbps 100
# Export JSON simulation telemetry for external analysis
cargo run --release --bin qosctl -- sim --scenario link_degradation --json
# Measure pure classification + HTB/CoDel scheduler throughput
cargo run --release --bin qosctl -- bench --packets 200000
# Inspect wire-format packet parsing, classification & RFC 1624 checksum integrity
cargo run --release --bin qosctl -- inspect-packet --dst-port 5060 --dscp 0 --payload-bytes 160# Start qosd with built-in demo traffic cycling normal load and congestion bursts
cargo run --release --bin qosd -- --link-mbps 50 --demo-trafficThen open your browser to http://127.0.0.1:9108 to view the real-time dashboard and run interactive simulations, or query metrics directly:
cargo run --release --bin qosctl -- status --addr 127.0.0.1:9108
curl http://127.0.0.1:9108/metrics
curl http://127.0.0.1:9108/api/v1/status# Generate and validate a TOML policy file
cargo run --bin qosctl -- policy init --output my-policy.toml --link-mbps 250
cargo run --bin qosctl -- policy validate config/default-policy.toml
# Export production Linux tc (HTB + fq_codel + u32 DSCP filters) script
cargo run --bin qosctl -- export --target linux-tc --policy config/default-policy.toml
# Export Windows PowerShell NetQosPolicy script
cargo run --bin qosctl -- export --target windows-qos --policy config/default-policy.toml| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Embedded real-time HTML5/JS NOC dashboard |
GET |
/healthz |
Service health check |
GET |
/metrics |
Prometheus OpenMetrics text exposition |
GET |
/api/v1/status |
Live link telemetry, congestion state & per-tier CIR/PIR allocations |
GET |
/api/v1/flows |
Top active and demoted flows tracked by the classifier |
GET |
/api/v1/decisions |
Audit log of autonomous controller decisions |
GET |
/api/v1/policy |
Current active QoS policy configuration |
PUT |
/api/v1/policy |
Hot-reload validated JSON policy (requires Authorization: Bearer <token> when --bearer-token / QOS_API_TOKEN is set) |
GET |
/api/v1/export/linux-tc |
Render live adapted Linux tc script |
GET |
/api/v1/export/windows-qos |
Render live adapted Windows New-NetQosPolicy script |
GET |
/api/v1/sim/run?scenario=... |
Run deterministic benchmark comparison on demand |
- Security architecture, threat model, and vulnerability reporting instructions are documented in SECURITY.md.
- Detailed mathematical and scheduling design notes are documented in ARCHITECTURE.md.
Copyright © 2026 AMISEF. All rights reserved.
Licensed under the MIT License. Designed, engineered, and maintained exclusively by AMISEF.