From 8be76a56c7a9ec8d9455539a9c43d6676a5d2495 Mon Sep 17 00:00:00 2001 From: Marek <118679709+Marek-mk@users.noreply.github.com> Date: Fri, 20 Jun 2025 01:48:35 +0200 Subject: [PATCH] PacketHistory - option to track entries' aging to log (#7067) * PacketHistory debloat RAM allocations * Removed FLOOD_EXPIRE_TIME option. We have static buffer now. * Remove mx_ prefix from recentPackets * Remember no less than 100 packet not to make reflood hell * Cleanup * PacketHistory max no less than 100 * no less than 100 means max of 100 or a given value of course. * Care to not do duplicate entries. Cleanups. * Packet History - option to log aging of entries * Update comments for PACKET_HISTORY_TRACE_AGING and VERBOSE_PACKET_HISTORY definitions --------- Co-authored-by: Ben Meadors --- src/mesh/PacketHistory.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mesh/PacketHistory.cpp b/src/mesh/PacketHistory.cpp index fd2218d94..6b8ccde76 100644 --- a/src/mesh/PacketHistory.cpp +++ b/src/mesh/PacketHistory.cpp @@ -12,7 +12,8 @@ #define RECENT_WARN_AGE (10 * 60 * 1000L) // Warn if the packet that gets removed was more recent than 10 min -#define VERBOSE_PACKET_HISTORY 0 // Set to 1 for verbose logging, 2 for heavy debugging +#define VERBOSE_PACKET_HISTORY 0 // Set to 1 for verbose logging, 2 for heavy debugging +#define PACKET_HISTORY_TRACE_AGING 1 // Set to 1 to enable logging of the age of re/used history slots PacketHistory::PacketHistory(uint32_t size) : recentPacketsCapacity(0), recentPackets(NULL) // Initialize members { @@ -254,6 +255,16 @@ void PacketHistory::insert(PacketRecord &r) #endif } } + +#if PACKET_HISTORY_TRACE_AGING + if (tu->rxTimeMsec != 0) { + LOG_INFO("Packet History - insert: Reusing slot aged %.3fs TRACE %s", OldtrxTimeMsec / 1000., + (tu->id == r.id && tu->sender == r.sender) ? "MATCHED PACKET" : "OLDEST SLOT"); + } else { + LOG_INFO("Packet History - insert: Using new slot @uptime %.3fs TRACE NEW", millis() / 1000.); + } +#endif + #endif #if VERBOSE_PACKET_HISTORY