Skip to main content

Reassembly

When packets arrive out of order or messages span multiple packets, the receiver must buffer, reorder, and reassemble them. SRSPP provides three receiver backends that trade off memory usage, insertion speed, and delivery cost.

Comparison

FastLitePacked
Out-of-order insertO(1)O(WIN)O(1)
DeliveryO(1) advanceO(REASM) shiftO(MSG) copy
Per-segment storageMTU (fixed)MTU (fixed)Actual payload size
Static memoryWIN × MTU + REASMREASMBUF + REASM
Best forHigh throughputMemory-constrainedVariable-size payloads

Fast

Every window slot reserves the full MTU size, regardless of how large the actual payload is. Insertion is O(1) — compute the slot index as seq % WIN and write. Delivery is O(1) per packet — walk consecutive occupied slots and copy to the reassembly buffer.

The tradeoff: wastes memory when payloads are smaller than the MTU.

Fast backend memory layout
Slot array (WIN × MTU bytes) — one fixed-size slot per window position:
seq 3
(empty)
seq 5
(empty)
seq 7
(empty)
(empty)
(empty)
Each slot is MTU bytes wide. Occupied slots (blue) contain payload data. Empty slots waste space.
Occupancy bitset (1 bit per slot):
1
0
1
0
1
0
0
0
Reassembly buffer (REASM bytes):
completed message data
(free)

Lite

Uses a single shared buffer for both reordering and reassembly. Segments are placed at computed byte offsets. A gap tracker records which byte ranges are filled and which are still missing.

The tradeoff: delivery requires shifting the entire buffer left when a message is consumed — O(REASM) bytes moved. But memory usage is minimal: only the REASM buffer plus gap metadata.

Lite backend memory layout
Single buffer (REASM bytes) — segments placed at computed offsets:
seg 0
gap
seg 2
gap
seg 4
(free)
Gap tracker — intervals of missing byte ranges:
[50..100]
[150..200]
When gaps are filled, the tracker merges intervals. When a message is consumed, the buffer shifts left.

Packed

Like Fast, uses a bitset and slot indices for O(1) insertion. But instead of reserving MTU bytes per slot, payloads are appended to a bump allocator (append-only slab). Each slot stores only a metadata record (offset + length into the slab).

The tradeoff: no wasted space per slot (payloads packed tightly), but delivery requires copying from the slab to the reassembly buffer — O(message size).

Packed backend memory layout
Slot metadata (WIN entries) — offset and length into the slab:
0:120
120:85
205:200
Bump slab (BUF bytes) — payloads packed contiguously:
payload 3 (120B)
payload 5 (85B)
payload 7 (200B)
(free)
Payloads use only their actual size — no MTU padding. Slab is cleared after delivery.
Reassembly buffer (REASM bytes):
completed message data
(free)

Choosing a Backend

  • Fast — use when throughput matters most and memory is available. Typical for ground stations or satellites with sufficient RAM.
  • Lite — use on the most memory-constrained satellites where every byte counts. Accepts slower delivery in exchange for the smallest possible footprint.
  • Packed — use when payload sizes vary significantly (some packets carry 50 bytes, others carry 500). Avoids the wasted space of Fast without the delivery cost of Lite.

All three backends produce identical output — the choice is purely a resource tradeoff. The application does not need to know which backend the receiver uses.