sim: ADAPTIVE flood routing with density-based relay selection and TX power saving#2466
sim: ADAPTIVE flood routing with density-based relay selection and TX power saving#2466Heilo27 wants to merge 1 commit into
Conversation
…aving Adds a complete simulation harness for the MeshCore radio platform, including: ### ADAPTIVE routing strategy (sim/src/RoutingStrategies.h) Hash-based relay gate selects a deterministic subset of nodes to forward each flood, with relay percentage adapted to local neighbour density: - SPARSE (<=4 neighbours): 100% relay -- no redundancy to spare - MEDIUM (5-14): 25% relay - DENSE (>=15): 15% relay Selection uses hash(packet_seed XOR node_seed) with no coordination required. Different packets select different subsets for stochastic load balancing. Relay suppression: nodes cancel queued outbound TX if they overhear another node already relaying the same flood (matched by packet hash). ### DensityEstimator (sim/src/DensityEstimator.h) Passive sliding-window neighbour count from normal traffic -- no extra messages. Only counts direct senders (hop_count==1) over a configurable window (default 60s). Uses std::unordered_set for unique counting; no fixed-array cap. ### Adaptive TX power saving (sim/src/SimNode.h) power_save_enabled reduces TX power in DENSE/MEDIUM tiers: DENSE: configurable (default 10 dBm, saves 75% TX current vs 20 dBm) MEDIUM: configurable (default 14 dBm, saves 60% TX current) SPARSE: always full power -- every hop counts on marginal links Validated: 100% delivery maintained at -10dBm DENSE reduction. Energy savings ~35% radio total. TX power reduction also lowers area RF noise floor. ### Scenario suite (sim/scenarios/) scenario_adaptive: ADAPTIVE vs DEFAULT vs PATH_SNR_HYBRID comparison scenario_concurrent: 2-8 simultaneous flood sources scenario_longchain: 20-hop chains at marginal SNR scenario_mixed: ADAPTIVE + legacy DEFAULT interoperability scenario_dutycycle: EU 1% duty cycle enforcement validation scenario_relay_pct_sweep: grid sweep to find optimal DENSE%/MEDIUM% operating point scenario_txpower: TX power saving vs delivery rate vs energy trade-off ### Key empirical results FM50 ADAPTIVE vs DEFAULT: equal delivery rate, -65% airtime, -70% collisions CH20 (chain): ADAPTIVE = SPARSE throughout, identical to DEFAULT TX power MODERATE (-10dB): 100% delivery, -35% energy across all topologies Legacy interop: zero delivery regression with mixed firmware ### Bug fixes - DensityEstimator: replace seen[64] array with unordered_set (was capping at 64 neighbours) - SimBus::onTransmit: add len > 255 guard before memcpy into 255-byte buffer - SimNode p_forward gate: >= -> > (was silently dropping relays at p_forward=1.0) - SimNode TX power reset: remove redundant !power_save_enabled clause - scenario_concurrent: fix stale ConcurrentResult* pointer after vector reallocation - scenario_relay_pct_sweep: update TxCallback from 4-arg to 5-arg (tx_power_dbm) - scenario_adaptive: remove unused variable last_suppressed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
" adapted to local neighbour density" this is a thing like meshtastic made, and i hated it. on my view this will do something similar. In addition to this you need a setting to switch it off on top of the hill repeaters, and then the folks down with their little ones will do it too. so no offence. i think the benefits from this will not work in the real world, because of not ideal repeaters |
|
Oh absolutely I get that. It would need tweeking for sure. My thought was using this in crowds would be beneficial and stop the constant re-broadcasting of every single message which causes drop messages and collisions. And it doesn’t base it off of signal quality it bases it off of a hash, which just kind of randomizes it and it only does it when there are enough nodes nearby that it’s becoming a problem so greater than 12 to 15 nodes the system starts to re-broadcast transmissions select selectively using a hash when a radio receives a message. It helps choose whether or not it will re-broadcast it to everyone else in other words it lowers overall network Clutter by 60% saves battery life on your radio since it’s not re-broadcasting every message needlessly and fewer re-broadcast means fewer collisions. I did think of provisions for edge cases and I think that there is definitely room for improvement however, in simulator, I tested this theory and it did show a dramatic reduction and dropped Messages power usage, but still ensuring 100% coverage. I absolutely think hilltop nodes don’t need this, and there is the ability to turn it on and off or maybe not even be flashed with this version of the firmware at all but for mobile notes, this would be very valuable in situations with a large gathering of people. -RyanOn May 15, 2026, at 6:40 AM, gafu ***@***.***> wrote:gafu42 left a comment (meshcore-dev/MeshCore#2466)
" adapted to local neighbour density"
this is a thing like meshtastic made, and i hated it.
in meshtastic the traffic reduction worked by SNR, relays with good snr doesnt repeat if someone with a lower SNR repeated first. In the real world with, nodes with bad antennas and indoor antennas, this enforced the mesh to be relayed through the link with the lowest quality. Sometimes this was a distant node, but often it was a bad performing one close to the sender, hindering the good one to repeat. This made the mesh very bad perfoming as soon as the mesh was growing.
on my view this will do something similar.
The "top height" relays, which can receive repeats from a wide area will stop repeating in favor to ones, which can receive only one or two others because their not optimal place oder bad antenna.
In addition to this you need a setting to switch it off on top of the hill repeaters, and then the folks down with their little ones will do it too.
so no offence. i think the benefits from this will not work in the real world, because of not ideal repeaters
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Summary
This PR adds a full native-C++ simulation harness for MeshCore, along with a new ADAPTIVE routing strategy that has been empirically validated across multiple topologies. Everything in the
sim/directory is simulation-only — no firmware code is touched.What's new
ADAPTIVE routing strategy (
sim/src/RoutingStrategies.h)Hash-based relay gate selects a deterministic subset of nodes to relay each flood, with the subset size adapted to local neighbour density:
Selection:
hash(packet_seed XOR node_seed) % 100 < relay_pctDensityEstimator (
sim/src/DensityEstimator.h)Passive neighbour density measurement from normal traffic — no extra protocol messages. Counts unique direct senders (hop_count == 1) over a 60-second sliding window. Thresholds are compile-time overridable.
Adaptive TX power saving (
sim/src/SimNode.h)Opt-in feature (
power_save_enabled). ADAPTIVE-selected relay nodes reduce TX power in dense areas:Motivation: at a high-density event (festival, conference), nodes running at full power 100% of the time waste battery and raise the local RF noise floor. Reducing power when you have 15+ neighbours: (a) saves battery, (b) shrinks interference radius via the LoRa capture effect, (c) doesn't hurt local delivery since nearby nodes still receive well above sensitivity.
Validated: 100% delivery maintained at MODERATE (-10 dBm DENSE) across all topologies tested.
Simulation infrastructure
sim/src/SimBus.hsim/src/SimNode.hsim/src/SimRadio.hsim/src/SimMetrics.hsim/src/SimRuntime.hChannel models available:
FullMeshModel,ChainModel,GridModel,PositionalModel.Scenario suite
scenario_adaptivescenario_concurrentscenario_longchainscenario_mixedscenario_dutycyclescenario_relay_pct_sweepscenario_txpowerKey empirical results
Bug fixes (found during development)
DensityEstimator: replacedseen[64]fixed array withstd::unordered_set— was silently capping unique neighbour count at 64SimBus::onTransmit: addedlen > 255guard beforememcpyinto 255-byte bufferSimNodep_forward gate:>=→>— was silently suppressing relays at exactlyp_forward=1.0Building
Requires a C++17 compiler. No dependencies beyond what's already in the repo (uses
lib/ed25519,deps/arduinolibs/Crypto).Not in this PR
This PR is simulation-only. The ADAPTIVE strategy would need firmware integration work (replacing the node_seed with a pub-key-prefix hash, hooking
getRetransmitDelay()) before it could run on hardware. That's a separate conversation — wanted to get the algorithm validated first.