From 25a58003c7c9d8aaa33abc719583293dabf6b44f Mon Sep 17 00:00:00 2001 From: medentem Date: Tue, 7 Jan 2025 15:53:55 -0600 Subject: [PATCH] unknown coverage rebroadcast probability --- src/mesh/FloodingRouter.cpp | 9 ++++++--- src/mesh/MeshTypes.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 81098fbca..78357b282 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -168,12 +168,15 @@ float FloodingRouter::calculateForwardProbability(const CoverageFilter &incoming return 1.0f; #endif // If we are a router or repeater, always forward because it's assumed these are in the most advantageous locations - // or if we haven't heard from any other nodes directly within the stale coverage time, fall back to always forward if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER || - config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER || - nodeDB->secondsSinceLastDirectNeighborHeard() >= STALE_COVERAGE_SECONDS) { + config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) { return 1.0f; } + + // If we haven't heard from any other nodes directly within the stale coverage time, fall back to always forward + if (nodeDB->secondsSinceLastDirectNeighborHeard() >= STALE_COVERAGE_SECONDS){ + return UNKNOWN_COVERAGE_FORWARD_PROB; + } // Retrieve recent direct neighbors within the time window std::vector recentNeighbors = nodeDB->getCoveredNodes(RECENCY_THRESHOLD_MINUTES * 60); diff --git a/src/mesh/MeshTypes.h b/src/mesh/MeshTypes.h index 136499058..07b95f78b 100644 --- a/src/mesh/MeshTypes.h +++ b/src/mesh/MeshTypes.h @@ -62,6 +62,7 @@ enum RxSource { // 0.2 could be suitable because the worst case False Positive Rate of the // coverage filter is 37%. That's if its saturated with 60 unique nodes. #define BASE_FORWARD_PROB 0.0f +#define UNKNOWN_COVERAGE_FORWARD_PROB 0.8f // Coverage scaling factor #define COVERAGE_SCALE_FACTOR 4.0f