Skip to content

Latest commit

 

History

History
112 lines (89 loc) · 5.53 KB

coding.md

File metadata and controls

112 lines (89 loc) · 5.53 KB

Coding model

Meld uses systematic linear erasure coding over GF(2⁸). It recovers missing data; it does not correct unknown bit errors. In encrypted sessions, source AEAD is checked after coding, so a polluted equation may enter decoder state before its invalid result is rejected. The standalone specification defines the exact arithmetic, joint solve, retirement rules, and security scope.

Algebraic source

Each application chunk becomes a fixed-width coded value containing a SymbolSize application region followed by its uint32 exact length and int64 deadline. The application region is zero-padded only inside the coding layer. With identical source vectors at both ends, this representation recovers the original byte length and deadline. The reference flow clamps received deadlines before constructing systematic/unit vectors; when that changes a stamp, those vectors differ from the sender's repair inputs and recovered metadata can differ. The specification describes the clamp, a numerical example, and delivery checks.

Systematic packets send exact source bytes. Dense and sparse equations may use a compact wire representation that removes a guaranteed-zero application suffix while retaining the coded metadata. Expansion happens before GF arithmetic and must reproduce the full equation byte-for-byte.

Coefficients

A repair packet carries its source set and a 16-bit RepairKey; it does not carry an explicit coefficient vector. Encoder and decoder call the same deterministic coefficient generator.

  • Keys with both high bits set select bounded Cauchy-MDS rows only when 1 <= N <= 254 and (RepairKey & 0x3fff) + N < 255. Other count/row combinations fall back to seeded RLNC and have no MDS guarantee.
  • Other keys select deterministic seeded RLNC coefficients and are guaranteed not to produce an all-zero vector.

The same (source set, RepairKey) pair must always regenerate the same vector.

Sliding RLNC

The default single-path flow emits repair over an elastic trailing band. Adjacent equations may cover different, overlapping source sets. The band decoder uses incremental reduced-row elimination and releases a source as soon as it is solved and preceding sources are resolved. The solver handles multiple unknowns jointly; it is not limited to peeling degree-one input equations. Input width is at most CodingWindow, stored span is at most twice that, and equations that exceed the stored span are discarded whole. This bounds local work while forgoing some recovery available to an unconstrained solver.

Moving-window equations remain fungible across unresolved sources in their span. Feedback supplies rank deficits and loss observations, but proactive work does not wait for feedback.

Bounded MDS blocks

Generation flows and automatic 16-source epochs use systematic Cauchy blocks. For one stable source set, any block-width collection of systematic and distinct admissible parity rows is full rank.

Generation mode partitions the stream into bounded groups and is currently used by the multipath host. Epoch repair is an actuator inside the sliding flow: all sources announce one stable 16-source range, epoch rows enter a separate decoder, and recovered values are exchanged with the ordinary sliding decoder. Block state is bounded and retired when the ordered cursor passes the block.

Sparse and exact repair

Sparse repair lists up to 64 source ids explicitly and derives coefficients in that order. It protects selected dependency neighborhoods without coupling every intervening source into the equation. The sliding receiver processes it; the generation receiver currently does not add sparse packets to its decoder.

Unit repair carries the exact bytes for one retained source. It is admitted and paced as repair but inserted into the decoder as a known systematic value. The sliding sender uses WindowBase=SrcIndex, N=1. In generation mode, a unit must name the existing generation base and width to help that generation; separate generation decoders do not share known values. The sender limits it to covered unresolved ids, the reported rank deficit, retained history, available byte headroom, and deadlines. For clustered loss, a deadline-aware crossover sends the named value at its final useful dispatch when measured repair headroom can fund it; isolated holes retain one persistence interval for already-in-flight coding to close.

Decoder contract

An equation is admitted only when its declared geometry and payload shape are valid. Independent rows add information, but the bounded band decoder can discard rows to enforce its span cap, so retained rank need not increase on every such arrival. A decoder emits a source only when the linear system determines that source exactly; it never guesses or emits unsupported rank.

The implementation is tested for:

  • exact coefficient agreement;
  • full-rank bounded Cauchy blocks;
  • correct compact-equation expansion;
  • exact recovered lengths and deadlines when the coding vectors agree;
  • no duplicate or out-of-order delivery;
  • delivery checks against the reference receiver's effective deadlines;
  • bounded state under malformed geometry; and
  • scalar/SIMD byte equality for GF multiply-add.

Implementation map

  • internal/gf: GF(2⁸) arithmetic and architecture-specific multiply-add.
  • internal/code/code.go: coefficient generation and bounded block encoder/ decoder.
  • internal/code/band.go: incremental sliding-band decoder.
  • internal/flow/coded_symbol.go: coded metadata and compact serialization.
  • internal/flow: deadline-aware recovery policy and wire admission.