[Bug]: NextHopRouter retransmissions to a direct neighbour can never be stopped, because the destination only ACKs the first copy
Category
Other (routing / NextHopRouter)
Hardware
Not hardware-specific — this is in src/mesh/, reached on any build. Observed while investigating a portduino-to-nRF52 link, but the code path has no platform dependency.
Firmware Version
develop @ d49cf21. All line numbers below are from that commit.
Description
For a unicast that a node originates with want_ack = false, a non-zero hop_limit and a learned next_hop, NextHopRouter starts relay-style retransmissions. That is deliberate — the gate is written to admit it:
// src/mesh/NextHopRouter.cpp:124
if (trackRetransmission && (!isFromUs(p) || !p->want_ack) && p->next_hop != NO_NEXT_HOP_PREFERENCE &&
(p->hop_limit > 0 || p->want_ack)) {!p->want_ack satisfies the first clause for our own packet, so the effective gate is hop_limit > 0 with a known next hop.
There is also a deliberate mechanism to stop them when the next hop is the final destination, which cannot supply an implicit ack because it will not rebroadcast a DM addressed to itself:
// src/mesh/ReliableRouter.cpp:155
} else if (p->next_hop == nodeDB->getLastByteOfNodeNum(getNodeNum()) && p->hop_limit > 0) {
// No wantAck, but we need to ACK with hop limit of 0 if we were the next hop to stop their retransmissions
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
}The bug is that this ACK is only ever generated for the first copy. If it is lost, the retransmission arrives as a duplicate and is caught in shouldFilterReceived before sniffReceived runs. The duplicate branch does contain a re-ACK, but it is gated on want_ack:
// src/mesh/NextHopRouter.cpp:163
bool isRepeated = getHopsAway(*p) == 0;
if (isRepeated) {
if (!findInTxQueue(p->from, p->id)) {
if (reprocessPacket(p) && !isBlockedEventCoordinatePacket(p) && !perhapsRebroadcast(p) && isToUs(p) &&
p->want_ack) {
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
}
}
}p->want_ack is false for exactly the packets whose retransmissions the ReliableRouter.cpp:155 ACK exists to stop, so after one lost ACK nothing can stop them.
The asymmetry is clearest against the relay case in that same branch. An intermediate hop reaches perhapsRebroadcast(p) and relays the duplicate again, which regenerates the implicit ack the sender is waiting for, so the relay path self-heals. The final destination is the only hop that cannot regenerate its acknowledgement, and it is the one whose acknowledgement is conditioned on want_ack.
What follows from a single lost ACK
doRetransmissions spends the full NUM_INTERMEDIATE_RETX allowance, and on the last try (numRetransmissions == 1) it calls noteRouteFailure(p.packet->to), clears next_hop in the NodeDB, and re-sends through FloodingRouter. So a working direct link is torn down and the next DM to that node floods.
Then, when the allowance reaches zero:
// src/mesh/NextHopRouter.cpp:475
if (isFromUs(p.packet)) {
LOG_DEBUG("Reliable send failed, return nak fr=0x%08x,to=0x%08x,id=0x%08x", ...);
sendAckNak(meshtastic_Routing_Error_MAX_RETRANSMIT, getFrom(p.packet), p.packet->id, p.packet->channel);
}to is our own node number, so sendAckNak → sendLocal → deliverLocal hands the error to the local app/phone. The result is a MAX_RETRANSMIT routing error reported for a packet that set want_ack = false — one the application never asked to have confirmed, and which in this scenario was delivered successfully on the first attempt. The log line reads "Reliable send failed" for a packet that was never reliable.
There is no want_ack check on that NAK, so it is not limited to this path.
Cost even in the success case
Every originated non-reliable unicast toward a known next hop buys one extra transmission from the peer — the 0-hop routing ACK — in addition to whatever the application itself sends back. On a slow preset, in a bidirectional half-duplex exchange, that is a significant fraction of the channel spent acknowledging packets nobody asked to have acknowledged, and an application has no way to opt out other than setting hop_limit = 0.
Suggested fixes
Two independent changes, both small:
- In the duplicate branch at
NextHopRouter.cpp:163, make the re-ACK condition mirror whatever generated the ACK in the first place (i.e. also re-ACK whenp->next_hopnames us andp->hop_limit > 0) rather than testingwant_ack. That closes the loop the design already intends. - Guard the
MAX_RETRANSMITNAK atNextHopRouter.cpp:475onp.packet->want_ack, so a packet that did not request delivery confirmation cannot be reported as having failed it.
Reproducing
Originate a directed unicast with want_ack = false and hop_limit > 0 to a direct neighbour the sender has a learned next_hop for, on a link lossy enough to drop the 0-hop routing ACK, and watch the sender's log for Send retransmission ... tries left=, Reset next hop for dest, and Reliable send failed, return nak while the destination has the payload. On the destination, the retransmissions appear as Ignore dupe incoming msg with no ACK sent in response.
Note that the duplicates are invisible above the dupe filter: they reuse the packet id, so shouldFilterReceived drops them before handleReceived, and no module-level counter can see them. Any measurement of this has to be taken at the router, not in the receiving module.
Relevant log output
No application-level log is needed to see this; the relevant lines are the existing LOG_DEBUGs in doRetransmissions (Send retransmission, Reliable send failed, return nak), Reset next hop for dest in the same function, and Ignore dupe incoming msg on the destination. I have not attached a capture because the traces I have come from a branch with local additions, and I did not want to post log lines that do not exist on develop.
Generated by Claude Code
Source: meshtastic/firmware