Step 23. OSPF Path Selection¶
Goals¶
The goal of this step is to demonstrate OSPF’s route selection hierarchy when multiple paths to the same destination exist with different route types.
OSPF prioritizes routes in the following order:
Intra-area routes (routes within the same area)
Inter-area routes (routes learned via Summary LSAs from other areas)
External Type-1 routes (E1)
External Type-2 routes (E2)
This hierarchy ensures that OSPF prefers routes with the most accurate cost information and maintains the hierarchical area structure.
Configuration¶
This step uses a topology where the same destination can be reached via different route types.
The configuration in omnetpp.ini is the following:
[Config Step23]
description = "OSPF Path Selection"
network = OSPF_Route_Selection
*.configurator.config = xml("<config> \
<interface hosts='R2' names='eth0' address='1.1.1.1' netmask='255.255.255.0' /> \
<interface hosts='R3' names='ppp1' address='1.1.1.1' netmask='255.255.255.0' /> \
<interface hosts='R6' names='ppp0' address='1.1.1.2' netmask='255.255.255.0' /> \
<interface hosts='R4' names='eth0' address='1.1.1.1' netmask='255.255.255.0' /> \
<interface hosts='R5' names='eth0' address='1.1.1.1' netmask='255.255.255.0' /> \
<interface hosts='**' address='10.x.x.x' netmask='255.x.x.x' /> \
</config>")
*.configurator.assignUniqueAddresses = false
*.configurator.assignDisjunctSubnetAddresses = false
*.R*.ospf.ospfConfig = xmldoc("ASConfig_Route_Selection.xml")
*.*.hasStatus = true
*.scenarioManager.script = xml("<scenario> \
<disconnect t='60' src-module='R1' dest-module='R2' /> \
<disconnect t='70' src-module='R1' dest-module='R3' /> \
</scenario>")
*.R1.numApps = 1
*.R1.app[0].typename = "PingApp"
*.R1.app[0].destAddr = "1.1.1.1"
*.R1.app[0].startTime = 0s
The OSPF configuration:
<?xml version="1.0"?>
<OSPFASConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="OSPF.xsd">
<!-- Areas -->
<Area id="0.0.0.1">
<AddressRange address="R3>R6" mask="R3>R6" />
<AddressRange address="R6>R3" mask="R6>R3" />
</Area>
<!-- Routers -->
<Router name="R1" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" />
<PointToPointInterface ifName="ppp1" />
<PointToPointInterface ifName="ppp2" />
<PointToPointInterface ifName="ppp3" />
</Router>
<Router name="R2" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" />
<BroadcastInterface ifName="eth0" areaID="0.0.0.0" />
</Router>
<Router name="R3" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" />
<PointToPointInterface ifName="ppp1" areaID="0.0.0.1" />
</Router>
<Router name="R4" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" />
<ExternalInterface ifName="eth0" advertisedExternalNetworkAddress="1.1.1.1" advertisedExternalNetworkMask="255.255.255.0" externalInterfaceOutputCost="10" externalInterfaceOutputType="Type1" />
</Router>
<Router name="R5" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" />
<ExternalInterface ifName="eth0" advertisedExternalNetworkAddress="1.1.1.1" advertisedExternalNetworkMask="255.255.255.0" externalInterfaceOutputCost="2" externalInterfaceOutputType="Type2" />
</Router>
<Router name="R6" RFC1583Compatible="true">
<PointToPointInterface ifName="ppp0" areaID="0.0.0.1" />
</Router>
</OSPFASConfig>
Results¶
The simulation demonstrates route selection hierarchy:
Multiple routers advertise the same destination (1.1.1.0/24) using different methods:
R2: Intra-area (RouterLsa), cost 1
R3: Inter-area (SummaryLsa), cost 2
R4: External Type-1 (NetworkLsa), cost 10
R5: External Type-2 (NetworkLsa), cost 1
At t=60s, the link between R1 and R2 breaks, changing available paths.
At t=70s, another link breaks, further changing available paths.
Throughout these changes, OSPF consistently applies its route preference hierarchy.
Intra-area routes are always preferred over inter-area routes, even if the inter-area route has lower cost.
Similarly, inter-area routes are preferred over external routes.
The routing tables clearly show OSPF selecting routes based on type hierarchy, not just cost, demonstrating the protocol’s design for stability and hierarchical routing.
Sources:
omnetpp.ini,
OSPF_Route_Selection.ned,
ASConfig_Route_Selection.xml
Discussion¶
Use this page in the GitHub issue tracker for commenting on this tutorial.