nx_fec_stripe.nx source
↩ module page · 34 lines · 1653 B
1// nx_fec_stripe.nx -- FEC-COMPLEMENTARY striping: the exceed beyond plain
2// multi-path duplication. Combines nx_fec_xor (parity repair) with
3// nx_pathstripe (multi-path): source packets travel on one path, FEC
4// REPAIR symbols on a complementary path. A source packet lost on its
5// path -- with NO duplicate anywhere -- is reconstructed by the parity on
6// a surviving path. This recovers CORRELATED / all-path loss (which plain
7// seq-dedup striping cannot: it needs the packet to survive on >=1 path)
8// AND does so at SUB-100% bandwidth overhead (repairs/source < 1), vs the
9// 100% overhead of 1+1 duplication. Pure-XOR -> integer-only, sovereign.
10//
11// license_tier: ORIGINAL
12
13import "nx_fec_xor.nx"
14
15// Complementary 2-path plan: source packets (idx < K) on path 0, all FEC
16// repair packets (idx >= K) on path 1. A failure of either path loses
17// source XOR repair -- never both halves needed for a given recovery.
18func fec_stripe_path_of(idx: i64, k: i64) -> i64 {
19 if idx < k { return 0 }
20 return 1
21}
22
23// Reconstruct the source block from whatever source + repair packets
24// survived across all paths (present flags). Returns # source still
25// missing (0 = full recovery). Reuses the proven 2-D peeling decoder.
26func fec_stripe_recover(src: *u8, L: i64, D: i64, S: i64, present_src: *i64,
27 rows: *u8, rp: *i64, cols: *u8, cp: *i64) -> i64 {
28 return fec_decode_2d(src, L, D, S, present_src, rows, rp, cols, cp)
29}
30
31// Bandwidth overhead %% of the FEC stripe vs 1+1 duplication's fixed 100%.
32func fec_stripe_overhead_pct(scheme: i64, L: i64, D: i64) -> i64 {
33 return fec_overhead_pct(scheme, L, D)
34}