Skip to content

Simulated multi-hop MeshCore fabric for scale-testing the bearer - #168

Merged
M0LTE merged 2 commits into
masterfrom
meshcore-sim-fabric
Jul 1, 2026
Merged

Simulated multi-hop MeshCore fabric for scale-testing the bearer#168
M0LTE merged 2 commits into
masterfrom
meshcore-sim-fabric

Conversation

@M0LTE

@M0LTE M0LTE commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What

An in-process multi-hop MeshCore mesh that runs the real bearer classes over topologies the two bench radios (one hop, direct) can't reach — multi-hop flood, dedup across paths, flood-scope containment, reliability + discovery over several hops — with no RF, deterministically, in CI. This is the tier-1 strategy from the #24 test-strategy discussion.

Why

The firmware is a source-verified fixed input (64-hop cap, 160-entry no-expiry dedup ring, transport-code scope drop). What actually needs scale-testing is our logic running on top of that behaviour — so reproduce the behaviour and run the unchanged bearer over it.

How

  • IMeshCoreLink extracted from MeshCoreLink (SendDataAsync/DrainAsync/MessageWaiting/PacketHeard/State); MeshCoreCompanionBackhaul + MeshCoreInbound take the interface. Behaviour-preserving — MeshCoreLink implements it and all 744 tests still pass.
  • dapps.meshcore.simMeshFabric models Leaf (DAPPS companion) / Relay (repeater) nodes on lossy undirected edges; Flood propagates hop-by-hop with per-node dedup (the ring), the hop cap, and flood-scope containment (a scoped flood re-floods only through relays sharing the scope). SimulatedMeshCoreLink : IMeshCoreLink drops in for the serial link; MeshDappsNode runs the real backhaul + inbound + reliability + discovery on a leaf.

Tests

  • MeshFabricTests — multi-hop delivery, dedup across two paths, ring-terminates (no infinite flood), leaf-doesn't-relay, scope containment + controls, and the real transport carried + decoded exactly once over 3 relay hops (single- and multi-fragment).
  • MeshFabricScenarioTests — the full bearer stack (transport + reliability ACK + idempotent inbound + passive discovery) over a 4-relay backbone bidirectionally, and a 5-sender fan-in — every message delivered exactly once, peers discovered multi-hop.

Scope

Models the channel, not serial-link liveness. No-loss runs are deterministic/fast; loss-recovery (multi-second reliability resends) is left to a longer harness run. Propagation is instantaneous — correctness (delivery/dedup/containment) is faithful; fine-grained timing isn't. Validating the firmware boundary itself still wants a real Repeater board + attenuators.

🤖 Generated with Claude Code

M0LTE and others added 2 commits July 1, 2026 10:35
Two adjacent bench radios can't exercise the design centre - sparse DAPPS nodes
with long strings of relays between them. The firmware is a verified fixed input
(64-hop cap, 160-entry dedup ring, transport-code scope drop), so what needs
scale-testing is OUR logic on top of it. This adds an in-process mesh that runs
the REAL bearer over arbitrary multi-hop topologies.

- Extract IMeshCoreLink (SendDataAsync/DrainAsync/MessageWaiting/PacketHeard/State)
  from MeshCoreLink; MeshCoreCompanionBackhaul + MeshCoreInbound take the interface
  (behaviour-preserving - MeshCoreLink implements it, all 744 tests still pass).
- dapps.meshcore.sim: MeshFabric models Leaf (DAPPS companion) / Relay (repeater)
  nodes on lossy undirected edges and floods a datagram hop-by-hop with per-node
  dedup (the ring), the hop cap, and flood-scope containment (a scoped flood is
  re-flooded only by relays sharing the scope). SimulatedMeshCoreLink : IMeshCoreLink
  drops in for the serial link; MeshDappsNode runs the real backhaul + inbound +
  reliability + discovery on a leaf.
- Tests: MeshFabricTests (multi-hop delivery, dedup across paths, ring terminates,
  leaf-doesn't-relay, scope containment + controls, real transport carried/decoded
  once over 3 relay hops) and MeshFabricScenarioTests (the full bearer stack over a
  4-relay backbone bidirectionally + a 5-sender fan-in, each message delivered
  exactly once, peers discovered multi-hop).

This is the tier-1 test strategy from the #24 discussion: it validates multi-hop,
dedup-across-paths, and model-B containment deterministically, in CI, with no RF.
A real Repeater board + attenuators remains the way to validate the firmware
boundary itself.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLbwvhE2cKCe8WPZNg8k17
The adversarial review caught a real (low) modelling bug: the flood re-flooded
through at most 63 relays, but MeshCore's cap is MAX_PATH_SIZE=64 forwarders (a
relay forwards while the path_len it received is < 64). The bug came from carrying
a 1-based "hop" and enqueuing the transmitter's hop rather than the path_len the
receiver sees.

Track path_len exactly as the firmware does: the origin transmits with path_len=0;
a relay that received path_len P forwards iff P < 64 and its transmission carries
P+1. So relays R1..R64 forward and R65 (which would receive 64) is dropped - one
relay further than before, matching the firmware boundary the harness exists to
exercise.

Test: HopCap_DeliversAtExactly64Relays_DropsBeyond (delivered at 64 relays, not at
65) - the long-chain edge no prior test reached.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLbwvhE2cKCe8WPZNg8k17
@M0LTE
M0LTE merged commit f409a56 into master Jul 1, 2026
4 checks passed
@M0LTE
M0LTE deleted the meshcore-sim-fabric branch July 1, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant