3. Part 2: adversarial resilience
This chapter measures failure behavior and recovery under malformed OTA frames, resource exhaustion, hostile UART framing, broadcast storms, and mid-write power loss on an SMLIGHT SLZB-06P7 (CC2652P7 / CC1352P7 @ 48 MHz) over a 115,200 baud 8N1 UART, with an out-of-band SWD probe sampling allocator watermarks, cycle counters, and fault status registers.
Part 2 summary
Section titled “Part 2 summary”| Adversarial stress / fault vector | Stock TI Z-Stack | SMLIGHT ZeroStack (v1.0.0) | Resilience advantage |
|---|---|---|---|
| Malformed secured OTA NWK/APS frames (12 fault classes + 3,255 MAC vectors) | Remote CPU frame-processing fault within ~3.0 ms. Accepts malformed routing headers (144,127 cyc). | 0 crashes across all 12 classes and 3,255 MAC vectors. Rejected before crypto in 320–6,631 cyc (6.7–138 µs), 790 cyc on a bad route header. | Remote reset eliminated (up to 402× lower CPU) |
| 1,000-frame cryptographic replay flood (D=150) | 143,802 cyc (3.0 ms) per replay, 2.99 s total CPU lockup | 1,550 cyc (32 µs) per replay, 32.4 ms total CPU | 92.8× faster replay rejection |
| Authenticated header / ciphertext / MIC tamper (D=150) | 143,058 – 143,065 cyc (2.98 ms) per frame | 4,760 – 4,771 cyc (99 µs) per frame | 30.0× lower CPU cost |
NOR flash brownout fuzzing (22,959 hardware power cuts + 2M shadow ops) |
1 NOR write-verify conflict. Torn record triggers 62-page erase recovery (20,232 B written). | 0 lost or corrupted records, 0 NOR conflicts. Torn record recovers in 27 B written (0 page erases). | 749× lower post-brownout flash I/O |
| Hostile UART framing abuse (6 scenarios) | 8.84 s blackout (44 consecutive lost pings) on 300 × SOF or random noise. 1 lost ping (203 ms) on a truncated frame. |
0 lost pings across all 6 scenarios (3–55 ms recovery, Δheap 0 B) | Zero serial blackouts (0 against 44) |
| 50-device unauthenticated join / TCLK-miss flood (D=300) | 33.9 ms per miss, 1.70 s total control-plane stall | 4 µs (208 cyc) on-CPU, 0.22 s total wire time | 7.7× faster join-flood recovery |
| 50-router broadcast echo storm (1,000 echoes, D=150) | 143,865 cyc (3.00 ms) per echo, 3.00 s total CPU | 7,076 cyc (147 µs p50) per echo, 151.16 ms total CPU | 19.9× lower total CPU (20.3× faster per echo) |
| 64-frame post-outage broadcast flood (BTT saturation) | Admits 30 / 64 frames. Overflow drop costs 3.01 ms. 200.25 ms total CPU. | Expanded broadcast table (+33% BTT). Overflow drop in 174 µs (8,341 cyc). 18.87 ms total CPU. | 10.6× lower flood CPU and +33% broadcast capacity |
| Heap (0 B free) and timer exhaustion | Uncapped timer walk (255 timers). Variable-block fragmentation. | Bounded timer cap, 5 / 5 ping survival at 0 B heap, and 100% heap recovery (Δheap 0 B). | Deterministic survival under full resource exhaustion |
The four resilience oracles
Section titled “The four resilience oracles”Avoiding a CPU exception is not sufficient for unattended coordinator operation. After each injected fault or burst, the harness verifies four post-fault invariants:
- Control-plane liveness and reset. The device answers synchronous host keepalive pings, and no CPU fault (HardFault or BusFault) or unsolicited reset indication occurs during or after injection.
- Zero-leak memory (SWD). Once the stimulus is drained or released, total free heap returns to the exact pre-fault byte baseline (Δheap = 0 B).
- State immutability. Replay counters (NWK and APS frame counters), NIB attributes, non-volatile flash records, active timer tables and the 300-entry TCLK table are bit-for-bit unchanged by any rejected frame or failed allocation.
- Forward progress. The next valid operation (an encrypted frame with
FC = FC_stored + 1, a valid NV write, or a host command) succeeds on the first attempt.
1. NVRAM compaction and flash wear
Section titled “1. NVRAM compaction and flash wear”Stock Z-Stack appends a new flash record even when a 100 B state record is byte-for-byte identical (100,714 cycles, 2.10 ms per write). The log fills, and a blocking flash page compaction runs on write #69, with interrupts masked and the main loop stalled. While it runs the NPI serial task cannot answer, which is one route to SRSP - SYS - ping after 6000ms.
ZeroStack deduplicates unchanged writes. An idempotent write takes 3,770 cycles (78.5 µs) and writes 0 B to flash on 48 / 48 repeats. First compaction arrives at write #1,013, a 14.7× lower rate.
2. Power-cut and brownout recovery
Section titled “2. Power-cut and brownout recovery”Brownout testing used a deterministic NOR flash simulator matching a production 128 KB (64 × 2 KB page) geometry, with physical bit-AND semantics. Erased pages are 0xFF, and programming executes flash[addr] &= data. Any attempt to flip a 0 bit back to 1 without an erase fails read-back verification and counts as a NOR write conflict.
A brownout interposer replays each composite operation K times, severing power after primitive 1, 2, … K, cold-booting the storage driver and checking every logical record. A lost record, stale value, checksum error, torn payload, resurrected tombstone or boot error counts as Bad.
| Brownout scan / scenario | Stock TI Z-Stack | SMLIGHT ZeroStack | Outcome |
|---|---|---|---|
| Mid-compaction power cut (64 variable records, 32 updated, 1 deleted) | 20,511 cuts: 0 lost, 1 NOR write-verify conflict | 22,565 cuts: 0 lost, 0 NOR conflicts, 0 boot errors | Power-fail-safe compaction across all 22,565 cuts |
| Torn tail, large record (380 byte-level cuts) | 380 cuts: 0 torn payloads | 380 cuts: 0 torn payloads | Every cut resolves to the intact prior record or the complete new one |
| Torn tail, small record (14 cuts) | 14 cuts: 0 torn | 14 cuts: 0 torn | Deterministic with no torn state |
| Boot after mid-compaction cut (flash bytes written / erases) | 19,377 B mean (22,458 B max), 62–64 erases | 19,405 B mean (20,529 B max), 56–63 erases | Clean single-pass ring recovery |
| Boot after torn record tail (flash bytes written / erases) | 20,232 B mean (20,447 B max), 62–63 page erases | 27 B mean (27 B max), 0 page erases | 749× lower post-brownout boot flash write volume |
Totals for ZeroStack: 22,565 mid-compaction cuts plus 394 record-update cuts make 22,959 hardware cut points, alongside 2,000,000 randomised shadow-fuzz operations, with 0 lost, stale or corrupted records.
When power fails during a routine record update outside compaction, stock Z-Stack falls back to a full-volume compaction on the next boot, writing 20,232 B and erasing 62 pages before NPITask services the serial port. Repeated brownouts compound flash wear and startup delay. ZeroStack recovers in O(1) flash I/O (27 B, 0 erases).
3. Hostile UART framing
Section titled “3. Hostile UART framing”Coordinator UART links encounter baud transients on host reboot, OS serial probes, mid-frame container restarts, and line noise. A wedged receiver causes the host to time out and restart the adapter.
Protocol: 115,200 baud, 5 seeded repetitions per scenario. The harness sends a hostile byte sequence into UART RX and immediately polls with back-to-back synchronous PING commands (200 ms timeout, up to 100 attempts) until a valid response arrives, then checks free heap over SWD.
| Adversarial UART input | Stock: pings lost | Stock: recovery | ZeroStack: pings lost | ZeroStack: recovery | SWD heap Δ |
|---|---|---|---|---|---|
512 B random noise (excluding SOF) |
0 | 48 ms | 0 | 47 ms | 0 B |
10 × PING with corrupted FCS |
0 | 6 ms | 0 | 9 ms | 0 B |
| Max-length header + 256 B garbage body | 0 | 25 ms | 0 | 25 ms | 0 B |
| Truncated frame (cut mid-payload) | 1 (every rep) | 203 ms | 0 | 3 ms | 0 B |
SOF delimiter storm (300 × SOF) |
44 (every rep) | 8,840 ms | 0 | 29 ms | 0 B |
512 B unconstrained random noise (including SOF) |
30, 4, then 0 | 6,000 ms | 0 | 47–55 ms | 0 B |
The 25–55 ms baseline recoveries on 512-byte injections are the wire serialisation time of the hostile burst itself: 5,120 bits at 115,200 bps is about 44.4 ms. The stock stack’s 8.84 s blackout is longer than Zigbee2MQTT’s 6,000 ms startup timeout, which is why a restart against stock firmware can report Failed to connect to the adapter.
4. Broadcast storm suppression
Section titled “4. Broadcast storm suppression”Both tests ran at D=150 on the CC1352P7.
| Vector | Stock TI Z-Stack | SMLIGHT ZeroStack | Outcome |
|---|---|---|---|
| 50-router echo amplification storm (1,000 frames: 20 × 50 echoes) | 20 / 20 delivered, 0 duplicates. Echo p50 / p99 143,865 / 152,526 cyc (3.00 ms). 3,004.97 ms total CPU. | 20 / 20 delivered, 0 duplicates. Echo p50 / p99 7,076 / 7,335 cyc (147 µs). 151.16 ms total CPU. | 19.9× lower total CPU, 20.3× faster per echo |
| 64-frame unique broadcast saturation flood (back-to-back) | 30 / 64 delivered (BTT = 30). Accepted p50 154,705 cyc. Shed p50 144,644 cyc (3.01 ms). 200.25 ms total CPU. | Expanded broadcast delivery. Accepted p50 17,699 cyc (369 µs). Shed p50 8,341 cyc (174 µs). 18.87 ms total CPU. 0 duplicates. | 10.6× lower total CPU, 17.3× faster overflow shedding |
ZeroStack raises the Broadcast Transaction Table by +33% (40 against 30 active slots), so a self-inflicted storm does not saturate 2.4 GHz CSMA/CA contention windows or overflow the table into 0xcd: NWK_NO_ROUTE.
5. O(1) allocator and resource exhaustion
Section titled “5. O(1) allocator and resource exhaustion”The allocator’s behaviour under fragmentation is in Part 1: 218 cycles at 64 holes against 2,550. The Part 2 harness then drives the coordinator into three exhaustion regimes and checks that every resource is reclaimed.
| Exhaustion vector | Stock TI Z-Stack | SMLIGHT ZeroStack | Outcome |
|---|---|---|---|
| Timers held until allocation refusal | Uncapped up to the harness limit (255) | Bounded refusal (194 timers, then NO_TIMER_AVAIL) |
Runaway timer use is refused cleanly instead of exhausting memory |
| Control-plane ping at max timers | 5 / 5 answered | 5 / 5 answered | Timer saturation does not impair serial command handling |
| Ping survival at 2,048 / 512 / 128 B free heap | 5/5, 5/5, 5/5 | 5/5, 5/5, 5/5 | Both stacks stay responsive down to 128 B |
| Heap exhausted to 0 B | No crash, 5/5 pings | No crash, 5/5 pings | The host command path keeps answering |
| In-band release after 0 B heap | Recovers 100% (Δheap 0 B) | Recovers 100% (Δheap 0 B) | Back to the exact pre-test byte watermark |
| Single TCLK miss (300 entries), ping stall p50 / max | 33.9 ms / 34.9 ms | 4.3 ms / 4.4 ms | The stock stack stalls ~31 ms per miss. ZeroStack resolves it in 4 µs (208 cyc), and the 4.3 ms is pure UART round-trip. |
| 50 back-to-back TCLK misses + ping | 1.70 s (1,700 ms) | 0.22 s (220 ms) | 7.7× faster, continuously responsive |
6. Malformed over-the-air frames and replay
Section titled “6. Malformed over-the-air frames and replay”Before upper-layer processing, the IEEE 802.15.4 MAC receive boundary was verified across 3,255 adversarial and reference frames (1,085 malformed MHR vectors interleaved with 2,170 valid frames). The sweep covers truncated and oversized lengths, bit-flipped control fields, reserved frame-type and version combinations, invalid addressing modes and compressed PAN identifier permutations. ZeroStack shows 0 memory-safety faults, 0 leaks and 0 state corruption, and accepts every valid frame on the first attempt.
At NWK/APS, each of 12 fault classes starts from a clean boot at D=150 and records cycle counts for the MAC-to-NWK handoff (handoff p50) and the NWK/APS processing (total p50). It then checks SWD heap stability and security-state integrity, and confirms the next valid encrypted frame is accepted.
| Fault class (D = 150) | Vectors | Stock outcome (total p50 / handoff p50 cyc) |
ZeroStack outcome (total p50 / handoff p50 cyc) |
Rejection speedup |
|---|---|---|---|---|
| Malformed cleartext header | 16 | 0 delivered, Δheap 0 B, state intact (3,136 / 1,031) | 0 delivered, Δheap 0 B, state intact (320 / 253) | 9.8× |
| Malformed secured frame, class A | 14 | CRASH: frame-processing fault on unauthenticated input | 0 delivered, state intact (357 / 291) | ∞ (402× cyc) |
| Malformed secured frame, class B | 19 | CRASH: frame-processing fault on unauthenticated input | 0 delivered, state intact (4,731 / 337) | ∞ (30.5× cyc) |
| Malformed upper-layer stub | 8 | 0 delivered, Δheap 0 B (144,290 / 1,437) | 0 delivered (6,312 / 330) | 22.9× |
| Malformed routing header | 9 | BUG: accepts the frame, mutates security state, delivers to the app (144,127 / 1,728) | All 9 rejected, state intact (790 / 394) | 182× |
| Truncated control command, class A | 3 | 0 delivered (149,862 / 1,465) | 0 delivered (6,631 / 347) | 22.6× |
| Truncated control command, class B | 3 | Accepted without drop (152,069 / 1,444) | 0 delivered (6,269 / 335) | 24.3× |
| Authenticated header bit-flips | 240 | All rejected (143,065 / 1,587) | All rejected (4,760 / 357) | 30.1× |
| Ciphertext bit-flips | 120 | 0 delivered (143,060 / 1,587) | 0 delivered (4,768 / 358) | 30.0× |
| Authentication tag bit-flips | 32 | 0 delivered (143,058 / 1,587) | 0 delivered (4,771 / 357) | 30.0× |
Cryptographic replay flood (FC ≤ FC_stored) |
1,000 | 0 delivered (143,802 / 1,589), ~2.99 s total CPU | 0 delivered (1,550 / 355), ~32.4 ms total CPU | 92.8× |
Boundary replay check (FC = FC_stored and FC = 0) |
2 | 0 delivered (143,775 / 1,586) | 0 delivered (1,568 / 355) | 91.7× |
The two secured-frame classes are the remote-reset path: an unauthenticated over-the-air NWK frame with a truncated AuxHeader, payload or MIC takes stock Z-Stack to a deterministic CPU fault (HardFault, Precise BusFault, per the Part 2 PDF) within ~3.0 ms, and the coordinator emits AREQ - SYS - resetInd. The 392 cryptographic bit-flips (240 + 120 + 32) are all rejected by both stacks, and ZeroStack does it 30× cheaper.
Sources
Section titled “Sources”Engineering whitepaper, the Part 2 PDF, and the diagnostic guides for warm-reset and UART, heap and broadcast storms, and MAC channel access.

