updateFromLSA method

OSPFRoutingTable<T>? updateFromLSA(
  1. OSPFRoutingTable<T> currentTable,
  2. LinkStateAdvertisement<T> newLSA,
  3. Map<T, Map<T, num>> network
)

Updates routing table based on new link-state advertisements

currentTable - Current routing table newLSA - New link-state advertisement network - Current network topology

Returns updated routing table if changes occurred

Implementation

OSPFRoutingTable<T>? updateFromLSA(
  OSPFRoutingTable<T> currentTable,
  LinkStateAdvertisement<T> newLSA,
  Map<T, Map<T, num>> network,
) {
  // Check if LSA is newer than what we have
  final existingRoute = currentTable.getRoute(newLSA.networkId);
  if (existingRoute != null &&
      existingRoute.lastUpdate.isAfter(newLSA.timestamp)) {
    return null; // No update needed
  }

  // Recompute routes if topology changed
  return computeRoutes(network, currentTable.sourceRouter);
}