RoutingNET/distance_vector_routing library
📡 Distance-Vector Routing Algorithm
Implements a comprehensive distance-vector routing algorithm that relies solely on updating neighbors. This algorithm uses the Bellman-Ford approach where each node maintains a vector of distances to all destinations and shares this information only with its immediate neighbors.
- Time Complexity: O(VE) per iteration for route computation
- Space Complexity: O(V²) for routing tables and neighbor updates
- Convergence: Guaranteed to converge in finite iterations (V-1 max)
- Update Strategy: Neighbor-only information sharing
- Route Selection: Based on distance vectors from neighbors
- Loop Prevention: Split horizon and poison reverse techniques
The algorithm maintains routing tables with destination, next hop, cost, and timestamp information, updating routes based solely on neighbor advertisements without global network topology knowledge.
Example:
final network = <String, Map<String, num>>{
'A': {'B': 1, 'C': 4},
'B': {'A': 1, 'C': 2, 'D': 5},
'C': {'A': 4, 'B': 2, 'D': 1},
'D': {'B': 5, 'C': 1},
};
final dvr = DistanceVectorRoutingAlgorithm<String>();
final routes = dvr.computeRoutes(network, 'A');
// Result: Complete routing table based on neighbor updates only
Classes
-
DistanceVectorRouteEntry<
T> - Represents a distance-vector route entry with neighbor-based information
-
DistanceVectorRoutingAlgorithm<
T> - Distance-Vector Routing Algorithm implementation
-
DistanceVectorRoutingTable<
T> - Represents a complete distance-vector routing table
-
NeighborAdvertisement<
T> - Represents a neighbor advertisement with routing information
Functions
-
computeDistanceVectorRoutes<
T> (Map< T, Map< network, T sourceNode, {Map<T, num> >T, NeighborAdvertisement< ? initialAdvertisements}) → DistanceVectorRoutingTable<T> >T> - Convenience function for quick distance-vector route computation