feat(peer): passive-monitor support via MsgPeerTgInterest
A node that has selected a TG without keying, or marked it in monitoredTGs, never received any audio: peer interest was only populated by talker activity, and the local UDP fanout filtered by TgFilter alone (current TG match), ignoring monitor entries. Adds: - MsgPeerTgInterest (wire ID 129, peer_id + vector<uint32_t>) — each trunk peer advertises the union of its local clients' selected TG and monitoredTGs to peers whose prefix is the longest-prefix-match for the TG. Edge-triggered (500 ms debounce) on client connect / disconnect, MsgSelectTG, MsgTgMonitor, and trunk hello completion; 60 s periodic refresh as a safety net, skipping when the outgoing set is unchanged. The receiver writes mapTgIn(tg) into m_peer_interested_tgs so the existing send-side gates (isPeerInterestedTG, shouldRelayInbound + forwardTrunkAudioToOther Trunks) deliver audio without requiring a PTT to bootstrap. - Multi-hop propagation. Receivers re-advertise interest from other peers, prefix-filtered for the destination link and source-link excluded, so country-gateway-into-national-mesh layouts (§2) converge in one debounce per hop. Closes the gap where SE monitoring an Italian regional TG would never reach Z1 without IT 222 explicitly forwarding interest. - TgMonitorFilter applied at every local UDP fanout (audio + MsgUdpFlushSamples) — Reflector::onUdpFrameReceived and the local talker stop, the trunk receive path, and both directions of the satellite mirror. Without this, the protocol-level interest arrives at the right reflector but stops at its UDP fanout — the passive monitor still hears nothing. Strict superset: no existing delivery path is removed. Loop safety relies on filtering local-side MsgPeerTgInterest by isSharedTG (same gate as audio fanout). Advertising to non-owner peers would register ghost interest there, which gateway prefix routing would then relay back across the mesh. Verified by test_32_three_way_conversation (full mesh, no echo loops). Tests: new test_39_passive_monitor_multihop covers the §2 chain (SE-style monitor on a, talker on d, gateway b). All existing tests pass: 42 trunk + 7 mqtt-deltas + 6 logging + 14 twin = 69/69. Builds on the idea originally proposed in #4 by @sa2blv; the single-hop and wire-ID-collision issues described in the close comment are addressed in this rewrite.
This commit is contained in:
1 parent
ccf34adbe6
commit
a6618790bb
11 files changed
+496
-23
No files matched your search
@@ -1111,6 +1111,7 @@ void Reflector::clientDisconnected(Async::FramedTcpConnection *con,
|
||||
m_redis->clearLiveClient(client->callsign());
|
||||
}
|
||||
scheduleNodeListUpdate();
|
||||
scheduleTgInterestUpdate();
|
||||
}
|
||||
//Application::app().runTask([=]{ delete client; });
|
||||
delete client;
|
||||
@@ -1408,7 +1409,9 @@ void Reflector::udpDatagramReceived(const IpAddress& addr, uint16_t port,
|
||||
broadcastUdpMsg(msg,
|
||||
ReflectorClient::mkAndFilter(
|
||||
ReflectorClient::ExceptFilter(client),
|
||||
ReflectorClient::TgFilter(tg)));
|
||||
ReflectorClient::mkOrFilter(
|
||||
ReflectorClient::TgFilter(tg),
|
||||
ReflectorClient::TgMonitorFilter(tg))));
|
||||
if (m_is_satellite && m_satellite_client != nullptr)
|
||||
{
|
||||
m_satellite_client->onLocalAudio(tg, msg.audioData());
|
||||
@@ -1572,7 +1575,9 @@ void Reflector::onTalkerUpdated(uint32_t tg, ReflectorClient* old_talker,
|
||||
}
|
||||
broadcastUdpMsg(MsgUdpFlushSamples(),
|
||||
ReflectorClient::mkAndFilter(
|
||||
ReflectorClient::TgFilter(tg),
|
||||
ReflectorClient::mkOrFilter(
|
||||
ReflectorClient::TgFilter(tg),
|
||||
ReflectorClient::TgMonitorFilter(tg)),
|
||||
ReflectorClient::ExceptFilter(old_talker)));
|
||||
if (m_mqtt != nullptr)
|
||||
{
|
||||
@@ -2847,7 +2852,9 @@ void Reflector::onTrunkTalkerUpdated(uint32_t tg,
|
||||
ReflectorClient::TgFilter(tg),
|
||||
ReflectorClient::TgMonitorFilter(tg))));
|
||||
broadcastUdpMsg(MsgUdpFlushSamples(),
|
||||
ReflectorClient::TgFilter(tg));
|
||||
ReflectorClient::mkOrFilter(
|
||||
ReflectorClient::TgFilter(tg),
|
||||
ReflectorClient::TgMonitorFilter(tg)));
|
||||
if (m_mqtt != nullptr)
|
||||
{
|
||||
m_mqtt->onPeerTalkerStop(peer_id, tg, old_cs);
|
||||
@@ -3435,6 +3442,7 @@ void Reflector::onClientAuthenticated(const std::string& callsign,
|
||||
m_redis->pushLiveClient(callsign, ip, "", tg);
|
||||
}
|
||||
scheduleNodeListUpdate();
|
||||
scheduleTgInterestUpdate();
|
||||
} /* Reflector::onClientAuthenticated */
|
||||
|
||||
|
||||
@@ -3461,6 +3469,64 @@ void Reflector::scheduleNodeListUpdate(void)
|
||||
} /* Reflector::scheduleNodeListUpdate */
|
||||
|
||||
|
||||
void Reflector::scheduleTgInterestUpdate(void)
|
||||
{
|
||||
// Union of every connected client's selected TG and monitored TGs. tg=0
|
||||
// is the protocol sentinel "no TG selected" — never of interest. The
|
||||
// per-link debounce in TrunkLink absorbs bursts of edge triggers
|
||||
// (e.g. a client toggling its monitor list one TG at a time).
|
||||
std::set<uint32_t> local_interest;
|
||||
for (const auto& kv : m_client_con_map)
|
||||
{
|
||||
ReflectorClient* c = kv.second;
|
||||
if (c == nullptr || c->callsign().empty()) continue;
|
||||
const uint32_t tg = c->currentTG();
|
||||
if (tg != 0) local_interest.insert(tg);
|
||||
for (uint32_t mt : c->monitoredTGs())
|
||||
{
|
||||
if (mt != 0) local_interest.insert(mt);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* link : m_trunk_links)
|
||||
{
|
||||
link->scheduleTgInterestRefresh(local_interest);
|
||||
}
|
||||
} /* Reflector::scheduleTgInterestUpdate */
|
||||
|
||||
|
||||
std::set<uint32_t> Reflector::aggregatePeerInterestsForLink(
|
||||
const TrunkLink* dest) const
|
||||
{
|
||||
std::set<uint32_t> out;
|
||||
if (dest == nullptr) return out;
|
||||
|
||||
const time_t now = std::time(nullptr);
|
||||
const time_t expiry = TrunkLink::PEER_INTEREST_TIMEOUT_S;
|
||||
|
||||
for (const auto* link : m_trunk_links)
|
||||
{
|
||||
// Source-link exclusion: never advertise an interest record back to the
|
||||
// peer we learned it from. Combined with the prefix-match filter below,
|
||||
// this matches the gateway-prefix-routing rule used for audio
|
||||
// (Reflector::shouldRelayInbound + forwardTrunkAudioToOtherTrunks).
|
||||
if (link == dest) continue;
|
||||
for (const auto& kv : link->peerInterestedTGs())
|
||||
{
|
||||
const uint32_t tg = kv.first;
|
||||
const time_t ts = kv.second;
|
||||
if ((now - ts) >= expiry) continue;
|
||||
// Re-advertise toward dest only if dest's prefix table claims this TG
|
||||
// (longest-prefix-match in dest->m_remote_prefix wins, with no longer
|
||||
// match elsewhere in m_all_prefixes).
|
||||
if (!dest->isSharedTG(tg)) continue;
|
||||
out.insert(tg);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
} /* Reflector::aggregatePeerInterestsForLink */
|
||||
|
||||
|
||||
void Reflector::sendNodeListToAllPeers(void)
|
||||
{
|
||||
// 1. Local clients — sat_id stays empty (recipient-relative: "on me").
|
||||
|
||||
Reference in new issue
Block a user