Skip to content

Conversation

@amirhmoradi
Copy link

This commit implements CAKE (Common Applications Kept Enhanced) traffic shaping for Wiregate, addressing upstream issue #77.

CAKE is a modern Linux kernel qdisc that provides superior bufferbloat control, fair queuing, and automatic bandwidth management compared to traditional traffic shapers.

Key Features:

  • Reduced latency under load (< 20ms vs 500ms+ without shaping)
  • Fair bandwidth distribution across VPN clients
  • NAT-aware per-host and per-flow fair queuing
  • Built-in ACK filtering for asymmetric connections
  • Automatic rate adaptation
  • Minimal configuration required

Implementation Details:

  1. Docker Infrastructure (WG-Dash/Dockerfile):

    • Added iproute2 package for tc command support
  2. Python Layer (WG-Dash/src/traffic_control.py):

    • New TrafficControl module with CAKEQdisc class
    • Functions for applying/removing CAKE qdisc
    • Validation and error handling
    • Statistics collection
    • Support for all CAKE parameters (bandwidth, overhead, mpu, options)
  3. Shell Scripts (WG-Dash/src/iptable-rules/*/):

    • cake-setup.sh: Apply CAKE to WireGuard interface (all zones)
    • cake-teardown.sh: Remove CAKE from interface (all zones)
    • Integrated with existing postup.sh and postdown.sh scripts
    • Environment variable-based configuration
    • Graceful fallback if CAKE unavailable
  4. Per-Zone Configuration:

    • ADMINS: 1 Gbit/s (full-speed admin access)
    • MEMBERS: 100 Mbit/s (standard users)
    • GUESTS: 50 Mbit/s (limited guest access)
    • LANP2P: 100 Mbit/s (LAN-only connections)
  5. Configuration (via environment variables):

    • CAKE_ENABLED: Global enable/disable toggle (default: false)
    • CAKE_BANDWIDTH_*: Per-zone bandwidth limits
    • CAKE_OVERHEAD: Overhead compensation for encapsulation
    • CAKE_MPU: Minimum packet unit
    • CAKE_MEMLIMIT: Memory limit for queues
    • CAKE_OPTIONS: Space-separated CAKE options
  6. Documentation:

    • docs/CAKE_TRAFFIC_SHAPING.md: Comprehensive guide
    • examples/cake-config.env.example: Example configurations
    • README.md: Quick start guide and feature overview
    • Docs/CHANGELOG.md: Version history entry

Design Principles:

  • Optional feature, disabled by default
  • Zero impact on existing functionality when disabled
  • Clean integration with existing network scripts
  • Environment variable driven configuration
  • Comprehensive documentation and examples

Testing Recommendations:

  1. Verify CAKE availability: tc qdisc add dev lo root cake help
  2. Check interface setup: tc qdisc show dev MEMBERS
  3. Monitor statistics: tc -s qdisc show dev MEMBERS
  4. Test latency under load: ping + large download

Addresses: #77

NOXCIS and others added 26 commits March 3, 2025 03:30
-no one ever reads the commit notes
Added details about unsafe inline CSS and public keys to the Traffic Shaping bug fixes entry.
Added details for sol-beta-v2.5.3 release including theme updates, logo update, UI bug fixes, and Tor Protocol Badge.
Added warning for beta version and updated theme, logo, and UI.
Added details for flat-bridge-v0.0.1 release including Dockerfile updates, security enhancements, and frontend improvements.
Added release notes for versions v0.0.2, v0.0.3, and v1.5.0.
This commit implements CAKE (Common Applications Kept Enhanced) traffic
shaping for Wiregate, addressing upstream issue NOXCIS#77.

CAKE is a modern Linux kernel qdisc that provides superior bufferbloat
control, fair queuing, and automatic bandwidth management compared to
traditional traffic shapers.

Key Features:
- Reduced latency under load (< 20ms vs 500ms+ without shaping)
- Fair bandwidth distribution across VPN clients
- NAT-aware per-host and per-flow fair queuing
- Built-in ACK filtering for asymmetric connections
- Automatic rate adaptation
- Minimal configuration required

Implementation Details:

1. Docker Infrastructure (WG-Dash/Dockerfile):
   - Added iproute2 package for tc command support

2. Python Layer (WG-Dash/src/traffic_control.py):
   - New TrafficControl module with CAKEQdisc class
   - Functions for applying/removing CAKE qdisc
   - Validation and error handling
   - Statistics collection
   - Support for all CAKE parameters (bandwidth, overhead, mpu, options)

3. Shell Scripts (WG-Dash/src/iptable-rules/*/):
   - cake-setup.sh: Apply CAKE to WireGuard interface (all zones)
   - cake-teardown.sh: Remove CAKE from interface (all zones)
   - Integrated with existing postup.sh and postdown.sh scripts
   - Environment variable-based configuration
   - Graceful fallback if CAKE unavailable

4. Per-Zone Configuration:
   - ADMINS: 1 Gbit/s (full-speed admin access)
   - MEMBERS: 100 Mbit/s (standard users)
   - GUESTS: 50 Mbit/s (limited guest access)
   - LANP2P: 100 Mbit/s (LAN-only connections)

5. Configuration (via environment variables):
   - CAKE_ENABLED: Global enable/disable toggle (default: false)
   - CAKE_BANDWIDTH_*: Per-zone bandwidth limits
   - CAKE_OVERHEAD: Overhead compensation for encapsulation
   - CAKE_MPU: Minimum packet unit
   - CAKE_MEMLIMIT: Memory limit for queues
   - CAKE_OPTIONS: Space-separated CAKE options

6. Documentation:
   - docs/CAKE_TRAFFIC_SHAPING.md: Comprehensive guide
   - examples/cake-config.env.example: Example configurations
   - README.md: Quick start guide and feature overview
   - Docs/CHANGELOG.md: Version history entry

Design Principles:
- Optional feature, disabled by default
- Zero impact on existing functionality when disabled
- Clean integration with existing network scripts
- Environment variable driven configuration
- Comprehensive documentation and examples

Testing Recommendations:
1. Verify CAKE availability: tc qdisc add dev lo root cake help
2. Check interface setup: tc qdisc show dev MEMBERS
3. Monitor statistics: tc -s qdisc show dev MEMBERS
4. Test latency under load: ping + large download

Addresses: NOXCIS#77
@NOXCIS NOXCIS changed the base branch from main to bug-hunting November 7, 2025 00:11
@amirhmoradi
Copy link
Author

closing in favor of the new PR ( #99 ) which is correctly based on bug-hunting branch.

@amirhmoradi amirhmoradi deleted the claude/issue-77-cake-traffic-shaping-011CUojiMSEFd7Dk6nbaCrhn branch November 11, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants