Table Of Contents
Table Of Contents

Step 24. OSPF Path Selection - Suboptimal routes

Goals

The goal of this step is to demonstrate scenarios where OSPF’s route selection hierarchy can lead to suboptimal routing.

Because OSPF always prefers intra-area routes over inter-area routes (regardless of cost), there are situations where the protocol selects a longer path within an area instead of a shorter path that crosses area boundaries.

This is an intentional design trade-off: OSPF prioritizes routing stability and hierarchical structure over always finding the absolute shortest path.

Configuration

This step uses a topology where an intra-area path is longer than an available inter-area path.

../../../_images/OSPF_Suboptimal.png

The configuration in omnetpp.ini is the following:

[Config Step24]
description = "OSPF Path Selection - Suboptimal routes"
network = OSPF_Suboptimal

# host0 pings host6 and the following route is used by the OSPF that is not optimal:
# R1--> R2 --> R4 --> R5 --> R3 --> R7 --> 10.0.0.52
# this is because intra-area routes are always prefered by inter-area routes even if
# they have higher total cost.

*.configurator.config = xml("<config> \
                                <interface hosts='**' address='10.x.x.x' netmask='255.x.x.x'/> \
                                <route hosts='host*' destination='*' netmask='0.0.0.0' interface='eth0' /> \
                             </config>")

# application parameters
*.host0.numApps = 1
*.host0.app[0].typename = "PingApp"
*.host0.app[0].destAddr = "host6"
*.host0.app[0].startTime = 60s

*.R*.ospf.ospfConfig = xmldoc("ASConfig_Suboptimal.xml")

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="R2>R4" mask="R2>R4" />
    <AddressRange address="R2>R6" mask="R2>R6" />      
    
    <AddressRange address="R3>R5" mask="R3>R5" />
    <AddressRange address="R3>R7" mask="R3>R7" />      
    
    <AddressRange address="R4>R2" mask="R4>R2" />
    <AddressRange address="R4>R5" mask="R4>R5" />   
    <AddressRange address="R4>switch2" mask="R4>switch2" /> 
    
    <AddressRange address="R5>R4" mask="R5>R4" />
    <AddressRange address="R5>R3" mask="R5>R3" />   
    <AddressRange address="R5>switch3" mask="R5>switch3" /> 
    
    <AddressRange address="R6>R2" mask="R6>R2" />
    <AddressRange address="R6>R7" mask="R6>R7" />
    <AddressRange address="R6>switch4" mask="R6>switch4" />
    
    <AddressRange address="R7>R6" mask="R7>R6" />
    <AddressRange address="R7>R3" mask="R7>R3" />
    <AddressRange address="R7>host6" mask="R7>host6" />    
  </Area>

  <!-- Routers -->
  <Router name="R1" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.0" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.0" interfaceMode="Passive" />
  </Router>

  <Router name="R2" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.0" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.0" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" interfaceOutputCost="10" />
    <BroadcastInterface ifName="eth3" areaID="0.0.0.1" />
  </Router>

  <Router name="R3" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.0" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth3" areaID="0.0.0.0" interfaceMode="Passive" />
  </Router>

  <Router name="R4" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" interfaceMode="Passive" />
  </Router>

  <Router name="R5" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" interfaceMode="Passive" />
  </Router>
   
  <Router name="R6" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" interfaceMode="Passive" />
  </Router>
  
  <Router name="R7" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" />
    <BroadcastInterface ifName="eth2" areaID="0.0.0.1" interfaceMode="Passive" />
  </Router>

</OSPFASConfig>

Results

The simulation demonstrates suboptimal routing:

  1. host0 pings host6.

  2. An inter-area path R1 → R7 exists with low cost.

  3. However, an intra-area path R1 → R2 → R4 → R5 → R3 → R7 also exists.

  4. OSPF selects the longer intra-area path because intra-area routes are always preferred over inter-area routes.

  5. The traffic follows the suboptimal path: R1 → R2 → R4 → R5 → R3 → R7 → 10.0.0.52

This demonstrates that OSPF’s route preference hierarchy can lead to suboptimal paths in certain topologies, which is an acceptable trade-off for the benefits of hierarchical routing (scalability, stability, summarization).

Sources: omnetpp.ini, OSPF_Suboptimal.ned, ASConfig_Suboptimal.xml

Discussion

Use this page in the GitHub issue tracker for commenting on this tutorial.