# Layered XOR: packet count is not recoverability

This is an original, deterministic Hesela illustration, not a Maelstrom
implementation, packet trace, latency benchmark or empirical durability result.

## Reproduce

Python 3.10+ and its standard library suffice. Keep the four files together.
Download the [model](model.py), [tests](test_model.py), [exact JSON results](results.json)
and this [README](README.md). Source locators and retrieval hashes are recorded in
[the research provenance](sources.json).

```sh
python3 -B model.py --check
python3 -B -m unittest -v test_model.py
python3 -B -O -m unittest -v test_model.py
```

Running model.py without --check regenerates results.json. No randomness,
network access or third-party package is used.

## Exact model and result

Forty data packets numbered 0 through 39 contain one-byte payloads
(73*i + 19) modulo 256. Every layer places a packet in bin i modulo
its interleave. A bin emits its five-packet XOR and clears when full.
The payload-generation formula is test-fixture knowledge, not decoder side
information; the decoder receives known packets and surviving repair equations.
The three interleaves are 1, 4 and 8; all 24 generated repairs arrive
unless the case explicitly removes them. Known missing positions are erasures;
payload corruption and false packet identities are outside the model.
The decoder repeatedly solves equations containing exactly one unknown.

| Missing data packets | Received repairs | Rank on unknowns | Unresolved |
| --- | ---: | ---: | --- |
| 0, 1, 2, 3 | 24 | 4 | none |
| 0, 1, 8, 9 | 24 | 3 | 0, 1, 8, 9 |

In the second case, changing the low bit of all four missing payloads preserves
every received XOR. The tests construct both assignments explicitly. No decoder
can uniquely select the original payloads from this evidence alone.
The first case recovers every byte. Equal numbers of lost data and received
repairs therefore do not imply equal recoverability.

Rank and peeling are reported separately: a different, full-rank equation set
can still stall this singleton decoder. The tests include that control, all 820
single/pair erasure patterns in the complete 40-packet window, reversed repair
order, missing repairs and invalid parameters.

A four-data-packet stream emits zero repairs because no bin fills. This finite
tail does not receive three useful repairs merely because three layers exist.
There is no partial-bin flush or future traffic in that case.

## Accounting and time boundary

The complete 40-packet example emits 24 repairs. With equal payload lengths,
repair/data is 3/5 and data/total is 5/8. For a separate r=8,c=3 accounting
example, these ratios are 3/8 (37.5%) and 8/11 (about 72.73%).
Neither is measured wire goodput: headers, recipe lists, fragmentation, ACKs
and retransmissions are excluded.

First emission in each layer occurs after packet indices 4, 16 and 32.
With the first arrival at time zero and uniform spacing of one millisecond,
the corresponding generation times are 4, 16 and 32 ms. Tenfold aggregate
arrival rate divides those generation times by ten. These are constructed
arrival schedules, not propagation, delivery or persistence times.

## Source boundary

The binning rule and illustrative r=5, I=(1,4,8) parameters follow section 4.3
and Figure 6 of [Balakrishnan et al., NSDI 2008](https://www.usenix.org/legacy/event/nsdi08/tech/full_papers/balakrishnan/balakrishnan_html/).
We omit staggered initialization, repair delay, cache eviction, scheduling and
TCP retransmission. Consequently this is not a reproduction of the optimized
prototype or its benchmark configuration, nor a new attack on Maelstrom.

The public glossary connects this toy result to
[Maelstrom](https://hesela.dev/terms/maelstrom/).
All numeric inputs are constructed; no observational population, confidence
interval, fleet extrapolation or probability of disaster survival is asserted.
The model and tests are original Hesela code; no upstream implementation,
paper figure or experiment dataset is redistributed.
