Implement cluster TGs and /config HTTP endpoint
Cluster TGs (BrandMeister-style): talk groups broadcast to all trunk peers regardless of prefix ownership. Configured via CLUSTER_TGS in [GLOBAL]. Routing checks in TrunkLink now accept isSharedTG || isClusterTG for all 8 inbound/outbound handlers. Validated at startup to not overlap with any LOCAL_PREFIX or REMOTE_PREFIX. New GET /config endpoint returns static configuration (local_prefix, cluster_tgs, listen_port, http_port, trunk peers) for dashboard use. Docs: cluster TG sections added to README, DEPLOYMENT_ITALY, and Italian translation. Design doc for satellite reflectors and cluster TGs added.
This commit is contained in:
1 parent
e26b932223
commit
166e57f445
8 files changed
+647
-17
No files matched your search
@@ -102,7 +102,21 @@ LOCAL_PREFIX=1 # owns TGs 1, 10, 100, 1000, ...
|
|||||||
# LOCAL_PREFIX=11,12,13 # multiple prefixes on one instance
|
# LOCAL_PREFIX=11,12,13 # multiple prefixes on one instance
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Add a trunk section per peer
|
### 2. Cluster TGs (optional)
|
||||||
|
|
||||||
|
Cluster TGs are broadcast to **all** trunk peers regardless of prefix ownership,
|
||||||
|
like BrandMeister's nationwide talk groups. Any reflector can originate a
|
||||||
|
transmission on a cluster TG and all other reflectors in the mesh will hear it.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[GLOBAL]
|
||||||
|
CLUSTER_TGS=222,2221,91 # comma-separated list of cluster TG numbers
|
||||||
|
```
|
||||||
|
|
||||||
|
All reflectors in the mesh should list the same cluster TGs. Cluster TG numbers
|
||||||
|
must not overlap with any `LOCAL_PREFIX` or `REMOTE_PREFIX`.
|
||||||
|
|
||||||
|
### 3. Add a trunk section per peer
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[TRUNK_2]
|
[TRUNK_2]
|
||||||
@@ -171,13 +185,16 @@ Both sides of each trunk must point at each other and share the same `SECRET`.
|
|||||||
|
|
||||||
## HTTP Status
|
## HTTP Status
|
||||||
|
|
||||||
Enable with `HTTP_SRV_PORT=8080` in `[GLOBAL]`. The `/status` endpoint returns
|
Enable with `HTTP_SRV_PORT=8080` in `[GLOBAL]`. Two endpoints are available:
|
||||||
JSON that now includes a `trunks` key. `local_prefix` and `remote_prefix` are
|
|
||||||
returned as arrays to reflect multi-prefix support:
|
### `GET /status` — live state
|
||||||
|
|
||||||
|
Returns nodes, trunk connection state, and active talkers:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"nodes": { ... },
|
"nodes": { ... },
|
||||||
|
"cluster_tgs": [222, 2221, 91],
|
||||||
"trunks": {
|
"trunks": {
|
||||||
"TRUNK_2": {
|
"TRUNK_2": {
|
||||||
"host": "reflector-b.example.com",
|
"host": "reflector-b.example.com",
|
||||||
@@ -186,15 +203,36 @@ returned as arrays to reflect multi-prefix support:
|
|||||||
"local_prefix": ["1"],
|
"local_prefix": ["1"],
|
||||||
"remote_prefix": ["2"],
|
"remote_prefix": ["2"],
|
||||||
"active_talkers": {
|
"active_talkers": {
|
||||||
"25": "SM0ABC",
|
"222": "IW1GEU",
|
||||||
"200": "LA8PV"
|
"25": "SM0ABC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`active_talkers` lists only TGs with an active remote talker at query time.
|
`active_talkers` lists TGs with an active remote talker at query time (both
|
||||||
|
prefix-based and cluster TGs).
|
||||||
|
|
||||||
|
### `GET /config` — static configuration
|
||||||
|
|
||||||
|
Returns the reflector's own configuration, useful for dashboards:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"local_prefix": ["1"],
|
||||||
|
"cluster_tgs": [222, 2221, 91],
|
||||||
|
"listen_port": "5300",
|
||||||
|
"http_port": "8080",
|
||||||
|
"trunks": {
|
||||||
|
"TRUNK_2": {
|
||||||
|
"host": "reflector-b.example.com",
|
||||||
|
"port": 5302,
|
||||||
|
"remote_prefix": ["2"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ IT_84_91 # MOLISE ↔ SICILIA
|
|||||||
[GLOBAL]
|
[GLOBAL]
|
||||||
LISTEN_PORT=5300
|
LISTEN_PORT=5300
|
||||||
LOCAL_PREFIX=01
|
LOCAL_PREFIX=01
|
||||||
|
CLUSTER_TGS=222
|
||||||
HTTP_SRV_PORT=8080
|
HTTP_SRV_PORT=8080
|
||||||
COMMAND_PTY=/dev/shm/reflector_ctrl
|
COMMAND_PTY=/dev/shm/reflector_ctrl
|
||||||
|
|
||||||
@@ -242,6 +243,27 @@ region's 2-digit code and add one `[TRUNK_xx]` section for each of the other
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Cluster TGs
|
||||||
|
|
||||||
|
The `CLUSTER_TGS` setting enables nationwide talk groups that are broadcast to
|
||||||
|
**all** trunk peers regardless of prefix ownership. In this deployment, TG 222
|
||||||
|
(the Italian national call channel in DMR numbering) is configured as a cluster
|
||||||
|
TG on every reflector:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
CLUSTER_TGS=222
|
||||||
|
```
|
||||||
|
|
||||||
|
When any client on any regional reflector keys up on TG 222, the audio is sent
|
||||||
|
to all 19 other reflectors simultaneously. Unlike prefix-based TGs (which route
|
||||||
|
to a single owning reflector), cluster TGs have no owner — any reflector can
|
||||||
|
originate a transmission. Talker arbitration works the same way (nonce
|
||||||
|
tie-break) if two operators key up simultaneously.
|
||||||
|
|
||||||
|
All reflectors in the mesh must list the same `CLUSTER_TGS` value.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Concurrent conversations
|
## Concurrent conversations
|
||||||
|
|
||||||
There is **no hardcoded limit** on concurrent QSOs over the trunk. The trunk
|
There is **no hardcoded limit** on concurrent QSOs over the trunk. The trunk
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ IT_84_91 # MOLISE ↔ SICILIA
|
|||||||
[GLOBAL]
|
[GLOBAL]
|
||||||
LISTEN_PORT=5300
|
LISTEN_PORT=5300
|
||||||
LOCAL_PREFIX=01
|
LOCAL_PREFIX=01
|
||||||
|
CLUSTER_TGS=222
|
||||||
HTTP_SRV_PORT=8080
|
HTTP_SRV_PORT=8080
|
||||||
COMMAND_PTY=/dev/shm/reflector_ctrl
|
COMMAND_PTY=/dev/shm/reflector_ctrl
|
||||||
|
|
||||||
@@ -246,6 +247,30 @@ secondo la convenzione sopra indicata.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## TG Cluster
|
||||||
|
|
||||||
|
L'impostazione `CLUSTER_TGS` abilita i talk group nazionali che vengono
|
||||||
|
trasmessi a **tutti** i peer trunk indipendentemente dalla proprietà del
|
||||||
|
prefisso. In questo deployment, il TG 222 (il canale di chiamata nazionale
|
||||||
|
italiano nella numerazione DMR) è configurato come TG cluster su ogni
|
||||||
|
reflector:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
CLUSTER_TGS=222
|
||||||
|
```
|
||||||
|
|
||||||
|
Quando un qualsiasi client su un qualsiasi reflector regionale trasmette sul
|
||||||
|
TG 222, l'audio viene inviato a tutti gli altri 19 reflector simultaneamente.
|
||||||
|
A differenza dei TG basati su prefisso (che instradano verso un singolo
|
||||||
|
reflector proprietario), i TG cluster non hanno proprietario — qualsiasi
|
||||||
|
reflector può originare una trasmissione. L'arbitraggio del talker funziona
|
||||||
|
allo stesso modo (tie-break tramite nonce) se due operatori trasmettono
|
||||||
|
contemporaneamente.
|
||||||
|
|
||||||
|
Tutti i reflector nella mesh devono avere lo stesso valore di `CLUSTER_TGS`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Conversazioni simultanee
|
## Conversazioni simultanee
|
||||||
|
|
||||||
Non esiste **nessun limite fisso** al numero di QSO simultanei sul trunk. Il trunk
|
Non esiste **nessun limite fisso** al numero di QSO simultanei sul trunk. Il trunk
|
||||||
|
|||||||
@@ -0,0 +1,387 @@
|
|||||||
|
# Design: Regional Satellites & Nationwide Cluster TGs
|
||||||
|
|
||||||
|
Two proposed extensions to GeuReflector's trunk architecture. Each can be
|
||||||
|
implemented independently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Regional Satellite Reflectors
|
||||||
|
|
||||||
|
### Problem
|
||||||
|
|
||||||
|
Full mesh works well for 5-10 reflectors but scales as N*(N-1)/2 connections.
|
||||||
|
Italy's 20-region deployment already needs 190 trunk links. A country with 50
|
||||||
|
regions would need 1225. Worse, many small regions don't justify the operational
|
||||||
|
overhead of managing 49 trunk peer configurations.
|
||||||
|
|
||||||
|
### Concept
|
||||||
|
|
||||||
|
A **satellite** is a lightweight reflector instance that connects to a single
|
||||||
|
parent reflector instead of joining the full mesh. Clients connect to the
|
||||||
|
satellite normally; the satellite relays everything to its parent. The parent
|
||||||
|
reflector is unchanged — it still participates in the trunk mesh as before, and
|
||||||
|
additionally accepts inbound satellite connections.
|
||||||
|
|
||||||
|
```
|
||||||
|
┌──────── Nationwide full mesh (unchanged) ────────┐
|
||||||
|
│ │
|
||||||
|
┌─────┴─────┐ ┌─────┴─────┐
|
||||||
|
│ Refl. 01 │◄── trunk ──────────────────────────►│ Refl. 02 │
|
||||||
|
└─────┬─────┘ └───────────┘
|
||||||
|
┌────────┼────────┐
|
||||||
|
▼ ▼ ▼
|
||||||
|
Sat 01a Sat 01b Sat 01c (satellites of Reflector 01)
|
||||||
|
│ │ │
|
||||||
|
clients clients clients
|
||||||
|
```
|
||||||
|
|
||||||
|
Satellites are transparent to the rest of the mesh — remote reflectors see
|
||||||
|
satellite clients as if they were connected directly to the parent.
|
||||||
|
|
||||||
|
### Config changes
|
||||||
|
|
||||||
|
On the **parent reflector** (existing reflector, no role change needed):
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[GLOBAL]
|
||||||
|
LOCAL_PREFIX=01
|
||||||
|
|
||||||
|
# Existing trunk config unchanged
|
||||||
|
[TRUNK_02]
|
||||||
|
HOST=reflector-02.example.com
|
||||||
|
SECRET=secret_01_02
|
||||||
|
REMOTE_PREFIX=02
|
||||||
|
|
||||||
|
# NEW: accept satellite connections
|
||||||
|
[SATELLITE]
|
||||||
|
LISTEN_PORT=5303
|
||||||
|
SECRET=regional_satellite_secret
|
||||||
|
```
|
||||||
|
|
||||||
|
On the **satellite**:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[GLOBAL]
|
||||||
|
SATELLITE_OF=reflector-01.example.com
|
||||||
|
SATELLITE_PORT=5303
|
||||||
|
SATELLITE_SECRET=regional_satellite_secret
|
||||||
|
```
|
||||||
|
|
||||||
|
A satellite does **not** set `LOCAL_PREFIX`, `REMOTE_PREFIX`, or any
|
||||||
|
`[TRUNK_x]` sections. It inherits its parent's prefix identity. It does not
|
||||||
|
connect to other reflectors or other satellites.
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
|
||||||
|
#### New class: `SatelliteLink`
|
||||||
|
|
||||||
|
Similar to `TrunkLink` but with different semantics:
|
||||||
|
|
||||||
|
| Aspect | TrunkLink (peer-to-peer) | SatelliteLink |
|
||||||
|
|--------|-------------------------|---------------|
|
||||||
|
| Topology | Symmetric mesh peers | Asymmetric — parent is authority |
|
||||||
|
| TG routing | Prefix-based (`isSharedTG`) | **All TGs** — satellite proxies everything |
|
||||||
|
| Talker arbitration | Nonce tie-break | Parent always wins |
|
||||||
|
| Who initiates | Both sides connect to each other | Satellite connects to parent |
|
||||||
|
| Audio path | Only shared-prefix TGs | All TGs active on either side |
|
||||||
|
|
||||||
|
#### Parent-side changes (`Reflector.cpp`)
|
||||||
|
|
||||||
|
1. **New TCP server** on the satellite port (5303), separate from the client
|
||||||
|
server (5300) and trunk mesh (5302).
|
||||||
|
|
||||||
|
2. **`SatelliteLink` instances** created for each inbound satellite connection
|
||||||
|
(dynamically on accept, like `ReflectorClient`).
|
||||||
|
|
||||||
|
3. **Audio forwarding**: when a local client or trunk peer starts talking on any
|
||||||
|
TG, the parent also sends `MsgTrunkTalkerStart` + `MsgTrunkAudio` to all
|
||||||
|
connected satellites. When a satellite client talks, the parent treats it
|
||||||
|
identically to a local client — forwards to trunk peers via `isSharedTG` as
|
||||||
|
normal.
|
||||||
|
|
||||||
|
4. **TGHandler**: satellite talkers are registered as regular local talkers (the
|
||||||
|
satellite is transparent). The parent's `TGHandler` sees them as
|
||||||
|
`ReflectorClient` objects proxied through the satellite.
|
||||||
|
|
||||||
|
#### Satellite-side changes
|
||||||
|
|
||||||
|
The satellite is a **thin relay**:
|
||||||
|
|
||||||
|
1. Clients connect to it on port 5300 as normal.
|
||||||
|
2. All talker events and audio are forwarded to the parent over the satellite
|
||||||
|
connection.
|
||||||
|
3. All talker events and audio received from the parent are broadcast to local
|
||||||
|
clients.
|
||||||
|
4. No `TGHandler` prefix logic — the satellite doesn't decide TG ownership.
|
||||||
|
|
||||||
|
#### Wire protocol
|
||||||
|
|
||||||
|
Reuse the existing trunk message types (115-120). The satellite handshake
|
||||||
|
(`MsgTrunkHello`) includes a flag field so the parent knows to treat the
|
||||||
|
connection as a satellite rather than a mesh peer.
|
||||||
|
|
||||||
|
Add one field to `MsgTrunkHello`:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
uint8_t m_role; // 0 = PEER (default, backward-compatible), 1 = SATELLITE
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Key files to modify
|
||||||
|
|
||||||
|
| File | Change |
|
||||||
|
|------|--------|
|
||||||
|
| `Reflector.cpp` | Add satellite TCP server, accept satellite connections |
|
||||||
|
| `SatelliteLink.cpp` (new) | Parent-side satellite connection handler |
|
||||||
|
| `SatelliteClient.cpp` (new) | Satellite-side parent connection + local relay |
|
||||||
|
| `ReflectorMsg.h` | Add `m_role` to `MsgTrunkHello` |
|
||||||
|
| `TrunkLink.cpp` | No changes — mesh unchanged |
|
||||||
|
| `svxreflector.conf.in` | Add `[SATELLITE]`, `SATELLITE_OF` settings |
|
||||||
|
|
||||||
|
#### Failure modes
|
||||||
|
|
||||||
|
- **Satellite loses parent connection**: local clients stay connected but can't
|
||||||
|
reach other regions or other clients on the parent. Satellite retries
|
||||||
|
automatically (same as TrunkLink reconnect logic).
|
||||||
|
- **Parent goes down**: all its satellites are isolated. Other reflectors in the
|
||||||
|
mesh see the parent's trunk links drop — same as today.
|
||||||
|
- **Satellite is optional**: a region with only a few nodes doesn't need
|
||||||
|
satellites. Zero overhead when not used.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Nationwide Cluster TGs (BrandMeister-style)
|
||||||
|
|
||||||
|
### Problem
|
||||||
|
|
||||||
|
The current prefix model means every TG is **owned by exactly one reflector**.
|
||||||
|
TG 22201 belongs to whoever owns prefix `01`. This works well for regional TGs
|
||||||
|
but doesn't support the BrandMeister "cluster TG" pattern — a talk group that
|
||||||
|
is **shared equally by all reflectors** with no single owner, where keying up
|
||||||
|
on any reflector is heard on every other reflector.
|
||||||
|
|
||||||
|
Examples from BrandMeister:
|
||||||
|
|
||||||
|
- TG 91 = Worldwide cluster
|
||||||
|
- TG 222 = Italy nationwide cluster
|
||||||
|
- TG 2221 = North Italy cluster
|
||||||
|
|
||||||
|
### Concept
|
||||||
|
|
||||||
|
Add a **cluster TG** category that bypasses prefix routing. When a client keys
|
||||||
|
up on a cluster TG at any reflector, that reflector broadcasts the audio to
|
||||||
|
**all** trunk peers, regardless of prefix ownership. Any reflector can originate
|
||||||
|
a cluster TG transmission.
|
||||||
|
|
||||||
|
```
|
||||||
|
Reflector 01 Reflector 02 Reflector 03
|
||||||
|
┌──────────┐ ┌──────────┐ ┌──────────┐
|
||||||
|
│ Client A │ │ Client B │ │ Client C │
|
||||||
|
│ TG 222 │ │ TG 222 │ │ TG 222 │
|
||||||
|
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
||||||
|
│ ◄── cluster broadcast ──► │
|
||||||
|
└──────────────── all hear A ────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
Compared to prefix-based TGs:
|
||||||
|
|
||||||
|
| Aspect | Prefix TG (e.g. 22201) | Cluster TG (e.g. 222) |
|
||||||
|
|--------|----------------------|------------------------|
|
||||||
|
| Owner | Single reflector (prefix `01`) | None — shared by all |
|
||||||
|
| Routing | Only to/from owner's trunk peer | Broadcast to all trunk peers |
|
||||||
|
| Who can originate | Any client, but routed through owner | Any client, handled locally |
|
||||||
|
| Arbitration | Nonce tie-break between 2 peers | Nonce tie-break between all peers |
|
||||||
|
|
||||||
|
### Config changes
|
||||||
|
|
||||||
|
New `[GLOBAL]` key `CLUSTER_TGS`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[GLOBAL]
|
||||||
|
LOCAL_PREFIX=01
|
||||||
|
# Cluster TGs: broadcast to all trunk peers regardless of prefix
|
||||||
|
# Comma-separated list of individual TGs
|
||||||
|
CLUSTER_TGS=222,2221,2222,91
|
||||||
|
```
|
||||||
|
|
||||||
|
All reflectors in the mesh must list the same cluster TG set. A TG number
|
||||||
|
cannot be both a cluster TG and match a `LOCAL_PREFIX`/`REMOTE_PREFIX`.
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
|
||||||
|
#### TG classification (`TrunkLink.cpp` / new helper)
|
||||||
|
|
||||||
|
Today, `isSharedTG()` checks if a TG matches the remote peer's prefix. Add a
|
||||||
|
parallel check:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// In Reflector or a shared utility
|
||||||
|
bool isClusterTG(uint32_t tg) const
|
||||||
|
{
|
||||||
|
return m_cluster_tgs.count(tg) > 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Modify the routing decision from:
|
||||||
|
|
||||||
|
```
|
||||||
|
if isSharedTG(tg) → send to that specific peer
|
||||||
|
```
|
||||||
|
|
||||||
|
to:
|
||||||
|
|
||||||
|
```
|
||||||
|
if isClusterTG(tg) → send to ALL peers
|
||||||
|
else if isSharedTG(tg) → send to that specific peer
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Changes to `TrunkLink`
|
||||||
|
|
||||||
|
`onLocalTalkerStart`, `onLocalAudio`, `onLocalFlush`, `onLocalTalkerStop`
|
||||||
|
currently filter with `isSharedTG(tg)`. Add `|| isClusterTG(tg)`:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
|
||||||
|
{
|
||||||
|
if (!m_con.isConnected() || !m_hello_received ||
|
||||||
|
(!isSharedTG(tg) && !m_reflector->isClusterTG(tg)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendMsg(MsgTrunkTalkerStart(tg, callsign));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Similarly for inbound: `handleMsgTrunkTalkerStart` currently checks
|
||||||
|
`isSharedTG`. Add `|| isClusterTG`:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Multi-peer arbitration
|
||||||
|
|
||||||
|
With prefix TGs, a conflict only involves 2 reflectors (local + the owner).
|
||||||
|
Cluster TGs can have N-way conflicts: 3 reflectors might all have a local
|
||||||
|
talker key up on TG 222 simultaneously.
|
||||||
|
|
||||||
|
The existing nonce tie-break still works because each pair of connected peers
|
||||||
|
resolves independently:
|
||||||
|
|
||||||
|
1. Reflector A (nonce 500) and Reflector B (nonce 300) both claim TG 222.
|
||||||
|
2. A-B link: B wins (lower nonce). A yields, sends TalkerStop to all its other
|
||||||
|
peers.
|
||||||
|
3. Reflector C (nonce 700) also claimed TG 222 on the A-C and B-C links. Both
|
||||||
|
A and B have lower nonces than C, so C yields on both links.
|
||||||
|
4. Net result: B (nonce 300) wins everywhere. Convergence takes one
|
||||||
|
round-trip per link — same as today.
|
||||||
|
|
||||||
|
No protocol changes needed. The nonce comparison is already pairwise.
|
||||||
|
|
||||||
|
#### Changes to `Reflector.cpp`
|
||||||
|
|
||||||
|
The `onTalkerUpdated` callback currently iterates all trunk links and calls
|
||||||
|
`link->onLocalTalkerStart()`. No change needed — each `TrunkLink` now
|
||||||
|
individually decides whether to forward based on `isSharedTG || isClusterTG`.
|
||||||
|
|
||||||
|
Audio forwarding in `Reflector::onTalkerUpdated` already loops all links. Same
|
||||||
|
for `handleMsgTrunkAudio` -> `broadcastUdpMsg` on the receiving side.
|
||||||
|
|
||||||
|
#### Cluster TG validation at startup
|
||||||
|
|
||||||
|
During `initTrunkLinks()`, validate that no cluster TG matches any
|
||||||
|
`LOCAL_PREFIX` or `REMOTE_PREFIX`. This prevents ambiguity about whether a TG is
|
||||||
|
cluster-routed or prefix-routed:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
for (uint32_t tg : m_cluster_tgs)
|
||||||
|
{
|
||||||
|
std::string s = std::to_string(tg);
|
||||||
|
for (const auto& prefix : local_prefixes)
|
||||||
|
{
|
||||||
|
if (s.compare(0, prefix.size(), prefix) == 0)
|
||||||
|
{
|
||||||
|
cerr << "*** ERROR: Cluster TG " << tg
|
||||||
|
<< " conflicts with LOCAL_PREFIX " << prefix << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### HTTP `/status` extension
|
||||||
|
|
||||||
|
Add a `cluster_tgs` array to the status JSON and include cluster TG talkers in
|
||||||
|
each trunk link's `active_talkers`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cluster_tgs": [222, 2221, 91],
|
||||||
|
"trunks": {
|
||||||
|
"TRUNK_02": {
|
||||||
|
"active_talkers": {
|
||||||
|
"222": "IW1GEU",
|
||||||
|
"25": "SM0ABC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Key files to modify
|
||||||
|
|
||||||
|
| File | Change |
|
||||||
|
|------|--------|
|
||||||
|
| `Reflector.h` | Add `m_cluster_tgs` set, `isClusterTG()` method |
|
||||||
|
| `Reflector.cpp` | Parse `CLUSTER_TGS` config, validate no prefix overlap |
|
||||||
|
| `TrunkLink.cpp` | Add `isClusterTG` to routing checks in all 6 handlers |
|
||||||
|
| `svxreflector.conf.in` | Add `CLUSTER_TGS` example |
|
||||||
|
|
||||||
|
No new message types. No wire protocol changes. No new classes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Comparison
|
||||||
|
|
||||||
|
| | Satellite reflectors | Cluster TGs |
|
||||||
|
|---|---|---|
|
||||||
|
| **Solves** | Mesh scaling for large deployments | Shared nationwide channels |
|
||||||
|
| **Complexity** | New class + new TCP listener | ~50 lines of routing logic changes |
|
||||||
|
| **Wire protocol** | 1 new field in MsgTrunkHello | No changes |
|
||||||
|
| **Config** | `[SATELLITE]`, `SATELLITE_OF` | `CLUSTER_TGS=222,91` |
|
||||||
|
| **Risk** | Medium — new connection type | Low — additive routing check |
|
||||||
|
| **Recommended order** | Second | **First** (simpler, high value) |
|
||||||
|
|
||||||
|
### Suggested implementation order
|
||||||
|
|
||||||
|
1. **Cluster TGs first** — small code change, no new protocol, immediately
|
||||||
|
useful for national channels.
|
||||||
|
2. **Satellite reflectors second** — larger feature, only needed when mesh
|
||||||
|
size becomes a bottleneck (>10 reflectors).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Combined example: Italy with both features
|
||||||
|
|
||||||
|
```
|
||||||
|
┌──── Nationwide full mesh (unchanged) ─────┐
|
||||||
|
│ Cluster TGs: 222, 2221 │
|
||||||
|
│ │
|
||||||
|
┌─────┴─────┐ ┌─────┴─────┐
|
||||||
|
│ Refl. 01 │◄── trunk (prefix 01↔02) ───►│ Refl. 02 │
|
||||||
|
│ (LAZIO) │ + cluster 222,2221 │ (SARDEGNA)│
|
||||||
|
└─────┬─────┘ └───────────┘
|
||||||
|
┌────────┼────────┐
|
||||||
|
▼ ▼ ▼
|
||||||
|
Sat Roma Sat Viter Sat Latina (satellites of Reflector 01)
|
||||||
|
clients clients clients
|
||||||
|
```
|
||||||
|
|
||||||
|
- A client on Satellite Roma joins **TG 22201** (regional Lazio): heard by all
|
||||||
|
Lazio clients (via parent reflector) and by all reflectors that have prefix
|
||||||
|
`01` as a `REMOTE_PREFIX`.
|
||||||
|
- The same client joins **TG 222** (national cluster): heard by **every
|
||||||
|
reflector** in the mesh, regardless of prefix.
|
||||||
|
- TG routing is unambiguous: cluster TGs are checked first, then prefix routing.
|
||||||
@@ -390,6 +390,33 @@ bool Reflector::initialize(Async::Config &cfg)
|
|||||||
|
|
||||||
m_cfg->valueUpdated.connect(sigc::mem_fun(*this, &Reflector::cfgUpdated));
|
m_cfg->valueUpdated.connect(sigc::mem_fun(*this, &Reflector::cfgUpdated));
|
||||||
|
|
||||||
|
// Parse CLUSTER_TGS — comma-separated list of TG numbers broadcast to all peers
|
||||||
|
std::string cluster_tgs_str;
|
||||||
|
if (cfg.getValue("GLOBAL", "CLUSTER_TGS", cluster_tgs_str))
|
||||||
|
{
|
||||||
|
std::istringstream ctss(cluster_tgs_str);
|
||||||
|
std::string token;
|
||||||
|
while (std::getline(ctss, token, ','))
|
||||||
|
{
|
||||||
|
token.erase(0, token.find_first_not_of(" \t"));
|
||||||
|
token.erase(token.find_last_not_of(" \t") + 1);
|
||||||
|
if (!token.empty())
|
||||||
|
{
|
||||||
|
uint32_t tg = static_cast<uint32_t>(std::stoul(token));
|
||||||
|
m_cluster_tgs.insert(tg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_cluster_tgs.empty())
|
||||||
|
{
|
||||||
|
std::cout << "Cluster TGs:";
|
||||||
|
for (uint32_t tg : m_cluster_tgs)
|
||||||
|
{
|
||||||
|
std::cout << " " << tg;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initTrunkLinks();
|
initTrunkLinks();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1425,6 +1452,74 @@ void Reflector::httpRequestReceived(Async::HttpServerConnection *con,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.target == "/config")
|
||||||
|
{
|
||||||
|
Json::Value cfg_json(Json::objectValue);
|
||||||
|
|
||||||
|
// Local prefixes
|
||||||
|
std::string local_prefix_str;
|
||||||
|
m_cfg->getValue("GLOBAL", "LOCAL_PREFIX", local_prefix_str);
|
||||||
|
Json::Value lp_arr(Json::arrayValue);
|
||||||
|
{
|
||||||
|
std::istringstream ss(local_prefix_str);
|
||||||
|
std::string token;
|
||||||
|
while (std::getline(ss, token, ','))
|
||||||
|
{
|
||||||
|
token.erase(0, token.find_first_not_of(" \t"));
|
||||||
|
token.erase(token.find_last_not_of(" \t") + 1);
|
||||||
|
if (!token.empty()) lp_arr.append(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg_json["local_prefix"] = lp_arr;
|
||||||
|
|
||||||
|
// Cluster TGs
|
||||||
|
Json::Value cluster_arr(Json::arrayValue);
|
||||||
|
for (uint32_t tg : m_cluster_tgs)
|
||||||
|
{
|
||||||
|
cluster_arr.append(tg);
|
||||||
|
}
|
||||||
|
cfg_json["cluster_tgs"] = cluster_arr;
|
||||||
|
|
||||||
|
// Trunk peers (static config)
|
||||||
|
Json::Value peers(Json::objectValue);
|
||||||
|
for (auto* link : m_trunk_links)
|
||||||
|
{
|
||||||
|
Json::Value peer(Json::objectValue);
|
||||||
|
Json::Value link_status = link->statusJson();
|
||||||
|
peer["host"] = link_status["host"];
|
||||||
|
peer["port"] = link_status["port"];
|
||||||
|
peer["remote_prefix"] = link_status["remote_prefix"];
|
||||||
|
peers[link->section()] = peer;
|
||||||
|
}
|
||||||
|
cfg_json["trunks"] = peers;
|
||||||
|
|
||||||
|
// Listen port
|
||||||
|
std::string listen_port("5300");
|
||||||
|
m_cfg->getValue("GLOBAL", "LISTEN_PORT", listen_port);
|
||||||
|
cfg_json["listen_port"] = listen_port;
|
||||||
|
|
||||||
|
// HTTP port
|
||||||
|
std::string http_port;
|
||||||
|
if (m_cfg->getValue("GLOBAL", "HTTP_SRV_PORT", http_port))
|
||||||
|
{
|
||||||
|
cfg_json["http_port"] = http_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
Json::StreamWriterBuilder builder;
|
||||||
|
builder["commentStyle"] = "None";
|
||||||
|
builder["indentation"] = "";
|
||||||
|
Json::StreamWriter* writer = builder.newStreamWriter();
|
||||||
|
writer->write(cfg_json, &os);
|
||||||
|
delete writer;
|
||||||
|
|
||||||
|
res.setContent("application/json", os.str());
|
||||||
|
res.setSendContent(req.method == "GET");
|
||||||
|
res.setCode(200);
|
||||||
|
con->write(res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.target != "/status")
|
if (req.target != "/status")
|
||||||
{
|
{
|
||||||
res.setCode(404);
|
res.setCode(404);
|
||||||
@@ -1442,6 +1537,13 @@ void Reflector::httpRequestReceived(Async::HttpServerConnection *con,
|
|||||||
}
|
}
|
||||||
m_status["trunks"] = trunks;
|
m_status["trunks"] = trunks;
|
||||||
|
|
||||||
|
Json::Value cluster_arr(Json::arrayValue);
|
||||||
|
for (uint32_t tg : m_cluster_tgs)
|
||||||
|
{
|
||||||
|
cluster_arr.append(tg);
|
||||||
|
}
|
||||||
|
m_status["cluster_tgs"] = cluster_arr;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
Json::StreamWriterBuilder builder;
|
Json::StreamWriterBuilder builder;
|
||||||
builder["commentStyle"] = "None";
|
builder["commentStyle"] = "None";
|
||||||
@@ -1746,12 +1848,42 @@ void Reflector::cfgUpdated(const std::string& section, const std::string& tag)
|
|||||||
|
|
||||||
void Reflector::initTrunkLinks(void)
|
void Reflector::initTrunkLinks(void)
|
||||||
{
|
{
|
||||||
|
// Collect local prefixes for cluster TG validation
|
||||||
|
std::string local_prefix_str;
|
||||||
|
m_cfg->getValue("GLOBAL", "LOCAL_PREFIX", local_prefix_str);
|
||||||
|
std::vector<std::string> all_prefixes;
|
||||||
|
{
|
||||||
|
std::istringstream ss(local_prefix_str);
|
||||||
|
std::string token;
|
||||||
|
while (std::getline(ss, token, ','))
|
||||||
|
{
|
||||||
|
token.erase(0, token.find_first_not_of(" \t"));
|
||||||
|
token.erase(token.find_last_not_of(" \t") + 1);
|
||||||
|
if (!token.empty()) all_prefixes.push_back(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& section : m_cfg->listSections())
|
for (const auto& section : m_cfg->listSections())
|
||||||
{
|
{
|
||||||
if (section.substr(0, 6) != "TRUNK_")
|
if (section.substr(0, 6) != "TRUNK_")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collect remote prefixes for validation
|
||||||
|
std::string remote_prefix_str;
|
||||||
|
m_cfg->getValue(section, "REMOTE_PREFIX", remote_prefix_str);
|
||||||
|
{
|
||||||
|
std::istringstream ss(remote_prefix_str);
|
||||||
|
std::string token;
|
||||||
|
while (std::getline(ss, token, ','))
|
||||||
|
{
|
||||||
|
token.erase(0, token.find_first_not_of(" \t"));
|
||||||
|
token.erase(token.find_last_not_of(" \t") + 1);
|
||||||
|
if (!token.empty()) all_prefixes.push_back(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto* link = new TrunkLink(this, *m_cfg, section);
|
auto* link = new TrunkLink(this, *m_cfg, section);
|
||||||
if (link->initialize())
|
if (link->initialize())
|
||||||
{
|
{
|
||||||
@@ -1764,6 +1896,23 @@ void Reflector::initTrunkLinks(void)
|
|||||||
delete link;
|
delete link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate cluster TGs don't overlap with any prefix
|
||||||
|
for (uint32_t tg : m_cluster_tgs)
|
||||||
|
{
|
||||||
|
std::string s = std::to_string(tg);
|
||||||
|
for (const auto& prefix : all_prefixes)
|
||||||
|
{
|
||||||
|
if (s.size() >= prefix.size() &&
|
||||||
|
s.compare(0, prefix.size(), prefix) == 0)
|
||||||
|
{
|
||||||
|
std::cerr << "*** WARNING: Cluster TG " << tg
|
||||||
|
<< " conflicts with prefix " << prefix
|
||||||
|
<< " — this TG will be routed as cluster (broadcast to all)"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} /* Reflector::initTrunkLinks */
|
} /* Reflector::initTrunkLinks */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
#include <sigc++/sigc++.h>
|
#include <sigc++/sigc++.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
@@ -236,6 +237,8 @@ class Reflector : public sigc::trackable
|
|||||||
|
|
||||||
Json::Value& clientStatus(const std::string& callsign);
|
Json::Value& clientStatus(const std::string& callsign);
|
||||||
|
|
||||||
|
bool isClusterTG(uint32_t tg) const { return m_cluster_tgs.count(tg) > 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -281,6 +284,7 @@ class Reflector : public sigc::trackable
|
|||||||
Json::Value m_status;
|
Json::Value m_status;
|
||||||
|
|
||||||
std::vector<TrunkLink*> m_trunk_links;
|
std::vector<TrunkLink*> m_trunk_links;
|
||||||
|
std::set<uint32_t> m_cluster_tgs;
|
||||||
|
|
||||||
Reflector(const Reflector&);
|
Reflector(const Reflector&);
|
||||||
Reflector& operator=(const Reflector&);
|
Reflector& operator=(const Reflector&);
|
||||||
|
|||||||
@@ -223,12 +223,12 @@ Json::Value TrunkLink::statusJson(void) const
|
|||||||
for (const auto& p : m_remote_prefix) remote_arr.append(p);
|
for (const auto& p : m_remote_prefix) remote_arr.append(p);
|
||||||
obj["remote_prefix"] = remote_arr;
|
obj["remote_prefix"] = remote_arr;
|
||||||
|
|
||||||
// active_talkers: all TGs currently held by trunk that match our remote prefix
|
// active_talkers: TGs held by trunk that match remote prefix or are cluster TGs
|
||||||
Json::Value talkers(Json::objectValue);
|
Json::Value talkers(Json::objectValue);
|
||||||
const auto& trunk_map = TGHandler::instance()->trunkTalkersSnapshot();
|
const auto& trunk_map = TGHandler::instance()->trunkTalkersSnapshot();
|
||||||
for (auto& kv : trunk_map)
|
for (auto& kv : trunk_map)
|
||||||
{
|
{
|
||||||
if (isSharedTG(kv.first))
|
if (isSharedTG(kv.first) || m_reflector->isClusterTG(kv.first))
|
||||||
{
|
{
|
||||||
talkers[std::to_string(kv.first)] = kv.second;
|
talkers[std::to_string(kv.first)] = kv.second;
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,8 @@ Json::Value TrunkLink::statusJson(void) const
|
|||||||
|
|
||||||
void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
|
void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
|
||||||
{
|
{
|
||||||
if (!m_con.isConnected() || !m_hello_received || !isSharedTG(tg))
|
if (!m_con.isConnected() || !m_hello_received ||
|
||||||
|
(!isSharedTG(tg) && !m_reflector->isClusterTG(tg)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -251,7 +252,8 @@ void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
|
|||||||
|
|
||||||
void TrunkLink::onLocalTalkerStop(uint32_t tg)
|
void TrunkLink::onLocalTalkerStop(uint32_t tg)
|
||||||
{
|
{
|
||||||
if (!m_con.isConnected() || !m_hello_received || !isSharedTG(tg))
|
if (!m_con.isConnected() || !m_hello_received ||
|
||||||
|
(!isSharedTG(tg) && !m_reflector->isClusterTG(tg)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -267,7 +269,8 @@ void TrunkLink::onLocalTalkerStop(uint32_t tg)
|
|||||||
|
|
||||||
void TrunkLink::onLocalAudio(uint32_t tg, const std::vector<uint8_t>& audio)
|
void TrunkLink::onLocalAudio(uint32_t tg, const std::vector<uint8_t>& audio)
|
||||||
{
|
{
|
||||||
if (!m_con.isConnected() || !m_hello_received || !isSharedTG(tg) ||
|
if (!m_con.isConnected() || !m_hello_received ||
|
||||||
|
(!isSharedTG(tg) && !m_reflector->isClusterTG(tg)) ||
|
||||||
m_yielded_tgs.count(tg))
|
m_yielded_tgs.count(tg))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -278,7 +281,8 @@ void TrunkLink::onLocalAudio(uint32_t tg, const std::vector<uint8_t>& audio)
|
|||||||
|
|
||||||
void TrunkLink::onLocalFlush(uint32_t tg)
|
void TrunkLink::onLocalFlush(uint32_t tg)
|
||||||
{
|
{
|
||||||
if (!m_con.isConnected() || !m_hello_received || !isSharedTG(tg))
|
if (!m_con.isConnected() || !m_hello_received ||
|
||||||
|
(!isSharedTG(tg) && !m_reflector->isClusterTG(tg)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -447,7 +451,7 @@ void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tg = msg.tg();
|
uint32_t tg = msg.tg();
|
||||||
if (!isSharedTG(tg))
|
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -491,7 +495,7 @@ void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tg = msg.tg();
|
uint32_t tg = msg.tg();
|
||||||
if (!isSharedTG(tg))
|
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -513,7 +517,7 @@ void TrunkLink::handleMsgTrunkAudio(std::istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tg = msg.tg();
|
uint32_t tg = msg.tg();
|
||||||
if (!isSharedTG(tg) || msg.audio().empty())
|
if ((!isSharedTG(tg) && !m_reflector->isClusterTG(tg)) || msg.audio().empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -541,7 +545,7 @@ void TrunkLink::handleMsgTrunkFlush(std::istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tg = msg.tg();
|
uint32_t tg = msg.tg();
|
||||||
if (!isSharedTG(tg))
|
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ LISTEN_PORT=5300
|
|||||||
#CODECS=OPUS
|
#CODECS=OPUS
|
||||||
TG_FOR_V1_CLIENTS=999
|
TG_FOR_V1_CLIENTS=999
|
||||||
#LOCAL_PREFIX=1
|
#LOCAL_PREFIX=1
|
||||||
|
#CLUSTER_TGS=222,2221,91
|
||||||
#RANDOM_QSY_RANGE=12399:100
|
#RANDOM_QSY_RANGE=12399:100
|
||||||
#HTTP_SRV_PORT=8080
|
#HTTP_SRV_PORT=8080
|
||||||
COMMAND_PTY=/dev/shm/reflector_ctrl
|
COMMAND_PTY=/dev/shm/reflector_ctrl
|
||||||
|
|||||||
Reference in new issue
Block a user