From 69c3c2eea367d5ea5cda1fcbef30bca7d06ef73f Mon Sep 17 00:00:00 2001 From: Audric Date: Mon, 20 Apr 2026 18:55:44 +0200 Subject: [PATCH] docs: document owner-relay fanout + peer-interest TTL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit README.md: "Full-mesh topology" bullet now spells out single-hop owner-relay: a non-owner sends to the TG's owner, owner fans out to every other trunk peer with interest, no daisy-chain relay. docs/TRUNK_PROTOCOL.md: new "Owner-Relay Fanout" subsection under "TG Ownership and Routing" with the fanout model, a refA/refB/refC worked example matching test_32, scaling argument (O(N) TCP sends on the owner for N reflectors), and the peer-interest caveat. The caveat paragraph now also states the 10-minute inactivity TTL (PEER_INTEREST_TIMEOUT_S = 600), refresh-on-each-packet behavior, and immediate clear on trunk disconnect — so sysops don't have to hunt for the timeout in the code. --- README.md | 8 +++-- docs/TRUNK_PROTOCOL.md | 66 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f78920..a13231d 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,12 @@ automatically. multiple prefix groups (e.g. `LOCAL_PREFIX=11,12,13`) - **Server-to-server trunk links** — persistent TCP connections between pairs of reflectors carry talker state and audio for shared TGs -- **Full-mesh topology** — any number of reflectors can be trunked together; each - pair has a direct link so no multi-hop routing is needed +- **Full-mesh topology** — any number of reflectors can be trunked together; + every pair has a direct link. Audio distribution uses **single-hop + owner-relay**: a non-owner sends to the TG's owner, and the owner fans the + audio out to every other trunk peer with interest. No daisy-chain relaying, + so conversations on a shared TG work between clients on any two (or more) + reflectors - **Unlimited concurrent conversations** — the trunk TCP connection multiplexes all active TGs simultaneously; the only per-TG rule is one talker at a time - **Independent talker arbitration** — each reflector arbitrates its own clients; diff --git a/docs/TRUNK_PROTOCOL.md b/docs/TRUNK_PROTOCOL.md index e44446c..b8f820b 100644 --- a/docs/TRUNK_PROTOCOL.md +++ b/docs/TRUNK_PROTOCOL.md @@ -92,8 +92,70 @@ instead. In a full mesh of N reflectors, each `[TRUNK_x]` section on reflector A points at reflector B and carries only TGs whose decimal string starts with B's prefix -(`REMOTE_PREFIX`). No multi-hop routing is needed because every pair has a -direct trunk. +(`REMOTE_PREFIX`). There is never a chain of trunk relays — every peer-to-peer +hop is direct, and audio distribution across more than two reflectors is +handled by owner-relay (see below), not by daisy-chain forwarding. + +### Owner-Relay Fanout + +Prefix routing alone gets talker state and audio from a non-owner to the TG's +owner, and from the owner to its local clients. But in a mesh of 3+ +reflectors, the owner is also the only reflector that sees every non-owner's +traffic on that TG — so for every non-owner to hear every other, the owner +must fan out. + +When `TrunkLink::handleMsgTrunkTalkerStart` / `handleMsgTrunkTalkerStop` / +`handleMsgTrunkAudio` / `handleMsgTrunkFlush` runs on the reflector that +**owns** the TG (`Reflector::isLocalTG(tg)`), after the existing local +delivery the event is re-forwarded to every **other** trunk peer through the +same per-link filter (`isSharedTG` / `isClusterTG` / `isPeerInterestedTG`). +The source trunk is excluded from the fanout. + +This preserves the single-hop invariant: + +- **Non-owners** receiving trunk audio deliver to local clients and stop — + they never relay to another trunk. +- **The owner** is the one and only relay. Because the source link is + skipped, the fanout cannot echo back. + +Example (refA prefix `240`, refB prefix `262`, refC prefix `222`, mesh +trunked, a client on each of refA and refC monitoring TG `2626` which is +owned by refB): + +``` +refA client PTT on 2626 + └─► refA forwards to refB (isSharedTG) + refB broadcasts to local clients on 2626 + refB fans out to refC via refB↔refC link (isPeerInterestedTG) + └─► refC broadcasts to local clients on 2626 (no further relay) +``` + +**Scales to any mesh size.** In a mesh of N reflectors with owner B and +N−1 non-owners, when any non-owner talks: + +- sender → B directly (prefix match) +- B fans out to the other N−2 peers (source link excluded) +- each non-owner delivers locally and stops + +Complexity per audio frame on the owner is **O(N) TCP sends** — inherent to +any mesh fanout, not a new limitation. + +**Peer-interest caveat.** The owner's fanout filter checks +`isPeerInterestedTG` on each non-owner link. `m_peer_interested_tgs` is +populated when a peer emits `TrunkTalkerStart` or `TrunkAudio` on the TG +(see [Peer Interest Tracking](#peer-interest-tracking) below), so a +non-owner's client must PTT on the TG at least once before the owner knows +to forward that TG back to them. This is the same mechanism that enables +the return path in 2-reflector conversations, reused for the N−2 fanout. + +The interest entry is **refreshed on every subsequent `TrunkTalkerStart` +/ `TrunkAudio` for the same TG** and **expires after 10 minutes of +inactivity** from that peer on that TG +(`PEER_INTEREST_TIMEOUT_S = 600` in `TrunkLink.h`), or immediately when +the trunk link fully disconnects. In practice this means: during an +active QSO the fanout stays live indefinitely; on a TG that has been +silent for ~10 minutes, the first PTT from a non-owner's client re-arms +the fanout before the owner starts forwarding that TG back out. ### Cluster TGs