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
@@ -242,6 +242,61 @@ inactivity on that TG from the peer, and is cleared immediately on trunk
|
||||
disconnect. The interest map is per-link — disconnecting one peer does not
|
||||
affect interest tracked for other peers.
|
||||
|
||||
#### Bootstrapping interest for passive monitors (`MsgPeerTgInterest`, type 129)
|
||||
|
||||
The talker-driven mechanism above only registers interest after a peer has
|
||||
actually transmitted on the TG. A node that has *selected* a TG without
|
||||
keying, or marked it in its `monitoredTGs`, would never receive any audio
|
||||
until something forced it to PTT first. To close that gap, each reflector
|
||||
periodically advertises its local interest set to its trunk peers.
|
||||
|
||||
> The same change makes UDP audio (and `MsgUdpFlushSamples`) on a TG fan
|
||||
> out to local clients monitoring it, not just the ones with that TG
|
||||
> selected — the local broadcast filter is now
|
||||
> `TgFilter ∪ TgMonitorFilter` for both client-originated audio and
|
||||
> trunk- / satellite-received audio. Without that, the protocol-level
|
||||
> interest propagation would arrive at the right reflector but stop at
|
||||
> its UDP fanout — passive monitors would still hear nothing.
|
||||
|
||||
`MsgPeerTgInterest(peer_id, tgs)` carries a list of TGs that this
|
||||
reflector's local clients have either selected (`tg`) or are monitoring
|
||||
(`monitoredTGs`), with `tg=0` excluded. The receiver writes each TG into
|
||||
its per-link `m_peer_interested_tgs` map, populating peer interest exactly
|
||||
as a `MsgPeerTalkerStart` would, but without requiring an actual
|
||||
transmission.
|
||||
|
||||
Sending is gated by `isSharedTG` for the destination link, so an interest
|
||||
record is only advertised to the peer that is the longest-prefix-match
|
||||
owner (or next hop toward the owner) for the TG. This avoids registering
|
||||
ghost interest on non-owner peers — without that filter, gateway prefix
|
||||
routing would relay an originator's own audio back through cyclic paths.
|
||||
|
||||
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.
|
||||
|
||||
Multi-hop propagation: when a reflector receives `MsgPeerTgInterest` from
|
||||
a peer P, it triggers a refresh on its other trunk links. Each other
|
||||
link's outgoing set is the union of (a) this reflector's own local
|
||||
interest and (b) interest learned from *other* peers (P excluded), with
|
||||
both filtered by `isSharedTG` for the destination. This re-advertises
|
||||
interest one prefix-route hop further toward the owner — the same shape
|
||||
as the audio gateway path (`Reflector::shouldRelayInbound`). The source
|
||||
peer is excluded so an interest record never echoes back to its
|
||||
originator.
|
||||
|
||||
Convergence and freshness: a fresh interest record is propagated within
|
||||
one debounce per hop (≤ 500 ms × hops); when a monitor stops monitoring,
|
||||
the reflector simply omits the TG from subsequent advertisements and the
|
||||
receiver-side 600 s TTL takes care of cleanup (worst-case staleness on
|
||||
disconnect ≈ 600 s — there is no explicit withdrawal message).
|
||||
|
||||
### Satellite Links — No TG Filtering
|
||||
|
||||
Satellite links (`SatelliteClient` / `SatelliteLink`) do **not** apply any TG
|
||||
|
||||
Reference in new issue
Block a user