code wiki / _hdl_build / nx_room_fec_wire.nx
nx_room_fec_wire.nx
buildroot/runtime/_hdl_build/nx_room_fec_wire.nx
about
nx_room_fec_wire.nx -- R1: the FRAME-LEVEL FEC wire protocol that makes the measured
loss-resilience (nx_room_resilience) REAL on the relay. A media frame is sharded into
k data + m parity packets (each with a 16-byte wire header); the receiver reconstructs
the ENTIRE frame byte-exact from any k surviving shards (<=m losses). This is the
shippable bridge: the abstract block accounting in nx_room_resilience is here proven on
real frame BYTES through encode -> packetize -> lose -> recover -> byte-exact compare.
Reuses the proven RS GF(256) codec from nx_room_fec.nx (no reimpl).
WIRE HEADER (16B): [block_id u32][shard_idx u8][is_parity u8][k u8][m u8][frame_len u32][rsv u32]
The relay forwards shards opaquely (content-blind); only the endpoints encode/decode.
HONEST SCOPE: this proves the protocol + recovery. Wiring it into nx_vroom_daemon's
vd_stream + the browser client, and DEPLOYING to the live family link, is the
operator-gated follow-on (touches live family video -- coordinate, never hot-patch).
main() is the SELF-VALIDATING GATE. Evidence -> knowledge/status/room_fec_wire.log.
license_tier: ORIGINAL
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_room_fec.nx
imported by: nx_room_fec_relay.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 19 | const FW_MAGIC_12345: i64 = 12345 |
| 21 | const FW_LOG: *u8 = "knowledge/status/room_fec_wire.log" |
functions
| 23 | 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 } |
| 24 | 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 as u8;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 } |
| 27 | func fwh_pack(buf: *u8, block_id: i64, idx: i64, is_parity: i64, k: i64, m: i64, fl: i64) -> i64 called by 1: main |
| 34 | func fwh_idx(buf: *u8) -> i64 { return buf[4] as i64 } called by 1: main |
| 35 | func fwh_parity(buf: *u8) -> i64 { return buf[5] as i64 } called by 1: main |
| 36 | func fwh_fl(buf: *u8) -> i64 { var v: i64=0; var b: i64=0; while b<4 { v = v | ((buf[8+b] as i64)<<(b*8)); b=b+1 } return v } called by 1: main |
| 39 | func fwire_encode(exp: *i64, log: *i64, G: *i64, frame: *u8, fl: i64, k: i64, m: i64, S: i64, data: *i64, shards: *i64) -> i64 |
| 46 | func fwire_decode(exp: *i64, log: *i64, G: *i64, shards: *i64, present: *i64, k: i64, m: i64, S: i64, fl: i64, frame_out: *u8, erased: *i64, out: *i64) -> i64 |
| 55 | func frame_eq(a: *u8, b: *u8, fl: i64) -> i64 { var i: i64=0; while i < fl { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } |
| 58 | func fwire_exhaustive2(exp: *i64, log: *i64, G: *i64, shards: *i64, frame: *u8, k: i64, m: i64, S: i64, fl: i64, present: *i64, erased: *i64, out: *i64, fout: *u8) -> i64 |
| 76 | func main() -> i64 |