Sub topic 16
OSPF: Areas, Flooding and Cost
Assume you know IPv4 prefixes, routers, weighted graphs, and the basic difference between routing and forwarding. Open Shortest Path First (OSPF) is a link-state routing protocol used inside one autonomous system. An autonomous system is a network managed by one organization.
How OSPF builds routes
Each OSPF router describes its directly connected links in a link-state advertisement (LSA). An LSA contains information such as the neighboring router and the link's cost. Routers flood these advertisements so that every router in the same OSPF area builds the same link-state database.
Flooding means forwarding new control information to all relevant neighbors, while avoiding repeated processing of the same LSA. Each LSA has an identifier and sequence number. A newer sequence number replaces an older copy.
After building the database, each router runs Dijkstra's shortest-path algorithm with itself as the source. The resulting shortest-path tree determines the next hop for each destination prefix.
For example, from router A to router D, the path A-B-C-D costs 2 + 1 + 1 = 4. The direct-looking alternative A-B-D costs 2 + 4 = 6. OSPF therefore selects the path through C.
OSPF cost
OSPF usually computes interface cost as:
reference bandwidth / interface bandwidth
The reference bandwidth is commonly 100 Mbps in older configurations. An administrator can change it, especially in networks containing links faster than 100 Mbps. OSPF chooses the path with the lowest total cost, not necessarily the path with the fewest hops.
| Link property | Effect on OSPF |
|---|---|
| Higher bandwidth | Usually lower interface cost |
| More links in a path | Usually higher total cost |
| Administrative cost change | Can deliberately influence path selection |
| Equal total cost | May permit equal-cost multipath |
Areas and route summarization
Large OSPF networks are divided into areas. Area 0 is the backbone area. Other areas should connect to area 0 for normal inter-area routing.
An Area Border Router (ABR) connects two or more areas. It maintains separate link-state databases for those areas and advertises summarized reachability between them. This limits flooding and reduces the size of each shortest-path calculation.
An Autonomous System Boundary Router (ASBR) injects routes learned from another routing system, such as static routes or BGP, into OSPF.
Within an area, routers receive detailed link information. Between areas, routers generally receive prefix reachability and cost summaries rather than every internal link.
Exam approach
For a small OSPF problem:
- Write each link and its cost.
- Build the graph visible to the router.
- Run Dijkstra's algorithm from the source router.
- Add costs along competing paths.
- Select the smallest total cost and identify the first hop.
Exercise
A router has two paths to a destination. Path 1 has link costs 3, 2, and 4. Path 2 has link costs 5 and 5. Which path does OSPF select?
Show answer
Path 1 costs 9. Path 2 costs 10. OSPF selects Path 1, even though it uses more links.