code wiki / _hdl_build / nx_room_abr.nx
nx_room_abr.nx
buildroot/runtime/_hdl_build/nx_room_abr.nx
about
nx_room_abr.nx -- X-ROOM ABR (GEN-ROOM-room-adaptive-bitrate): sovereign
DETERMINISTIC INTEGER adaptive-bitrate controller for the video room.
EXCEED axis vs Zoom/LiveKit/WebRTC heuristic+ML ABR: every layer decision is a
REPRODUCIBLE integer verdict (audit-replayable -- replay the same link trace, get
the same layers), and the anti-oscillation HYSTERESIS is a deterministic rule, not
a tuned black box. Discipline = CLIMB-SLOW / DROP-FAST (the safe-ABR invariant):
ramp up one layer only on SUSTAINED headroom, drop immediately on loss/congestion.
MODEL (all bitrates in kbps, loss in per-mille):
ladder[] = quality layers low->high, bitrate each (DATA, rule 25 -- improve rows, never strip)
state[3] = [ est_bw(EWMA), layer(index), up_count(sustained-headroom ticks) ]
per tick : measured throughput meas_bw + loss_pm
est_bw = (3*est_bw + meas_bw)/4 (integer EWMA; smooths jitter)
safe_bw = est_bw * ABR_SAFE_PCT/100 (climb only into headroom, never to the edge)
DROP (fast): loss_pm>ABR_LOSS_PM OR ladder[layer]>est_bw -> layer-1, up_count=0
UP (slow) : highest layer that fits safe_bw is above current -> up_count++,
step up ONE layer only when up_count>=hyst_up (use_hyst=0 disables = the control)
main() is the SELF-VALIDATING GATE: A climb-to-top, B collapse-drops-fast,
C oscillation flaps LESS with hysteresis than without (the anti-oscillation exceed),
tamper a ladder rung -> outcome diverges. Evidence -> knowledge/status/room_abr.log.
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 25 | const ABR_MAGIC_1500: i64 = 1500 |
| 26 | const ABR_MAGIC_3000: i64 = 3000 |
| 27 | const ABR_MAGIC_4000: i64 = 4000 |
| 28 | const ABR_MAGIC_999999: i64 = 999999 |
| 30 | const ABR_LOG: *u8 = "knowledge/status/room_abr.log" |
| 31 | const ABR_SAFE_PCT: i64 = 85 // climb only into 85% of the estimate (headroom) |
| 32 | const ABR_LOSS_PM: i64 = 50 // > 5% loss = congestion -> drop now |
functions
| 34 | func aw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 35 | func awn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 } |
| 38 | func abr_top_layer(ladder: *i64, n: i64, cap: i64) -> i64 called by 1: abr_step |
| 46 | func abr_step(ladder: *i64, n: i64, state: *i64, meas_bw: i64, loss_pm: i64, hyst_up: i64, use_hyst: i64) -> i64 |
| 80 | func abr_run(ladder: *i64, n: i64, T: i64, meas: *i64, loss: *i64, hyst_up: i64, use_hyst: i64, init_layer: i64, init_bw: i64, out: *i64) -> i64 |
| 96 | func main() -> i64 |