Nils Andreas Svee 8e4a1a24f6 refactor(control): introduce runtime and SQMA law modules
Separate traffic sampling and shaper access from measurement processing and rate decisions through Runtime, LawContext, and SqmaLaw. Add the async Law interface and its dependency; the worker migration activates these modules in the following commit.
2026-10-31 00:06:53 +07:00
2022-10-13 17:28:10 +02:00
2026-09-26 00:01:03 +07:00
2026-04-23 12:19:49 +07:00

Summary

sqm‑autorate‑rust is a Rust re‑implementation of the original sqm‑autorate tool, which dynamically adjusts CAKE SQM bandwidth settings by measuring traffic load and latency – ideal for variable DOCIS/cable or LTE/wireless links where capacity fluctuates. This port preserves the original’s adaptive control logic while leveraging Rust’s type safety, performance, and concurrency primitives to deliver a more robust, maintainable codebase.

Features

  • Adaptive rate control: continuously measures one‑way delay baselines and traffic load to tune both download and upload shaping rates in real­time .
  • Multiple measurement types: prefers ICMP timestamps by default, but also supports ICMP echo requests as a fallback for networks where timestamps are blocked
  • Concurrent architecture: separates packet sending, receiving, baselining, reflector reselection and rate‑controller loops into dedicated threads for maximum responsiveness .
  • Configurable via environment or UCI: reads settings from environment variables or OpenWRT UCI, with sensible defaults and type‑safe parsing .
  • Minimal dependencies: relies on Rust crates only (anyhow, socket2, neli, rustix), no external scripts .

Installation

You can install sqm‑autorate‑rust in two ways:

1. Native Rust build

  1. Ensure you have the Rust toolchain (1.70+), Cargo, and libnl headers installed on your Linux host.

  2. Clone and build:

    git clone https://github.com/Lochnair/sqm-autorate-rust.git
    cd sqm-autorate-rust
    cargo build --release
    
  3. The optimized binary is at target/release/sqm-autorate-rust.

2. OpenWrt SDK build

You can also build an OpenWrt package to install in your images with the SDK:

  1. Prepare the OpenWrt SDK

    # Download and extract the matching SDK for your target platform
    tar xJf openwrt-sdk-*.tar.xz
    cd openwrt-sdk-*
    
  2. Add the openwrt-feeds repository

    # Add the feed to feeds.conf.default
    echo 'src-link lochnair https://github.com/Lochnair/openwrt-feeds.git' >> feeds.conf.default
    ./scripts/feeds update lochnair
    ./scripts/feeds install sqm-autorate-rust
    
  3. Configure and build the package

    make menuconfig        # navigate to Network → sqm-autorate-rust, enable it
    make package/sqm-autorate-rust/{clean,compile} V=s
    
  4. Install on your device

    # Copy the generated .ipk from bin/packages/... to your router
    opkg install sqm-autorate-rust_*.ipk
    

Reflector files and inline UCI reflectors

Inline config reflector sections supplement the default /etc/sqm-autorate-rust/reflectors.csv. To use only inline reflectors, explicitly disable file loading:

config reflectors
    option files 'none'

config reflector
    option host 'global.irtt.lochnair.net'
    list protocols 'irtt'

Use list files '/path/to/reflectors.csv' instead of option files 'none' to combine CSV files with inline reflectors. Omitting files keeps the default CSV; UCI discards empty string options, so option files '' does not disable it. Absent or blank irtt_hmac values use unauthenticated IRTT sessions.

Languages
Rust 99.8%
Shell 0.2%