updateFromBGPUpdate method
BGPRoutingTable<T> ?
updateFromBGPUpdate(
- BGPRoutingTable<
T> currentTable, - Map<
T, BGPRouteEntry< updates,T> > - Map<
T, Map< asTopologyT, num> >
Updates routing table based on received BGP updates
currentTable - Current routing table
updates - BGP route updates from neighbors
asTopology - Current AS topology
Returns updated routing table if changes occurred
Implementation
BGPRoutingTable<T>? updateFromBGPUpdate(
BGPRoutingTable<T> currentTable,
Map<T, BGPRouteEntry<T>> updates,
Map<T, Map<T, num>> asTopology,
) {
bool hasChanges = false;
final updatedRoutes = Map<T, BGPRouteEntry<T>>.from(currentTable.routes);
for (final entry in updates.entries) {
final destination = entry.key;
final updateRoute = entry.value;
// Check if we have a better route
if (!updatedRoutes.containsKey(destination) ||
_isBetterRoute(updateRoute, updatedRoutes[destination]!)) {
updatedRoutes[destination] = updateRoute;
hasChanges = true;
}
}
if (!hasChanges) return null;
// Recompute routing table with new information
return computeRoutes(asTopology, currentTable.sourceAS);
}