code wiki / _hdl_build / nx_room_fec.nx
nx_room_fec.nx
buildroot/runtime/_hdl_build/nx_room_fec.nx
about
nx_room_fec.nx -- X-ROOM (overseas-grade): sovereign DETERMINISTIC Reed-Solomon
systematic ERASURE CODE over GF(256) -- Forward Error Correction for high-RTT,
lossy intercontinental video calls.
WHY (the overseas-call performance axis): at ~250ms intercontinental RTT a
retransmit (ARQ) costs a full round-trip = an audible/visible STALL. FEC recovers
lost packets from PARITY already in flight -> ZERO added latency, NO retransmit.
k data shards + m parity shards (n=k+m). ANY m losses out of n reconstruct exactly.
EXCEED axis (honest) vs Zoom/Teams/WebRTC FlexFEC: a PROVABLE MDS guarantee --
deterministic, integer-exact, audit-replayable recovery of EVERY <=m erasure
pattern (the gate proves all C(n,m) of them), sovereign (own GF(256), no library).
HONEST SCOPE: ERASURE coding (lost-packet positions known from RTP seq numbers) --
not error correction of silently-corrupted survivors; rate-adaptive FEC = deeper rung.
CONSTRUCTION: generator G (n x k) = [ I_k ; Cauchy ]. Cauchy[j][i] = 1/((k+j) ^ i)
in GF(256) -> every k x k submatrix invertible (MDS). Decode = pick any k surviving
rows, solve the k x k GF system by Gauss-Jordan -> the original data shards.
main() is the SELF-VALIDATING GATE. Evidence -> knowledge/status/room_fec.log.
license_tier: ORIGINAL
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_fabric_fec.nxnx_room_fec_wire.nxnx_room_resilience.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 24 | const FEC_LOG: *u8 = "knowledge/status/room_fec.log" |
| 25 | const GF_POLY: i64 = 0x11d // primitive polynomial x^8+x^4+x^3+x^2+1 |
functions
| 27 | func fw(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 } |
| 28 | func fwn(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 } |
| 31 | func gf_init(exp: *i64, log: *i64) -> i64 |
| 46 | func gf_mul(exp: *i64, log: *i64, a: i64, b: i64) -> i64 |
| 51 | func gf_inv(exp: *i64, log: *i64, a: i64) -> i64 |
| 56 | func fec_build_G(exp: *i64, log: *i64, G: *i64, k: i64, m: i64) -> i64 |
| 77 | func fec_encode(exp: *i64, log: *i64, G: *i64, data: *i64, shards: *i64, k: i64, m: i64, S: i64) -> i64 |
| 96 | func gf_solve(exp: *i64, log: *i64, A: *i64, B: *i64, k: i64, S: i64) -> i64 |
| 134 | func fec_decode(exp: *i64, log: *i64, G: *i64, shards: *i64, erased: *i64, out: *i64, k: i64, m: i64, S: i64) -> i64 |
| 154 | func fec_data_eq(out: *i64, data: *i64, k: i64, S: i64) -> i64 |
| 165 | func fec_exhaustive3(exp: *i64, log: *i64, G: *i64, shards: *i64, data: *i64, erased: *i64, out: *i64, k: i64, m: i64, S: i64) -> i64 |
| 188 | func main() -> i64 |