diff --git a/docs/PEER_PROTOCOL.md b/docs/PEER_PROTOCOL.md index 68cbaa4..f811db7 100644 --- a/docs/PEER_PROTOCOL.md +++ b/docs/PEER_PROTOCOL.md @@ -276,10 +276,14 @@ Send cadence: - **Edge-triggered** on local-state changes that affect the set: client connect / disconnect, `MsgSelectTG`, `MsgTgMonitor`, and trunk hello completion. Coalesced with a 500 ms debounce so a client toggling its - monitor list one TG at a time sends one update, not many. -- **Periodic refresh** every 60 s as a safety net against lost deltas. - Both timers skip the actual send when the outgoing set is unchanged - since the last transmission, so an idle reflector generates no traffic. + monitor list one TG at a time sends one update, not many. This path + skips the actual send when the outgoing set is unchanged. +- **Periodic refresh** every 60 s — *always sends*, even when the + outgoing set is unchanged. The heartbeat is what keeps the receiver's + `m_peer_interested_tgs` entries from expiring at the 600 s TTL: every + receipt rewrites the timestamp, so an idle monitor stays known to its + peer indefinitely. Without this the monitor would go deaf 10 minutes + after the last edge-triggered change. Multi-hop propagation: when a reflector receives `MsgPeerTgInterest` from a peer P, it triggers a refresh on its other trunk links. Each other diff --git a/src/svxlink/reflector/TrunkLink.cpp b/src/svxlink/reflector/TrunkLink.cpp index f5fe4be..6629f7d 100644 --- a/src/svxlink/reflector/TrunkLink.cpp +++ b/src/svxlink/reflector/TrunkLink.cpp @@ -1826,14 +1826,22 @@ void TrunkLink::handleMsgPeerTgInterest(std::istream& is) void TrunkLink::onTgInterestTimer(Async::Timer*) { - sendTgInterest(); + // Periodic refresh: always re-send (force=true) so the receiver's + // m_peer_interested_tgs entries get their timestamp refreshed and the + // 600 s TTL stays alive even when the local set hasn't changed since + // the last debounce send. Without this, a passive monitor would go + // deaf after 600 s of no-op heartbeats. + sendTgInterest(/*force=*/true); } /* TrunkLink::onTgInterestTimer */ void TrunkLink::onTgInterestDebounce(Async::Timer* t) { t->setEnable(false); - sendTgInterest(); + // Edge-triggered: skip when the outgoing set is unchanged. The 60 s + // heartbeat above takes care of receiver-TTL upkeep, so this path can + // safely no-op on idle changes. + sendTgInterest(/*force=*/false); } /* TrunkLink::onTgInterestDebounce */ @@ -1872,16 +1880,15 @@ std::set TrunkLink::buildOutgoingTgInterest(void) const } /* TrunkLink::buildOutgoingTgInterest */ -void TrunkLink::sendTgInterest(void) +void TrunkLink::sendTgInterest(bool force) { if (!isActive()) return; std::set outgoing = buildOutgoingTgInterest(); - if (outgoing == m_last_sent_tg_interest) + if (!force && outgoing == m_last_sent_tg_interest) { - // Nothing changed since the last advertisement — let the receiver's TTL - // ride on the previous send. Keeps the heartbeat refresh from generating - // idle traffic when the monitored set is stable. + // Edge-triggered debounce path with nothing changed: skip. The 60 s + // heartbeat (force=true) will refresh the receiver's TTL. return; } diff --git a/src/svxlink/reflector/TrunkLink.h b/src/svxlink/reflector/TrunkLink.h index 00374a1..cfc1cfd 100644 --- a/src/svxlink/reflector/TrunkLink.h +++ b/src/svxlink/reflector/TrunkLink.h @@ -294,7 +294,9 @@ class TrunkLink : public sigc::trackable void handleMsgPeerNodeList(std::istream& is); void handleMsgPeerTgInterest(std::istream& is); - void sendTgInterest(void); + // force=true bypasses skip-when-unchanged so the periodic 60 s + // heartbeat refreshes the receiver's m_peer_interested_tgs TTL. + void sendTgInterest(bool force = false); void onTgInterestTimer(Async::Timer* t); void onTgInterestDebounce(Async::Timer* t); // Build the set we should advertise to this peer: local interest, plus