validateOSPFTable method
Validates OSPF routing table consistency
routingTable - Routing table to validate
network - Network topology for validation
Returns list of validation errors (empty if valid)
Implementation
List<String> validateOSPFTable(
OSPFRoutingTable<T> routingTable,
Map<T, Map<T, num>> network,
) {
final errors = <String>[];
// Check if source router exists in network
if (!network.containsKey(routingTable.sourceRouter)) {
errors.add(
'Source router ${routingTable.sourceRouter} not found in network',
);
}
// Check for invalid costs
for (final route in routingTable.routes.values) {
if (route.cost < 0) {
errors.add(
'Invalid cost ${route.cost} for destination ${route.destination}',
);
}
if (route.cost > _maxCost) {
errors.add(
'Cost ${route.cost} exceeds maximum cost $_maxCost for destination ${route.destination}',
);
}
}
// Check for circular routes
for (final route in routingTable.routes.values) {
if (route.nextHop != null && route.nextHop == routingTable.sourceRouter) {
errors.add(
'Circular route detected: ${route.destination} -> ${route.nextHop}',
);
}
}
return errors;
}