Re-home a short local talk group (e.g. 8) under the reflector's own owned prefix as a globally-unique number (e.g. 2620008) via a single [GLOBAL] LOCAL_ALIASES entry, so it routes across the trunk mesh like any owned TG while local users keep dialing the short number. - Config: LOCAL_ALIASES=localTG:aliasTG[/dir] (dir in|out, omitted = two-way); aliasTG must be owned by a LOCAL_PREFIX. Rejects unowned alias, an owned short side, duplicate short keys, and numeric overflow. - Boundary rewrite: prefix routing / owner-relay / peer-interest run on the long owned number; local delivery and talker arbitration run on the short number, bridged in the four inbound trunk handlers. - Rewrite-on-select folds a client that dials the long number onto the short number (select + monitor), so the two are one conversation locally and on the mesh. - Twin: external-talker notify uses the short number to match the audio mirror; disconnect cleanup folds to short so an aliased TG cannot wedge. - /status exposes local_aliases; satellite nodes warn that the setting is ignored (a local alias belongs on the mesh parent that owns the prefix). - Docs (PEER_PROTOCOL, CONCEPTS, conf template) and integration tests (tests/test_alias.py): two-way / in / out, rewrite-on-select, status, validation, disconnect-wedge, and duplicate-key coverage.
43 KiB
GeuReflector — Server-to-Server Peer Protocol
Renamed in 2026-04 (wire-format unchanged). Message types were previously called
MsgTrunk*; they are nowMsgPeer*. Wire IDs (115-122) and field layouts are identical — a renamed reflector and an old reflector interoperate identically.
Overview
GeuReflector extends SvxReflector with a server-to-server trunk protocol that allows two or more independent reflector instances to share talk groups (TGs) as simultaneous, independent voice channels — analogous to telephone trunk lines.
TGs are routed by numeric prefix: each reflector owns all TGs whose decimal
string representation starts with a configured digit string. For example, a
reflector configured with LOCAL_PREFIX=1 is authoritative for TG 1, 10, 100,
1000, 12345, 19999999, etc. This is analogous to E.164 telephone numbering
(country codes, area codes).
Multiple reflectors can be trunked together in a full mesh. Each pair of
reflectors shares one [TRUNK_x] section name on both sides. Each TG has exactly one
authoritative home reflector (the one whose prefix matches); all other
reflectors are transparent proxies for that TG.
Important: Both reflectors in a trunk link must use the same
[TRUNK_x]section name. The section name is transmitted in theMsgPeerHellohandshake and both sides must agree on it for the connection to be matched to the correctTrunkLinkinstance. The convention is to use sorted pair identifiers — for example, the link between reflector 1 and reflector 2 uses[TRUNK_1_2]on both sides.
Clients (SvxLink nodes) connect to their local reflector as normal and are
completely unaware of the trunk. When a remote talker is active on a TG whose
prefix belongs to another reflector, local clients receive a standard
MsgTalkerStart with the remote node's callsign, indistinguishable from a
local talker.
Architecture
SvxLink nodes SvxLink nodes SvxLink nodes
│ │ │
▼ ▼ ▼
Reflector 1 ◄──trunk──► Reflector 2 ◄──trunk──► Reflector 3
prefix "1" prefix "2" prefix "3"
└──────────────────────────────────────────────►┘
(full mesh)
Each reflector runs one TrunkLink instance per configured peer and a trunk
TCP server (default port 5302, configurable via TRUNK_LISTEN_PORT). Each
TrunkLink attempts an outbound connection to the peer while simultaneously
accepting inbound connections from the peer on the trunk server. Only one
connection per peer is active at a time — when both directions connect
simultaneously, a deterministic tie-break selects which connection to keep
(see Connection Conflict Resolution).
TG Ownership and Routing
A TG number belongs to the reflector whose LOCAL_PREFIX is a string prefix
of the TG's decimal representation. When multiple prefixes match (because one
prefix is itself a prefix of another), the longest matching prefix wins —
analogous to longest-prefix-match in IP routing.
| TG number | Decimal string | Owned by |
|---|---|---|
| 1 | "1" | prefix "1" |
| 10 | "10" | prefix "1" |
| 100 | "100" | prefix "1" |
| 1234567 | "1234567" | prefix "1" |
| 2 | "2" | prefix "2" |
| 25 | "25" | prefix "2" |
| 30 | "30" | prefix "3" |
Overlapping Prefixes
Prefixes may overlap — one prefix can be a prefix of another. This enables
hierarchical TG numbering schemes. For example, with prefixes "12" and
"120":
| TG number | Matches | Longest match | Owned by |
|---|---|---|---|
| 125 | "12" | "12" (len 2) | prefix "12" |
| 1205 | "12" and "120" | "120" (len 3) | prefix "120" |
| 12 | "12" | "12" (len 2) | prefix "12" |
| 1200 | "12" and "120" | "120" (len 3) | prefix "120" |
At startup, each TrunkLink receives the complete set of all prefixes in the
mesh (local + all remotes). isSharedTG(tg) finds the best matching remote
prefix for the peer, then verifies no other prefix in the mesh is a longer
match. If a longer match exists, the TG belongs to that other reflector
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). 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.
Inbound Relay (shouldRelayInbound)
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. Additionally, a reflector with two trunk legs (a gateway between meshes) needs to bridge prefix-routed traffic from one leg to the other.
TrunkLink::handleMsgPeerTalkerStart / handleMsgPeerTalkerStop /
handleMsgPeerAudio / handleMsgPeerFlush invoke
Reflector::shouldRelayInbound(tg) after local delivery to decide whether
to re-forward to other trunk peers via the same per-link filter
(isSharedTG / isClusterTG / isPeerInterestedTG). The source trunk is
always excluded from the fanout.
bool Reflector::shouldRelayInbound(uint32_t tg) const {
if (isLocalTG(tg)) return true; // owner-relay fanout
if (isClusterTG(tg)) return false; // anti-loop: cluster TGs stay single-hop
return hasPrefixRoute(tg); // gateway: have route, forward onward
}
Three regimes follow:
- Owner relay (
isLocalTG). When we own the TG, we are the one and only relay for full-mesh fanout. Source-trunk exclusion prevents echo back. - Cluster TGs. Cluster TGs received inbound on a trunk are delivered
locally and not re-forwarded to other trunks — this is deliberate.
Cluster TGs are broadcast outbound by every reflector's local clients
(the
isClusterTGbranch inonLocalAudio); transitive trunk-to-trunk relay would loop in any cyclic mesh. The recipient still checksisClusterTGon inbound to admit the frame for local delivery. - Gateway prefix routing. When we are a non-owner of the TG but
hasPrefixRoute(tg)returns true — i.e. some prefix inm_all_prefixesprefix-matches the TG — we forward onward throughonLocal*. The per-linkisSharedTGfilter (longest-prefix-match against the remote prefix) selects the unique trunk whoseREMOTE_PREFIXis the longest match, so the relay goes toward the actual owner, not in all directions.isPeerInterestedTGcovers the return leg back through the same gateway.
Loop safety holds because peer interest is populated only on direct receive
(TrunkLink.cpp:1025, 1111). In any chain X→Y→Z, Z registers Y as
interested but never X — so when audio circulates back, Y's onward fanout
finds nothing matching for X (no isSharedTG, no interest), and stops. No
TTLs, no path lists.
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. Inside a single 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 (unless it has a prefix route
into another mesh, in which case
shouldRelayInboundbridges onward — see the gateway case above)
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 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.
Routable Prefixes (ROUTABLE_PREFIXES)
Standard prefix routing requires either a direct REMOTE_PREFIX match or full-mesh
connectivity. ROUTABLE_PREFIXES (per [TRUNK_x] section, comma-separated) adds
two complementary capabilities for hierarchical and non-full-mesh topologies.
Explicit prefixes (e.g. 263) are injected into m_all_prefixes at startup
alongside LOCAL_PREFIX and all REMOTE_PREFIX values. From that point they
participate in longest-prefix-match just like native prefixes:
- Send / interest gate (
isSharedTG). When evaluating whether to forward a local talker event or audio frame on a given trunk link,isSharedTGperforms a longest-prefix-match against the remote peer's combined prefix set (itsREMOTE_PREFIXplus itsROUTABLE_PREFIXES). A TG that matches a routable prefix on that link is forwarded toward the peer as if it matchedREMOTE_PREFIX. - Interest advertisement (
MsgPeerTgInterest, type 129). The sameisSharedTGgate controls which TGs are advertised in interest messages, so a routable TG's interest reaches the next hop toward the owner without a PTT. - Inbound accept gate. On the receive side,
hasPrefixRoute(tg)is true wheneverm_all_prefixesholds a prefix that matches the TG — including routable prefixes. Combined withisOwnedTG, this covers accepting transit traffic for TGs this reflector neither owns nor has as a directREMOTE_PREFIX. - Transit (
shouldRelayInbound/hasPrefixRoute). Because the routable prefix is inm_all_prefixes,hasPrefixRoute(tg)returns true andshouldRelayInboundtriggers the gateway fanout arm, re-forwarding the frame viaonLocal*toward the actual owner. Each intermediate hop in a chain must declare the same routable prefix on its appropriate trunk; the declaration does not propagate automatically.
* wildcard is a zero-length default-route match. It is treated as the
lowest-precedence prefix — a real prefix always wins — and is never added to
m_all_prefixes. As a result:
isSharedTGadmits via a*-configured link any TG not claimed by a longer real prefix inm_all_prefixes, for local-client forwarding and interest advertisement (a real prefix always wins over the zero-length wildcard).hasPrefixRouteis not set for*-matched TGs, soshouldRelayInbounddoes not trigger the gateway arm. Wildcard-routed frames are delivered locally but never transited between trunks.- The return leg to a
*-leaf relies on peer interest: because*matches every TG in the send/interest gate, the leaf advertises interest in the TG toward the parent (MsgPeerTgInterest), and the parent'sisPeerInterestedTGcarries the return audio back. The leaf also accepts the returning audio via the wildcard match (matchesRoutable) on its inbound-accept gate — because*is never added tom_all_prefixes,hasPrefixRoutecannot serve this role, so the wildcard accept is the mechanism that lets the leaf receive the return audio.
A startup WARNING is emitted when * is set on a reflector with more than one
trunk, as that is outside the intended single-uplink leaf pattern and may produce
unexpected fanout behaviour.
Blacklist precedence. BLACKLIST_TGS is evaluated before any routable prefix
logic. A blacklisted TG is dropped before isSharedTG, hasPrefixRoute, or
interest advertisement are consulted.
Delegation note. A routable prefix more specific than this reflector's own
LOCAL_PREFIX intentionally delegates that sub-range elsewhere: longest-prefix-match
honors it and the more specific routable prefix wins. Point such a prefix at the
reflector that actually owns those TGs.
Cluster TGs
Cluster TGs bypass prefix routing entirely. A TG listed in CLUSTER_TGS is
forwarded to all trunk peers regardless of LOCAL_PREFIX or REMOTE_PREFIX.
The routing decision in TrunkLink is:
Sending: if isClusterTG(tg) or isSharedTG(tg) or isPeerInterestedTG(tg) → send to peer
Receiving: if isClusterTG(tg) or isOwnedTG(tg) → accept from peer
Otherwise: drop silently
This check is applied independently on both sides of each trunk link, using different prefix checks appropriate to each direction:
- Sending side:
TrunkLink::onLocalTalkerStart,onLocalAudio, andonLocalFlushcheckisSharedTG(tg) || isClusterTG(tg) || isPeerInterestedTG(tg)before sending.isSharedTGmatches the TG against the remote peer's prefix — i.e. it forwards TGs that belong to the peer. Additionally,isPeerInterestedTGmatches TGs that the peer has previously sent traffic for, enabling the return path for bidirectional conversations (see below). - Receiving side:
TrunkLink::handleMsgPeerTalkerStart,handleMsgPeerAudio, andhandleMsgPeerFlushcheckisOwnedTG(tg) || isClusterTG(tg)before accepting.isOwnedTGmatches the TG against both the local prefix (TG belongs to us — a peer's client is talking on one of our TGs) and the remote prefix (TG belongs to the peer — the peer is reporting its own talker state).
Each reflector owner chooses which cluster TGs to subscribe to. A reflector
only sends and accepts traffic for cluster TGs listed in its own CLUSTER_TGS.
If a cluster TG is declared on the sending reflector but not the receiving one,
the receiving side silently ignores the traffic — this is normal operation, not
a misconfiguration. Only reflectors that both subscribe to a given cluster TG
will exchange audio for it.
Peer Interest Tracking
Prefix-based routing is inherently one-directional: when a client on
reflector A visits a TG owned by reflector B, isSharedTG causes A to
forward to B. But when B's client replies on that same TG, B sees it as a
local TG and has no reason to forward back to A.
To enable the return path, each TrunkLink tracks peer interest: when
a peer sends MsgPeerTalkerStart(tg), the receiving side records that the
peer has active clients on that TG. From that point, local talker activity
on the same TG is also forwarded to the peer via isPeerInterestedTG.
Interest is refreshed on each MsgPeerAudio received for the TG (keeping
it alive during long transmissions). It expires after 10 minutes of
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.
UDP audio (and
MsgUdpFlushSamples) on a TG can now fan out to local clients monitoring it, not just the ones with that TG selected. The local broadcast filter isTgFilter ∪ (TgMonitorFilter ∩ SelectedTgIdleFilter)for client-originated audio and trunk- / satellite-received audio, whereSelectedTgIdleFilteris true iff the receiver's selected TG has no active local or trunk talker (withcurrentTG=0short-circuited to true so passive observers keep receiving). The gate keeps a busy QSO on the selected TG from being interleaved with monitor-TG UDP frames at a client whose svxlink decoder cannot demultiplex (MsgUdpAudiocarries no TG field). Without the OR arm at all, 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. 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_tgsentries 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
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
filtering. All talker signaling and audio is forwarded unconditionally in both
directions:
| Aspect | Trunk link | Satellite link |
|---|---|---|
Prefix filtering (isSharedTG/isOwnedTG) |
Yes | No |
Cluster filtering (isClusterTG) |
Yes | No |
| What is forwarded | Only prefix-matched + cluster TGs | All TGs |
CLUSTER_TGS config needed |
Yes, on both sides | No |
Connection and Handshake
Each reflector both listens for inbound trunk connections on its trunk server port (default 5302) and actively connects outbound to each configured peer. Outbound and inbound connections operate independently and can both be active at the same time. When sending, the outbound connection is preferred; if it is not ready, the inbound connection is used as fallback.
Outbound connection
When a TrunkLink connects outbound to a peer, it immediately sends
MsgPeerHello. The peer's trunk server accepts the connection, verifies the
HMAC-authenticated shared secret, matches it to the corresponding TrunkLink,
and sends its own MsgPeerHello in response.
Reflector A (prefix "1") Reflector B (prefix "2")
│──── TCP connect to B:5302 ──────────────────────────►│
│──── MsgPeerHello(id, prefix="1", priority, HMAC) ──►│
│ B verifies HMAC, matches TrunkLink
│◀─── MsgPeerHello(id, prefix="2", priority, HMAC) ───│
│ (both sides ready) │
Inbound connection
The trunk server (Reflector::m_trunk_srv) listens on the configured
TRUNK_LISTEN_PORT (default 5302). When a peer connects:
- The connection enters a pending state with a 10-second hello timeout
- The server waits for a
MsgPeerHelloframe - The shared secret is verified via HMAC against each configured
TrunkLink - On match, the connection is handed off to the corresponding
TrunkLink - The
TrunkLinkstores the inbound connection alongside any existing outbound connection
Security hardening:
- Pre-authentication frame size is limited to 4 KB (vs 32 KB post-auth)
- Maximum 5 pending (unauthenticated) connections at a time
- 10-second timeout for hello message; connections that don't authenticate are dropped
- Peer identifiers are sanitized before logging (control characters stripped, length capped at 64)
Dual Connection Model
Each TrunkLink maintains two independent connections to the peer: an outbound
connection (via TcpPrioClient) and an inbound connection (accepted by the
trunk server). Both can be active simultaneously. When sending messages, the
outbound connection is preferred; if it is not ready, the inbound connection is
used as fallback. Each connection has independent heartbeat timers.
If a second inbound connection arrives while one is already active, the new one
is rejected. Outbound reconnection is handled automatically by
TcpPrioClient.
MsgPeerHello fields
id— the config section name (e.g.TRUNK_1_2), used for logging and connection matching — both sides must use the same section namelocal_prefix— the sender's authoritative TG prefix (e.g."1")priority— random 32-bit nonce, regenerated per connection, used for talker arbitration tie-breakingnonce+digest— HMAC authentication of the shared secret
Normal Talker Flow
When a local client starts transmitting on a TG owned by the peer:
Reflector A (owns prefix "1") Reflector B (owns prefix "2")
│ SM0ABC starts on TG 25 │
│ setTalkerForTG(25, SM0ABC) │
│──── MsgPeerTalkerStart(25, "SM0ABC") ──►│
│ setTrunkTalkerForTG(25, "SM0ABC")
│ broadcast MsgTalkerStart(25, "SM0ABC") to B clients
│──── MsgPeerAudio(25, <frame>) ─►│
│ broadcast MsgUdpAudio to B TG25 clients
│ (repeats for each audio frame) │
│──── MsgPeerFlush(25) ──────────►│
│ setTalkerForTG(25, null) │
│──── MsgPeerTalkerStop(25) ─────►│
│ clearTrunkTalkerForTG(25)
│ broadcast MsgTalkerStop(25, "SM0ABC") to B clients
│ broadcast MsgUdpFlushSamples to B TG25 clients
The reverse direction (B client talking on a TG owned by A) is symmetric.
Talker Arbitration and Tie-Breaking
Each reflector arbitrates talkers independently for its own clients. The trunk adds a second layer of arbitration for shared TGs.
Normal case (one side talking at a time): the first MsgPeerTalkerStart
to arrive locks the TG on the receiving side. Local clients on that side cannot
grab the talker slot while the trunk lock is held — their audio packets are
silently dropped by the existing talker != client check in the reflector's
UDP handler.
Simultaneous claim (both sides start at the same instant): resolved using
the priority nonce exchanged in MsgPeerHello:
- The side with the lower priority value wins
- The losing side calls
setTalkerForTG(tg, nullptr)to clear its local talker, then callssetTrunkTalkerForTG(tg, peer_callsign)to accept the remote claim - The losing side suppresses the spurious
MsgPeerTalkerStopthat would otherwise be sent when the local talker is cleared (tracked viam_yielded_tgs)
Local Client Arbitration Guard
In Reflector::udpDatagramReceived(), before accepting a new local talker on a
TG that is shared with any trunk, the reflector checks whether the trunk already
holds the TG:
if ((talker == 0) && !TGHandler::instance()->hasTrunkTalker(tg))
{
TGHandler::instance()->setTalkerForTG(tg, client);
...
}
This single guard ensures that remote conversations are protected from interruption by local clients.
Keepalive / Heartbeat
Both sides send MsgPeerHeartbeat periodically to keep the TCP connection
alive and detect peer disconnection:
- TX: sent when no other message has been sent for 10 timer ticks (10 s)
- RX timeout: connection torn down if no message received for 15 ticks (15 s)
On disconnect, all trunk talker locks are immediately released so local clients
are not left blocked. The TcpPrioClient infrastructure handles automatic
reconnection.
Protocol Messages
All messages use the existing SvxReflector TCP framing: a serialized
ReflectorMsg header (containing the type field) followed by the message
payload, packed using the ASYNC_MSG_MEMBERS macro.
| Type | Name | Fields |
|---|---|---|
| 115 | MsgPeerHello |
string id, string local_prefix, uint32 priority, uint8[] nonce, uint8[] hmac, uint8 role |
| 116 | MsgPeerTalkerStart |
uint32 tg, string callsign |
| 117 | MsgPeerTalkerStop |
uint32 tg |
| 118 | MsgPeerAudio |
uint32 tg, uint8[] audio |
| 119 | MsgPeerFlush |
uint32 tg |
| 120 | MsgPeerHeartbeat |
(no fields) |
| 121 | MsgPeerNodeList |
string[] callsigns, uint32[] tgs, float[] lats, float[] lons, string[] qth_names, string[] status_blobs, string[] sat_ids |
| 122 | MsgPeerFilter |
string filter (shared-syntax TG filter: exact / 24* / 10-20, comma-separated) |
Type numbers 115–120 are chosen to follow the last existing SvxReflector TCP
message type (114 = MsgStartUdpEncryption) without collision. Types 121–122
were added by the jayReflector integration (v1.1.0) and are optional —
older peers silently ignore unknown message types, preserving backward
compatibility.
MsgPeerClient* — per-client liveness deltas (types 125–128)
Types 123–124 are reserved for MsgTwinExt* (twin-only talker extensions).
Types 125–128 carry per-client liveness deltas for satellite and twin links.
| Type | Name | Fields |
|---|---|---|
| 125 | MsgPeerClientConnected |
string callsign, uint32 tg, string ip |
| 126 | MsgPeerClientDisconnected |
string callsign |
| 127 | MsgPeerClientRx |
string callsign, string rx_json |
| 128 | MsgPeerClientStatus |
string callsign, string status_json |
Routing: these types are emitted only over SatelliteLink, SatelliteClient,
and TwinLink. TrunkLink does not emit them. The wire format is general, so
future trunk-axis enablement is purely additive.
MsgPeerClientConnected (125): sent when a local client successfully
authenticates. tg is the client's initial talk group; ip is the client's
remote address. Receiver republishes to MQTT peer/{peer_id}/client/{callsign}/connected.
MsgPeerClientDisconnected (126): sent on client disconnect. Receiver
republishes to MQTT peer/{peer_id}/client/{callsign}/disconnected.
MsgPeerClientRx (127): sent on rx-status changes. rx_json is a
JSON-serialized receiver map (same schema as client/{callsign}/rx), capped
at 64 KiB on receive (matching MsgPeerNodeList status-blob cap). The sender
debounces per callsign at 500 ms to limit rate. Receiver publishes as a
retained MQTT topic.
MsgPeerClientStatus (128): sent on per-client status changes.
status_json is the same rich per-client blob that appears in
MsgPeerNodeList::status_blobs, capped at 64 KiB. Receiver publishes as a
retained MQTT topic.
TG filter interaction. If the receiver has advertised a MsgPeerFilter
(e.g. a satellite with SATELLITE_FILTER), the sender checks the originating
client's current TG against that filter before emitting any MsgPeerClient*
message. Clients on filtered-out TGs produce no delta traffic toward that peer.
Backward compatibility. All three peer-protocol dispatch sites
(SatelliteLink, SatelliteClient, TwinLink) have graceful unknown-type
fall-through — unrecognised frames are silently ignored (heartbeat reset
happens before dispatch, so unknown frames count as keepalive). An old peer
receiving these types ignores them and falls back to the existing
MsgPeerNodeList snapshot mechanism.
MsgPeerNodeList is emitted by the reflector on local client login, logout,
or TG change, debounced to 500 ms, and broadcast to every trunk peer. Peers
republish it via MQTT under nodes/<peer_id> so a central dashboard can see
who is connected to each reflector.
On ingest the receiver applies that link's per-trunk TG filter
(BLACKLIST_TGS / ALLOW_TGS) to every entry, using the same match as the
audio/talker receive gate (isBlacklisted(tg) || isBlacklisted(mapTgIn(tg)) || !isAllowed(tg), so TG_MAP translation is honoured). A node whose
selected TG is blacklisted or outside ALLOW_TGS is dropped from the roster
entirely, so it never appears under /status.trunks[<section>].nodes, MQTT
nodes/<peer_id>, or the Redis mirror — a filtered TG's roster is trimmed on
this link just like its audio, even though the full snapshot is sent on the
wire. (Satellite links filter on the send side via SATELLITE_FILTER; trunk
links have no roster filtering on send, so the trim happens on receive.) The
same gate is then applied to each kept entry's monitoredTGs array inside the
status blob (see below), so a node retained because its selected TG is
permitted cannot surface filtered TGs it is only monitoring.
The optional status_blobs[i] field carries the source reflector's
m_status["nodes"][callsign] JSON serialised verbatim — the same rich
per-client status that local clients expose (rx/tx config, qth array,
monitoredTGs, restrictedTG, protoVer, ...). Receivers parse and recursively
sanitise it (depth/length caps, control-char strip) before surfacing it
under /status.trunks[<section>].nodes[i], MQTT nodes/<peer_id>, and
the status field of Redis hash live:peer_node:<peer_id>:<callsign>.
The isTalker flag on each peer node is not carried in the blob (it
would be stale by the time it arrives); it is derived on the receive side
from the live trunk-talker map maintained by MsgPeerTalkerStart /
MsgPeerTalkerStop.
The optional sat_ids[i] field tags each entry with the satellite that
the client is actually attached to. Interpretation is recipient-relative:
an empty string means "on whoever sent this list", and a non-empty value
identifies a satellite hanging off the sender. The field exists so a parent
reflector can advertise both its own clients (sat_id="") and clients
learned from each connected satellite (sat_id=<satellite_id>) in a single
message, while letting the recipient distinguish them in /status and
Redis. Receivers preserve sat_id verbatim under
/status.trunks[<section>].nodes[i].sat_id (and /status.twin.nodes[i].sat_id
on twin links).
Wire-format note: type 121 has been extended twice since its initial
shipment. Each addition is a hard lockstep change (Async-msg unpack
expects an exact vector count): first status_blobs (raising the count
from 5 to 6), then sat_ids (raising it to 7). A peer running an older
fork build that knows type 121 but expects fewer vectors will fail to
unpack and reject the message, which silently empties the partner roster
on that peer until it is upgraded. All trunk, twin, and satellite peers
in a mesh must be upgraded together. Peers that don't know type 121 at
all (pre-jayReflector) keep ignoring it as before.
Node-list flow with multiple satellites
When a parent reflector has two or more satellites (S1, S2) attached, each participant is given a single shared view of the mesh roster:
- Parent → trunks/twin: sends parent-local clients (
sat_id="") merged with every connected satellite's contribution (sat_id=<sat_id>). - Parent → satellite Si: sends parent-local + every other
satellite's contribution; Si's own roster is excluded
(self-echo guard). The list is additionally filtered by
Si's
SATELLITE_FILTERif any. - Satellite → parent: sends the satellite's local clients only, with
sat_id=""on the wire. The parent stamps each ingested entry withsat_id=<satellite_id>so subsequent fanouts attribute correctly.
Result: every reflector and every satellite shows the same set of callsigns
in its /status, with each entry tagged so consumers can tell where it
physically lives. Re-broadcasts are debounced (500 ms) and triggered by:
local client login/logout/TG change, satellite hello completion, and
inbound satellite node-list updates.
MsgPeerFilter is used by satellite links to advertise TG interest to the
parent. A satellite with SATELLITE_FILTER set sends one MsgPeerFilter
right after authenticating; the parent stores the filter and skips forwarding
non-matching TGs to that satellite. Absent or empty filter means pass-all
(pre-existing behavior). Trunk peers do not emit it.
Audio is transported over TCP (not UDP) — the trunk is a reliable server-to-server link, not a lossy radio gateway path, so TCP framing is appropriate and avoids the complexity of a separate UDP cipher channel.
TGHandler Changes
Trunk talker state is stored separately from the ReflectorClient* talker
pointer in TGHandler, in a parallel std::map<uint32_t, std::string> keyed
by TG number. This avoids any refactoring of the existing ReflectorClient
type hierarchy.
New methods:
setTrunkTalkerForTG(tg, callsign)— lock TG, emittrunkTalkerUpdatedsignalclearTrunkTalkerForTG(tg)— release lock on one TGclearAllTrunkTalkers()— release all locks (used on disconnect)trunkTalkerForTG(tg)— returns callsign or""if nonehasTrunkTalker(tg)— returns bool, used in arbitration guardtrunkTalkersSnapshot()— returns const ref to the map (for HTTP status)
New signal:
trunkTalkerUpdated(tg, old_callsign, new_callsign)— connected toReflector::onTrunkTalkerUpdated()which broadcastsMsgTalkerStart/Stopto local clients with the correct remote callsign
HTTP Status
The /status JSON endpoint includes a trunks object alongside nodes:
{
"nodes": { ... },
"trunks": {
"TRUNK_1_2": {
"host": "reflector-b.example.com",
"port": 5302,
"connected": true,
"local_prefix": "1",
"remote_prefix": "2",
"active_talkers": {
"25": "SM0ABC",
"200": "LA8PV"
}
}
},
"local_aliases": {
"8": { "alias": 2620008, "direction": "two-way" }
}
}
active_talkers contains only TGs with an active remote talker at the moment
of the request. It is empty when no trunk conversations are in progress.
local_aliases is keyed by the short local TG and lists every configured
LOCAL_ALIASES entry: alias is the long, mesh-routable number it is
re-homed under, and direction is "two-way", "in", or "out" (see
"Local aliases" below). Note that this is the local view — active_talkers
above (and MQTT/Redis mirrors of it) report the long mesh number for aliased
traffic, since that is the identity used for routing, while local clients
experience the short number.
Configuration
Global setting (both reflectors)
Add LOCAL_PREFIX to the [GLOBAL] section. This declares which TG prefix
this reflector is authoritative for. TRUNK_LISTEN_PORT sets the TCP port
the trunk server listens on (default 5302):
[GLOBAL]
...
LOCAL_PREFIX=1 # this reflector owns TGs 1, 10, 100, 1000, ...
TRUNK_LISTEN_PORT=5302 # trunk server port (default 5302, optional)
Per-trunk section
Add one [TRUNK_x] section per peer. Both reflectors in a link must use the
same section name — the name is exchanged during the handshake and used to
match connections. The convention is to use sorted pair identifiers (e.g.
[TRUNK_1_2] for the link between reflector 1 and reflector 2).
REMOTE_PREFIX declares which TG prefix the peer owns:
[TRUNK_1_2]
HOST=reflector-b.example.com # peer hostname or IP
PORT=5302 # peer trunk port (default 5302)
SECRET=change_this_secret # shared secret
REMOTE_PREFIX=2 # peer owns TGs 2, 20, 200, 2000, ...
Full-mesh example (three reflectors)
Reflector 1 (LOCAL_PREFIX=1):
[TRUNK_1_2]
HOST=reflector-b.example.com
SECRET=secret_ab
REMOTE_PREFIX=2
[TRUNK_1_3]
HOST=reflector-c.example.com
SECRET=secret_ac
REMOTE_PREFIX=3
Reflector 2 (LOCAL_PREFIX=2):
[TRUNK_1_2]
HOST=reflector-a.example.com
SECRET=secret_ab
REMOTE_PREFIX=1
[TRUNK_2_3]
HOST=reflector-c.example.com
SECRET=secret_bc
REMOTE_PREFIX=3
Reflector 3 (LOCAL_PREFIX=3):
[TRUNK_1_3]
HOST=reflector-a.example.com
SECRET=secret_ac
REMOTE_PREFIX=1
[TRUNK_2_3]
HOST=reflector-b.example.com
SECRET=secret_bc
REMOTE_PREFIX=2
Local aliases
LOCAL_ALIASES (in [GLOBAL]) re-homes a short local TG under one of this
reflector's own LOCAL_PREFIX values, so it gets a globally-unique number
reachable from anywhere in the mesh while local users keep dialing the short
number:
[GLOBAL]
LOCAL_PREFIX=262
LOCAL_ALIASES=8:2620008,9:2620009/out,4001:2620400/in
Syntax. Comma-separated entries of the form localTG:aliasTG[/dir].
dir is in or out; when omitted the alias is two-way.
Ownership rule. aliasTG must fall under one of this reflector's
LOCAL_PREFIX values (checked with the same longest-prefix match used for
TG ownership everywhere else). An entry whose aliasTG is not owned is
rejected at config load — logged as an error and skipped — so a typo can
never claim a number the reflector doesn't own; the reflector still starts
and the remaining valid entries take effect.
Direction semantics.
- two-way (no suffix): talk on the short local TG is exported to the mesh under the long number, and traffic arriving from the mesh on the long number is delivered to local clients on the short number.
/out: local talk is exported to the mesh under the long number, but inbound mesh traffic on the long number is not folded back to the short number — the alias is publish-only./in: mesh traffic on the long number is delivered locally on the short number, but the short number is not exported to the mesh — the alias is listen-only.
Rewrite-on-select. A client — local or remote — that dials the long
alias number directly is folded onto the short number as soon as it
selects or monitors that TG, so 8 and 2620008 are always the same
conversation locally; there is no way to end up split across both numbers
on this reflector.
Routing on long, delivery on short. The alias is a translation applied
at the local-client / trunk-mesh boundary, not a rename. All prefix
routing, owner-relay fan-out, and peer-interest bookkeeping run on the
long number, because that is the identity the rest of the mesh sees and
uses for longest-prefix-match. All local delivery and talker arbitration
(which client currently holds the TG, PTT interruption, monitor filters,
mute) run on the short number, because that is what local clients
select and expect to see. One documented consequence: /status.local_aliases
(above) is the local, short-keyed view of the mapping, but
/status.active_talkers in a trunk's status block — and the equivalent
MQTT/Redis mirrors — report the long mesh number while local clients are
simultaneously experiencing the short number for the same transmission.
This is intentional: it reflects the two identities (mesh-routing vs.
local-delivery) the alias deliberately keeps separate.
Files Changed vs Upstream SvxLink
| File | Change |
|---|---|
src/svxlink/reflector/ReflectorMsg.h |
Added MsgPeerHello–MsgPeerHeartbeat (types 115–120); MsgPeerHello carries local_prefix string instead of TG list. Added MsgPeerClientConnected–MsgPeerClientStatus (types 125–128) and MsgPeerTgInterest (type 129). Renamed from MsgTrunk* (wire IDs unchanged). |
src/svxlink/reflector/TGHandler.h |
Added trunk talker map, 5 methods + snapshot accessor, trunkTalkerUpdated signal |
src/svxlink/reflector/TGHandler.cpp |
Implemented trunk talker methods including clearAllTrunkTalkers |
src/svxlink/reflector/Reflector.h |
Added m_trunk_links, m_trunk_srv, initTrunkLinks(), initTrunkServer(), onTrunkTalkerUpdated(), trunk inbound connection handling |
src/svxlink/reflector/Reflector.cpp |
Wired trunk init, trunk server (listen + accept + auth), signals, audio relay, arbitration guard, HTTP status |
src/svxlink/reflector/TrunkLink.h |
New — TrunkLink class declaration |
src/svxlink/reflector/TrunkLink.cpp |
New — full trunk link implementation |
src/svxlink/reflector/SatelliteLink.h |
New — SatelliteLink class declaration |
src/svxlink/reflector/SatelliteLink.cpp |
New — satellite link implementation (parent side) |
src/svxlink/reflector/SatelliteClient.h |
New — SatelliteClient class declaration |
src/svxlink/reflector/SatelliteClient.cpp |
New — satellite client implementation (satellite side) |
src/svxlink/reflector/CMakeLists.txt |
Added TrunkLink.cpp to sources |
src/svxlink/reflector/svxreflector.conf.in |
Added prefix-based trunk example config |
src/versions |
Version bumped to 1.3.99.12+trunk1 |
src/svxlink/reflector/svxreflector.cpp |
Updated startup banner |