code wiki / (root) / nx_bwe.nx

nx_bwe.nx

buildroot/runtime/nx_bwe.nx

3384 B73 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_bwe.nx -- SOVEREIGN bandwidth estimator (the "adapt to the pipe" rung). BENCHMARK: WebRTC's GCC (Google Congestion Control) = a delay-based signal (queuing delay TREND: is one-way delay rising = a queue building ahead of us?) + a loss-based signal, combined into an AIMD controller (additive increase when the path is clear, multiplicative decrease the instant congestion appears). Rebuilt from scratch, pure integer, no third party, transport-agnostic. Output = an available-bitrate estimate that feeds nx_media_budget's uplink input, so the ladder rides the REAL pipe instead of a static guess. bwe_on_arrival(send_ts, arr_ts) : per-packet inter-arrival delay variation -> EWMA trend bwe_report_loss(lost, total) : windowed loss -> EWMA loss rate bwe_update() : one AIMD step -> new estimate (call ~1x/RTT) license_tier: ORIGINAL

dependencies 0 imports · 1 importers

nx_bwe.nx nx_bwe_gate.nx

imports: none

imported by: nx_bwe_gate.nx

structs

none

consts

12const BW_EST: i64 = 0
13const BW_LOSS: i64 = 1 // EWMA loss, permille
14const BW_TREND: i64 = 2 // EWMA inter-arrival delay variation (rising = queue building)
15const BW_PSEND: i64 = 3
16const BW_PARR: i64 = 4
17const BW_HAVE: i64 = 5
18const BW_MIN: i64 = 6
19const BW_MAX: i64 = 7
20const BW_INC: i64 = 8
22const BW_TREND_THRESH: i64 = 50 // delay-variation units above which a queue is deemed building
23const BW_LOSS_HI: i64 = 100 // 10% -> congested
24const BW_LOSS_LO: i64 = 20 // 2% -> safe to probe up
25const BW_DEC_NUM: i64 = 85 // multiplicative decrease = x0.85 (fast back-off, GCC-style)
26const BW_DEC_DEN: i64 = 100

functions

28func bwe_init(bw: *i64, min_kbps: i64, max_kbps: i64, start_kbps: i64, inc_kbps: i64) -> i64
called by 1: run
40func bwe_on_arrival(bw: *i64, send_ts: i64, arr_ts: i64) -> i64
called by 1: run
50func bwe_report_loss(bw: *i64, lost: i64, total: i64) -> i64
called by 1: run
57func bwe_update(bw: *i64) -> i64
called by 1: run
71func bwe_estimate(bw: *i64) -> i64 { return bw[BW_EST] }
called by 1: run
73func main() -> i64 { return 0 }