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

+81
View File
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.42.4 (0)
-->
<!-- Title: TwinPair Pages: 1 -->
<svg width="574pt" height="237pt"
viewBox="21.60 21.60 552.64 215.77" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(25.6 211.77)">
<title>TwinPair</title>
<!-- SE -->
<g id="node1" class="node">
<title>SE</title>
<path fill="#dde8fb" stroke="#1a4fa3" stroke-width="2" d="M64,-186.17C64,-186.17 12,-186.17 12,-186.17 6,-186.17 0,-180.17 0,-174.17 0,-174.17 0,-148.17 0,-148.17 0,-142.17 6,-136.17 12,-136.17 12,-136.17 64,-136.17 64,-136.17 70,-136.17 76,-142.17 76,-148.17 76,-148.17 76,-174.17 76,-174.17 76,-180.17 70,-186.17 64,-186.17"/>
<text text-anchor="middle" x="38" y="-164.77" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">SE</text>
<text text-anchor="middle" x="38" y="-150.77" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">240</text>
</g>
<!-- DEA -->
<g id="node3" class="node">
<title>DEA</title>
<path fill="#e6dcff" stroke="#5430a8" stroke-width="2" d="M359.03,-186.17C359.03,-186.17 307.03,-186.17 307.03,-186.17 301.03,-186.17 295.03,-180.17 295.03,-174.17 295.03,-174.17 295.03,-148.17 295.03,-148.17 295.03,-142.17 301.03,-136.17 307.03,-136.17 307.03,-136.17 359.03,-136.17 359.03,-136.17 365.03,-136.17 371.03,-142.17 371.03,-148.17 371.03,-148.17 371.03,-174.17 371.03,-174.17 371.03,-180.17 365.03,-186.17 359.03,-186.17"/>
<text text-anchor="middle" x="333.03" y="-164.77" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">DE&#45;A</text>
<text text-anchor="middle" x="333.03" y="-150.77" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">262</text>
</g>
<!-- SE&#45;&#45;DEA -->
<g id="edge4" class="edge">
<title>SE&#45;&#45;DEA</title>
<path fill="none" stroke="#5f6368" stroke-width="1.2" d="M76.27,-161.17C132.86,-161.17 238.27,-161.17 294.83,-161.17"/>
</g>
<!-- DEB -->
<g id="node4" class="node">
<title>DEB</title>
<path fill="#e6dcff" stroke="#5430a8" stroke-width="2" d="M359.03,-50C359.03,-50 307.03,-50 307.03,-50 301.03,-50 295.03,-44 295.03,-38 295.03,-38 295.03,-12 295.03,-12 295.03,-6 301.03,0 307.03,0 307.03,0 359.03,0 359.03,0 365.03,0 371.03,-6 371.03,-12 371.03,-12 371.03,-38 371.03,-38 371.03,-44 365.03,-50 359.03,-50"/>
<text text-anchor="middle" x="333.03" y="-28.6" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">DE&#45;B</text>
<text text-anchor="middle" x="333.03" y="-14.6" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">262</text>
</g>
<!-- SE&#45;&#45;DEB -->
<g id="edge5" class="edge">
<title>SE&#45;&#45;DEB</title>
<path fill="none" stroke="#5f6368" stroke-width="1.2" d="M76.27,-143.51C132.86,-117.38 238.27,-68.73 294.83,-42.63"/>
</g>
<!-- IT -->
<g id="node2" class="node">
<title>IT</title>
<path fill="#fde2d4" stroke="#c0531c" stroke-width="2" d="M64,-50C64,-50 12,-50 12,-50 6,-50 0,-44 0,-38 0,-38 0,-12 0,-12 0,-6 6,0 12,0 12,0 64,0 64,0 70,0 76,-6 76,-12 76,-12 76,-38 76,-38 76,-44 70,-50 64,-50"/>
<text text-anchor="middle" x="38" y="-28.6" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">IT</text>
<text text-anchor="middle" x="38" y="-14.6" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">222</text>
</g>
<!-- IT&#45;&#45;SE -->
<g id="edge1" class="edge">
<title>IT&#45;&#45;SE</title>
<path fill="none" stroke="#5f6368" stroke-width="1.2" d="M38,-50.29C38,-74.75 38,-111.6 38,-136.01"/>
</g>
<!-- IT&#45;&#45;DEA -->
<g id="edge2" class="edge">
<title>IT&#45;&#45;DEA</title>
<path fill="none" stroke="#5f6368" stroke-width="1.2" d="M76.27,-42.66C132.86,-68.78 238.27,-117.43 294.83,-143.54"/>
</g>
<!-- IT&#45;&#45;DEB -->
<g id="edge3" class="edge">
<title>IT&#45;&#45;DEB</title>
<path fill="none" stroke="#5f6368" stroke-width="1.2" d="M76.27,-25C132.86,-25 238.27,-25 294.83,-25"/>
</g>
<!-- DEA&#45;&#45;DEB -->
<g id="edge6" class="edge">
<title>DEA&#45;&#45;DEB</title>
<path fill="none" stroke="#5430a8" stroke-width="3" d="M333.03,-135.87C333.03,-111.42 333.03,-74.57 333.03,-50.16"/>
</g>
<!-- TWINANN -->
<g id="node5" class="node">
<title>TWINANN</title>
<path fill="lightgrey" stroke="transparent" stroke-width="2" d="M511.04,-143.58C511.04,-143.58 391.04,-143.58 391.04,-143.58 385.04,-143.58 379.04,-137.58 379.04,-131.58 379.04,-131.58 379.04,-54.58 379.04,-54.58 379.04,-48.58 385.04,-42.58 391.04,-42.58 391.04,-42.58 511.04,-42.58 511.04,-42.58 517.04,-42.58 523.04,-48.58 523.04,-54.58 523.04,-54.58 523.04,-131.58 523.04,-131.58 523.04,-137.58 517.04,-143.58 511.04,-143.58"/>
<text text-anchor="middle" x="451.04" y="-112.58" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="10.00" fill="#5430a8">[TWIN] link</text>
<text text-anchor="middle" x="451.04" y="-101.58" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="10.00" fill="#5430a8">full&#45;state mirror</text>
<text text-anchor="middle" x="451.04" y="-90.58" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="10.00" fill="#5430a8">heartbeat:</text>
<text text-anchor="middle" x="451.04" y="-79.58" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="10.00" fill="#5430a8"> &#160;send every 2 s</text>
<text text-anchor="middle" x="451.04" y="-68.58" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="10.00" fill="#5430a8"> &#160;fail after 5 s silence</text>
</g>
<!-- DEB&#45;&#45;TWINANN -->
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB