From 05b34449d9bb6dfec702e4aeefc6aceb08f063ee Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 29 Jul 2025 10:54:40 +1000 Subject: [PATCH 1/3] Only send Neighbours if we have some to send. The original intent of NeighborInfo was that when a NeighbourInfo was sent all of the nodes that saw it would reply with NeighbourInfo. So, NeighbourInfo was sent even if there were no hop-zero nodes in the NodeDB. Since 2023, when this was implemented, our understanding of running city-wide meshes has improved substantially. We have taken steps to reduce the impact of NeighborInfo over LoRa. This change aligns with those ideas: we will now only send NeighborInfo if we have some neighbors to contribute. The impact of this change is that a node must first see another directly connected node in another packet type before NeighborInfo is sent. This means that a node with no neighbors is no longer able to trigger other nodes to broadcast NeighborInfo. It will, however, receive the regular periodic broadcast of NeighborInfo, and will be able to send NeighborInfo if it has at least 1 neighbor. --- src/modules/NeighborInfoModule.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index eebf428a4..8fa86eb1f 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -106,12 +106,13 @@ void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies) meshtastic_NeighborInfo neighborInfo = meshtastic_NeighborInfo_init_zero; collectNeighborInfo(&neighborInfo); meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo); - // send regardless of whether or not we have neighbors in our DB, - // because we want to get neighbors for the next cycle p->to = dest; p->decoded.want_response = wantReplies; p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; - printNeighborInfo("SENDING", &neighborInfo); + // only send neighbours if we have some to send + if (neighborInfo.neighbors_count > 0) { + printNeighborInfo("SENDING", &neighborInfo); + } service->sendToMesh(p, RX_SRC_LOCAL, true); } From 439534f1fb2abd296180892c902d2d89b3d7aca5 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 29 Jul 2025 21:03:26 +1000 Subject: [PATCH 2/3] Include all the things --- src/modules/NeighborInfoModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index 8fa86eb1f..a1929798d 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -112,8 +112,8 @@ void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies) // only send neighbours if we have some to send if (neighborInfo.neighbors_count > 0) { printNeighborInfo("SENDING", &neighborInfo); + service->sendToMesh(p, RX_SRC_LOCAL, true); } - service->sendToMesh(p, RX_SRC_LOCAL, true); } /* @@ -215,4 +215,4 @@ meshtastic_Neighbor *NeighborInfoModule::getOrCreateNeighbor(NodeNum originalSen neighbors.push_back(new_nbr); } return &neighbors.back(); -} \ No newline at end of file +} From 0a5263a4aa0b74fae325469c8c0299b2d9a3eca7 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 29 Jul 2025 21:05:46 +1000 Subject: [PATCH 3/3] AvOid memleak --- src/modules/NeighborInfoModule.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index a1929798d..97dc17001 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -105,12 +105,12 @@ void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies) { meshtastic_NeighborInfo neighborInfo = meshtastic_NeighborInfo_init_zero; collectNeighborInfo(&neighborInfo); - meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo); - p->to = dest; - p->decoded.want_response = wantReplies; - p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; // only send neighbours if we have some to send if (neighborInfo.neighbors_count > 0) { + meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo); + p->to = dest; + p->decoded.want_response = wantReplies; + p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; printNeighborInfo("SENDING", &neighborInfo); service->sendToMesh(p, RX_SRC_LOCAL, true); }