Skip to content

Decrease routing storms and improve routing in large homogenous networks - #149

Open
puddly wants to merge 19 commits into
devfrom
puddly/router-fixes
Open

puddly wants to merge 19 commits into
devfrom
puddly/router-fixes

Conversation

@puddly

@puddly puddly commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

This PR is the result of a bunch of 100 node simulation tests in adverse conditions (with LQI/RSSI/CCA/packet loss simulation) based on #106, focusing on decreasing routing traffic while increasing deliverability.

Notable changes:

  • Networks with a bunch of Ziggurat routers were not cooperative: routers that started up at the same time did not jitter their Link Status broadcasts, causing unintentional timer synchronization.
  • Jitter relayed route requests based on the link cost. The spec allows this and it causes better routes to propagate faster.
  • Directly send to neighbors without route discovery if their link cost is less than two.
  • Stop relaying a route request when a cheaper one arrives. With the above cost-based route request jittering, it reduces the relaying of worse-cost routes.

@puddly
puddly added this pull request to stack #146 November 22, 2026 21:22
@zigpy-review-bot zigpy-review-bot added the bugfix This PR fixes a bug label Nov 22, 2026
Base automatically changed from puddly/time-based-scheduling to dev November 22, 2026 22:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Terminal no-ACK failures leave failed direct links eligible for reuse, while held frames promoted to routable can be sent without required return-path route records.

2 open issues
What changed in this PR

This PR reduces routing traffic and improves delivery in large Zigbee networks, building on simulation work with adverse radio conditions.

Changes:

  • Jitters link-status broadcasts and prioritizes cheaper route-request relays, cancelling superseded copies.
  • Uses link costs to select direct neighbors and source routes.
  • Extends concentrator behavior, route-record handling, and tree-depth reporting.
File Description
crates/​ziggurat-zigbee/​src/​sends/​tests.rs Tests cancellation of superseded route-request relays.
crates/​ziggurat-zigbee/​src/​sends/​mod.rs Tracks and cancels replaced relays.
crates/​ziggurat-zigbee/​src/​nwk/​routing/​tests.rs Tests source-route first-hop filtering.
crates/​ziggurat-zigbee/​src/​nwk/​routing.rs Adds route-record decisions and source-route filtering.
crates/​ziggurat-zigbee/​src/​nwk/​next_hop.rs Selects direct neighbors and source routes by link cost.
crates/​ziggurat-zigbee/​src/​nwk/​neighbors.rs Exposes bidirectional costs and live router links.
crates/​ziggurat-zigbee/​src/​nwk/​frame.rs Adds secured-frame size checks.
crates/​ziggurat-zigbee/​src/​constants.rs Adds routing-cost and broadcast-jitter tunables.
crates/​ziggurat-protocol/​src/​wire.rs Uses reserved configuration bits for tree depth.
crates/​ziggurat-protocol/​src/​bridge.rs Maps concentrator and depth configuration.
crates/​ziggurat-driver/​src/​zigbee_stack/​zdp.rs Updates neighbor depth reporting.
crates/​ziggurat-driver/​src/​zigbee_stack/​sends.rs Updates routing policy for held sends.
crates/​ziggurat-driver/​src/​zigbee_stack/​route.rs Adds cost-based relay delays and dynamic concentrator control.
crates/​ziggurat-driver/​src/​zigbee_stack/​nwk.rs Extends route records, child discovery, and failure reporting.
crates/​ziggurat-driver/​src/​zigbee_stack/​neighbor.rs Sizes link-status frames dynamically and jitters broadcasts.
crates/​ziggurat-driver/​src/​zigbee_stack/​mac.rs Advertises configured tree depth in beacons.
crates/​ziggurat-driver/​src/​zigbee_stack/​joining.rs Uses link-aware direct-send selection.
crates/​ziggurat-driver/​src/​zigbee_stack.rs Adds depth configuration and mutable concentrator state.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Clearing the route-record requirement during resolution lets queued unicasts overtake the record, so the concentrator may receive data before learning the return path.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved routing and route-record state bugs can discard frames or suppress required records, while management responses misreport routing state and coordinator depth, and frame-size checks perform unnecessary encryption.

2 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Recognize the coordinator as depth zero

crates/​ziggurat-driver/​src/​zigbee_stack/​zdp.rs:112

A coordinator discovered through Link Status is stored as NwkDeviceType::Router by Neighbors::on_link_status (nwk/neighbors.rs:845–848). On a router, this condition consequently reports the coordinator at our depth plus one instead of depth zero. Also recognize network address 0x0000 here so the root's known depth is reported correctly.

Medium severity Avoid repeated encryption when checking link-status frame size

crates/​ziggurat-zigbee/​src/​nwk/​frame.rs:621

This size check performs full AES-CCM encryption, and send_link_status_broadcast calls it for every candidate chunk length. A full chunk therefore incurs dozens of discarded encryptions before its actual transmission, adding avoidable crypto work to the MCU housekeeping path. Serialize the headers and payload and add the fixed MIC length instead; encryption is unnecessary to determine the frame size.

Medium severity Preserve empty route records when source routes are disabled

crates/​ziggurat-zigbee/​src/​nwk/​routing.rs:655

With max_source_route = 0, this filter rejects an empty route record even though it requires no source-route header. A cost-3 neighbor passes the default first-hop check but not the direct-neighbor shortcut, so without a routing-table entry this now triggers discovery or discards a discovery-suppressed frame. Preserve the empty-record exception while retaining the first-hop usability check.

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants