Reliable ACKs for DMs (#8165)

* RoutingModule::sendAckNak takes ackWantsAck arg to set want_ack on the ACK itself

* Use reliable delivery for traceroute requests (which will be copied to traceroute responses by setReplyTo)

* Update ReliableRouter::sniffReceived to use ReliableRouter::shouldSuccessAckWithWantAck

* Use isFromUs

* Update MockRoutingModule::sendAckNak to include ackWantsAck argument (currently ignored)

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Mike Robbins
2025-10-01 16:31:53 -04:00
committed by GitHub
parent af83670376
commit f7469159cf
9 changed files with 76 additions and 9 deletions

View File

@@ -47,10 +47,14 @@ meshtastic_MeshPacket *RoutingModule::allocReply()
return NULL;
}
void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopLimit)
void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopLimit,
bool ackWantsAck)
{
auto p = allocAckNak(err, to, idFrom, chIndex, hopLimit);
// Allow the caller to set want_ack on this ACK packet if it's important that the ACK be delivered reliably
p->want_ack = ackWantsAck;
router->sendLocal(p); // we sometimes send directly to the local node
}

View File

@@ -13,8 +13,8 @@ class RoutingModule : public ProtobufModule<meshtastic_Routing>
*/
RoutingModule();
virtual void sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex,
uint8_t hopLimit = 0);
virtual void sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex, uint8_t hopLimit = 0,
bool ackWantsAck = false);
// Given the hopStart and hopLimit upon reception of a request, return the hop limit to use for the response
uint8_t getHopLimitForResponse(uint8_t hopStart, uint8_t hopLimit);

View File

@@ -419,6 +419,9 @@ bool TraceRouteModule::startTraceRoute(NodeNum node)
p->decoded.portnum = meshtastic_PortNum_TRACEROUTE_APP;
p->decoded.want_response = true;
// Use reliable delivery for traceroute requests (which will be copied to traceroute responses by setReplyTo)
p->want_ack = true;
// Manually encode the RouteDiscovery payload
p->decoded.payload.size =
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_RouteDiscovery_msg, &req);
@@ -532,6 +535,9 @@ void TraceRouteModule::launch(NodeNum node)
p->decoded.portnum = meshtastic_PortNum_TRACEROUTE_APP;
p->decoded.want_response = true;
// Use reliable delivery for traceroute requests (which will be copied to traceroute responses by setReplyTo)
p->want_ack = true;
p->decoded.payload.size =
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_RouteDiscovery_msg, &req);