Skip to content

Add link-local addressing (net_id=0) for edge-initiated communication#201

Merged
okhsunrog merged 2 commits intojamesmunns:mainfrom
okhsunrog:link-local-addressing
Mar 28, 2026
Merged

Add link-local addressing (net_id=0) for edge-initiated communication#201
okhsunrog merged 2 commits intojamesmunns:mainfrom
okhsunrog:link-local-addressing

Conversation

@okhsunrog
Copy link
Copy Markdown
Collaborator

Previously, an edge device could not send any frames until the router pinged it first — the edge started as Inactive and had no net_id to put in outgoing headers. This forced a router-initiates-first bootstrap flow, which is awkward when the edge wants to request something from the router immediately on connection (e.g. configuration, seed assignment).

This PR allows edges to send frames with net_id=0 as "link-local" addressing. The edge starts as Active { net_id: 0 } and can immediately send to (0, CENTRAL_NODE_ID, port) meaning "my directly connected router". The router rewrites dst.network_id=0 to the real net_id of that interface and delivers locally. The response carries the real net_id back, and the edge discovers its address from that first response — no protocol change needed.

  • Remove net_id == 0 send guard in EdgePort::common_send
  • Add dst.network_id == 0 rewriting in router's process_frame (mirrors existing src rewriting)
  • Target edges now initialize as Active { net_id: 0, node_id: EDGE_NODE_ID } instead of Inactive across all transports (TCP, UDP, USB, serial, embassy-usb)
  • Update UDP transport is_target check to handle new initial state

Testing: 3 new e2e tests — edge-initiated link-local ping, link-local then real-address ping, two link-local edges pinging each other through a router. All existing e2e tests pass unchanged.

Allow edge devices to send frames before discovering their real net_id
by using net_id=0 as link-local addressing. The router rewrites
dst.network_id=0 to the interface's real net_id, enabling the edge to
bootstrap itself without waiting for the router to ping first.

- Remove net_id==0 send block in EdgePort::common_send
- Rewrite dst.network_id=0 in router's process_frame (link-local delivery)
- Target edges now start as Active{net_id:0} instead of Inactive
- Update all transports and toolkits for new initial state
- Add e2e tests for link-local ping, address discovery, and cross-edge routing
@okhsunrog okhsunrog marked this pull request as ready for review March 28, 2026 21:22
@okhsunrog okhsunrog merged commit 4d51746 into jamesmunns:main Mar 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant