Skip to content

Commit

Permalink
Move repeated sending logic to wasSeenRecently()
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF committed Nov 3, 2024
1 parent 791d30b commit 0c763af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/mesh/PacketHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ bool PacketHistory::wasSeenRecently(const meshtastic_MeshPacket *p, bool withUpd
seenRecently = false;
}

/* If the original transmitter is doing retransmissions (hopStart equals hopLimit) for a reliable transmission, e.g., when the
ACK got lost, we will handle the packet again to make sure it gets an ACK/response to its packet. */
if (seenRecently && p->hop_start > 0 && p->hop_start == p->hop_limit) {
seenRecently = false;
}

if (seenRecently) {
LOG_DEBUG("Found existing packet record for fr=0x%x,to=0x%x,id=0x%x", p->from, p->to, p->id);
}
Expand Down
13 changes: 0 additions & 13 deletions src/mesh/ReliableRouter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "ReliableRouter.h"
#include "Default.h"
#include "MeshModule.h"
#include "MeshTypes.h"
#include "configuration.h"
#include "mesh-pb-constants.h"
Expand Down Expand Up @@ -74,18 +73,6 @@ bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
i->second.nextTxMsec += iface->getPacketTime(p);
}

/* Resend implicit ACKs for repeated packets (hopStart equals hopLimit);
* this way if an implicit ACK is dropped and a packet is resent we'll rebroadcast again.
* Resending real ACKs is omitted, as you might receive a packet multiple times due to flooding and
* flooding this ACK back to the original sender already adds redundancy. */
bool isRepeated = p->hop_start == 0 ? (p->hop_limit == HOP_RELIABLE) : (p->hop_start == p->hop_limit);
if (wasSeenRecently(p, false) && isRepeated && !MeshModule::currentReply && !isToUs(p)) {
LOG_DEBUG("Resending implicit ack for a repeated floodmsg");
meshtastic_MeshPacket *tosend = packetPool.allocCopy(*p);
tosend->hop_limit--; // bump down the hop count
Router::send(tosend);
}

return FloodingRouter::shouldFilterReceived(p);
}

Expand Down

0 comments on commit 0c763af

Please sign in to comment.