OSPF (Open Shortest Path First) calculates the best path to each destination using the Dijkstra’s Algorithm (also known as the Shortest Path First (SPF) algorithm). The process involves multiple steps to ensure accurate and loop-free routing.
Step 1: Establish Neighbor Relationships
- OSPF routers discover and establish adjacency with neighbors via Hello packets.
- Neighbor parameters (e.g., Hello/Dead timers, Area ID) must match for adjacency to form.
- Once neighbors are established, OSPF routers exchange LSAs (Link-State Advertisements).
Step 2: Build the Link-State Database (LSDB)
- Each router creates an LSDB, which contains detailed information about the network topology.
- LSAs are exchanged via flooding to ensure all routers in the area have identical LSDBs.
- The LSDB is essentially a map of the entire network area.
Step 3: Run the SPF Algorithm
- Using the LSDB, each router independently runs Dijkstra’s SPF algorithm to calculate the shortest path to each destination.
- The algorithm starts with itself as the root node and calculates the shortest path to all other nodes.
Dijkstra’s Algorithm Key Steps:
- Mark the router itself as the starting point (Root).
- Assign an initial cost of 0 to itself and infinity to all other nodes.
- Examine all directly connected nodes, calculate the cost (using interface bandwidth), and record the lowest cost path.
- Mark the node with the lowest cost as “visited” and add it to the Shortest Path Tree (SPT).
- Repeat the process until all nodes are visited.
Step 4: Best Path Selection
- The best path is selected based on the lowest cumulative cost (metric).
- OSPF’s cost is calculated using this formula:
Cost=Reference BandwidthInterface Bandwidth\text{Cost} = \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}}Cost=Interface BandwidthReference Bandwidth
Default Reference Bandwidth: 100 Mbps (adjustable via auto-cost reference-bandwidth for higher-speed links).
| Bandwidth | Cost |
|---|---|
| 10 Mbps | 10 |
| 100 Mbps | 1 |
| 1 Gbps | 1 |
| 10 Gbps | 1 (unless reference bandwidth is adjusted) |
Step 5: Install Routes in the Routing Table
- The calculated best path is installed in the RIB (Routing Information Base).
- If multiple paths have the same cost (ECMP – Equal-Cost Multi-Path), OSPF can load balance traffic across these paths.
Step 6: Ongoing Maintenance
- OSPF continuously monitors network changes.
- When a link or router fails, OSPF triggers an SPF recalculation to converge quickly.
Example Network Topology
[R1] ----- 10 Mbps ----- [R2]
| |
|----- 100 Mbps ----- [R3]
- If R1 needs to reach R2:
- Path via R3 has a cost of 1 (100 Mbps).
- Path directly to R2 has a cost of 10 (10 Mbps).
- OSPF will prefer the R1 → R3 → R2 path.
Key Notes
✅ OSPF is loop-free due to the SPF algorithm.
✅ LSDB synchronization ensures all routers have a consistent view of the network.
✅ OSPF recalculations can be minimized by effective area design and summarization.
Leave a comment