The pathfinding algorithm has been updated to use the route_info table from the backend JSON data instead of a default graph-based search algorithm. This ensures that paths are determined by the actual routing configuration, not by arbitrary graph traversal.
- First, the algorithm checks if the source and target are directly connected
- If a physical (direct) edge exists between them, it returns a single-hop path
- This handles the case where nodes are immediate neighbors without routing entries
- If not direct neighbors, the algorithm uses the
route_infotable - Each node's
route_infocontains entries showing how traffic from different sources reaches it - Each entry has:
source_node: The ultimate source of trafficincoming_interface: The interface where traffic arrivesiif_neigh_node: The immediate next-hop neighbor
The algorithm traces the path backwards from target to source:
- Start at the target node
- Look up the target's
route_infotable - Find the entry where
source_nodematches our source - Extract the
iif_neigh_node(next hop toward source) - Move to that next hop and repeat
- Continue until we reach the source node
- The algorithm builds the path in reverse (target → source)
- Then reverses it to give the final path (source → target)
- Includes both the node sequence and the edge IDs
For path 14cd → fireapp-VirtualBox:
{
"incoming_interface": "usb0",
"iif_neigh_node": "2001:197a:1576:0:2b0:19ff:fe7a:1576",
"source_node": "2001:197a:14cd:0:2b0:19ff:fe7a:14cd"
}- Start at:
fireapp-VirtualBox - Look up route for source
14cd→ find next hop is1576 - Move to:
1576 - Look up route for source
14cd→ find next hop is14cd(reached source!) - Final path:
14cd → 1576 → fireapp-VirtualBox
Path from 14cd → fireapp-VirtualBox:
Nodes: 14cd → 1576 → fireapp-VirtualBox
Edges: direct-14cd-1576, direct-1576-fireapp-VirtualBox
Path from f453 → fireapp-VirtualBox:
Nodes: f453 → fireapp-VirtualBox
Edges: direct-f453-fireapp-VirtualBox
Path from 1576 → fireapp-VirtualBox:
Nodes: 1576 → fireapp-VirtualBox
Edges: direct-1576-fireapp-VirtualBox
-
Implementation:
utils/dataAdapter.tsfindPath()- Main entry pointfindPathUsingRouteInfo()- Route-based algorithmfindPathBFS()- Fallback BFS (if route_info not available)
-
Usage:
components/BackendNetworkExample.tsx- Calls
findPath()with the backend JSON to enable route-based pathfinding
- Calls
✅ Accurate: Uses actual routing tables from network configuration
✅ Realistic: Shows how traffic actually flows through the network
✅ Direct neighbor support: Handles single-hop connections automatically
✅ Fallback: Uses BFS if route_info data is not available
✅ Loop detection: Prevents infinite loops in case of routing errors