@@ -97,27 +97,34 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
97
97
void ReliableRouter::sniffReceived (const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
98
98
{
99
99
if (isToUs (p)) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability)
100
- if (p->want_ack ) {
101
- if (MeshModule::currentReply) {
102
- LOG_DEBUG (" Another module replied to this message, no need for 2nd ack" );
103
- } else if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
104
- // A response may be set to want_ack for retransmissions, but we don't need to ACK a response if it received an
105
- // implicit ACK already. If we received it directly, only ACK with a hop limit of 0
106
- if (!p->decoded .request_id )
107
- sendAckNak (meshtastic_Routing_Error_NONE, getFrom (p), p->id , p->channel ,
100
+ if (!MeshModule::currentReply) {
101
+ if (p->want_ack ) {
102
+ if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
103
+ /* A response may be set to want_ack for retransmissions, but we don't need to ACK a response if it received
104
+ an implicit ACK already. If we received it directly or via NextHopRouter, only ACK with a hop limit of 0 to
105
+ make sure the other side stops retransmitting. */
106
+ if (!p->decoded .request_id && !p->decoded .reply_id ) {
107
+ sendAckNak (meshtastic_Routing_Error_NONE, getFrom (p), p->id , p->channel ,
108
+ routingModule->getHopLimitForResponse (p->hop_start , p->hop_limit ));
109
+ } else if ((p->hop_start > 0 && p->hop_start == p->hop_limit ) || p->next_hop != NO_NEXT_HOP_PREFERENCE) {
110
+ sendAckNak (meshtastic_Routing_Error_NONE, getFrom (p), p->id , p->channel , 0 );
111
+ }
112
+ } else if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && p->channel == 0 &&
113
+ (nodeDB->getMeshNode (p->from ) == nullptr || nodeDB->getMeshNode (p->from )->user .public_key .size == 0 )) {
114
+ LOG_INFO (" PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY" );
115
+ sendAckNak (meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY, getFrom (p), p->id , channels.getPrimaryIndex (),
108
116
routingModule->getHopLimitForResponse (p->hop_start , p->hop_limit ));
109
- else if (p->hop_start > 0 && p->hop_start == p->hop_limit )
110
- sendAckNak (meshtastic_Routing_Error_NONE, getFrom (p), p->id , p->channel , 0 );
111
- } else if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && p->channel == 0 &&
112
- (nodeDB->getMeshNode (p->from ) == nullptr || nodeDB->getMeshNode (p->from )->user .public_key .size == 0 )) {
113
- LOG_INFO (" PKI packet from unknown node, send PKI_UNKNOWN_PUBKEY" );
114
- sendAckNak (meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY, getFrom (p), p->id , channels.getPrimaryIndex (),
115
- routingModule->getHopLimitForResponse (p->hop_start , p->hop_limit ));
116
- } else {
117
- // Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded
118
- sendAckNak (meshtastic_Routing_Error_NO_CHANNEL, getFrom (p), p->id , channels.getPrimaryIndex (),
119
- routingModule->getHopLimitForResponse (p->hop_start , p->hop_limit ));
117
+ } else {
118
+ // Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded
119
+ sendAckNak (meshtastic_Routing_Error_NO_CHANNEL, getFrom (p), p->id , channels.getPrimaryIndex (),
120
+ routingModule->getHopLimitForResponse (p->hop_start , p->hop_limit ));
121
+ }
122
+ } else if (p->next_hop == nodeDB->getLastByteOfNodeNum (getNodeNum ()) && p->hop_limit > 0 ) {
123
+ // No wantAck, but we need to ACK with hop limit of 0 if we were the next hop to stop their retransmissions
124
+ sendAckNak (meshtastic_Routing_Error_NONE, getFrom (p), p->id , p->channel , 0 );
120
125
}
126
+ } else {
127
+ LOG_DEBUG (" Another module replied to this message, no need for 2nd ack" );
121
128
}
122
129
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && c &&
123
130
c->error_reason == meshtastic_Routing_Error_PKI_UNKNOWN_PUBKEY) {
0 commit comments