feat(reflector): gateway prefix routing via shouldRelayInbound

A non-owner reflector with two trunk legs (a country gateway sitting
between an international mesh and a national mesh) now forwards inbound
trunk traffic toward the actual prefix owner — automatically, via
longest-prefix-match in its own [TRUNK_x] table. Cluster TGs keep their
deliberate single-hop semantic to prevent loops in cyclic meshes.

Implementation
- Reflector::shouldRelayInbound(tg) composes the inbound relay decision:
  * isLocalTG          -> fan out (existing owner-relay)
  * isClusterTG        -> stop (anti-loop; cluster TGs broadcast outbound
                                from local clients only)
  * hasPrefixRoute     -> gateway forwarding via per-trunk isSharedTG
- The four isLocalTG gates in TrunkLink::handleMsgPeer{TalkerStart,
  TalkerStop,Audio,Flush} are replaced by shouldRelayInbound. Source
  exclusion in forwardTrunk*ToOtherTrunks plus per-link interest
  tracking keep the topology naturally loop-free.

Tests
- topology.py: per-reflector `peers` filter for sparse layouts; new
  reflector `d` (prefix 1219, trunked only to `b`) demonstrating
  gateway-only reachability from `a` to `d`.
- generate_configs.py: honours the peers filter.
- test_trunk.py:
  * setUpClass and test_01 skip non-existent pairs in sparse layouts.
  * test_37_gateway_prefix_routing: a-client (122) <-> d-client (1219)
    over TG 121950 in both directions, no CLUSTER_TGS.
  * test_38_cluster_tg_local_client_broadcast: explicit coverage for
    the outbound local-client cluster broadcast path.
- All previously passing tests still pass: 41/41 trunk + 7/7
  mqtt-deltas + 14/14 twin.

Docs
- docs/TOPOLOGY_EXAMPLES.md (new) + .pdf + topology_pdf/ build sources +
  build_topology_pdf.sh: visual cookbook of the five topology shapes
  (international full-mesh, national mesh joined at gateway, satellite
  tree, hybrid satellite-under-regional, HA twin pair). Includes an
  MCC-range appendix with the recommendation to draw cluster TGs from
  100-199 / 800-999 to avoid country-prefix collisions.
- docs/PEER_PROTOCOL.md: rewrote the "Owner-Relay Fanout" section as
  "Inbound Relay (shouldRelayInbound)" with the three-regime
  composition and clarified the single-mesh fanout caveat.
- README.md: feature bullet now describes gateway prefix routing and
  links to TOPOLOGY_EXAMPLES.md (also added to the documentation list).
This commit is contained in:
Audric committed 2026-05-07 16:12:14 +02:00
1 parent 658a1b153f
commit 52b5e4f3cf
22 files changed
+2191 -38

No files matched your search

+18 -6
View File
@@ -40,12 +40,19 @@ 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;
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
- **Full-mesh topology with gateway prefix routing** — any number of
reflectors can be trunked together; every pair has a direct link inside a
mesh. Audio distribution uses **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. A reflector with two trunk legs (e.g. a country gateway
between an international mesh and a national mesh) automatically bridges
inbound traffic toward the longest-prefix-match owner via
`Reflector::shouldRelayInbound` — no `CLUSTER_TGS` hack required.
Cluster TGs keep an anti-loop single-hop semantic. See
[`docs/TOPOLOGY_EXAMPLES.md`](docs/TOPOLOGY_EXAMPLES.md) for a visual
cookbook of the five supported shapes (international full-mesh,
national mesh joined at gateway, satellite tree, hybrid
satellite-under-regional, HA twin pair)
- **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;
@@ -524,6 +531,11 @@ The PTY path is set by `COMMAND_PTY` in `[GLOBAL]` (default
- [`docs/PEER_PROTOCOL.md`](docs/PEER_PROTOCOL.md) — full wire protocol
specification: message format, handshake sequence, talker arbitration
tie-breaking, heartbeat, and the complete message type table
- [`docs/TOPOLOGY_EXAMPLES.md`](docs/TOPOLOGY_EXAMPLES.md) — visual
cookbook of the five supported topology shapes (international
full-mesh, national mesh joined at gateway, satellite tree, hybrid,
HA twin pair) with rendered diagrams; PDF version in
[`docs/TOPOLOGY_EXAMPLES.pdf`](docs/TOPOLOGY_EXAMPLES.pdf)
- [`docs/DEPLOYMENT_ITALY.md`](docs/DEPLOYMENT_ITALY.md) — complete national
deployment example for Italy (20 regions, full mesh)
- [`docs/DEPLOYMENT_ITALY_IT.md`](docs/DEPLOYMENT_ITALY_IT.md) — same document