Sub topic 16
OSPF: Areas, Costs, and Designated Routers
This chapter assumes you know basic IP addressing and subnetting, what a routing table is, and how the link-state ideas from earlier chapters work: hello packets, flooding, the link-state database, and Dijkstra's algorithm. Here we look at how OSPF (Open Shortest Path First) packages those ideas for real networks.
Costs: OSPF's metric
OSPF assigns each interface a cost, and a path's cost is the sum of the outgoing interface costs along it. By default, Cisco IOS computes cost as reference bandwidth divided by interface bandwidth. The default reference bandwidth is 100 Mbps, so a 100 Mbps link costs 1 and a 10 Mbps link costs 10.
A common error follows from this. Any link of 100 Mbps or faster gets cost 1, which is rounded up from a fraction. OSPF then treats a 100 Mbps link and a 100 Gbps link as equal. Raise the reference bandwidth with auto-cost reference-bandwidth on every router, or set costs by hand on each interface.
Areas
Every router in an area holds the same link-state database, so a large flat network makes every router flood and recompute for every change anywhere. OSPF limits this by splitting the network into areas.
- Area 0 is the backbone. All other areas must connect to it.
- An Area Border Router (ABR) has interfaces in more than one area. It keeps a separate database for each area.
- An ABR does not pass detailed topology between areas. It summarizes the destinations in one area and advertises them into another as prefixes with a cost.
Inside an area, routers run Dijkstra's algorithm over the full topology. Between areas, routers behave somewhat like distance-vector: they see a prefix and a cost to reach it through an ABR, not the map beyond it. A link flapping in one area triggers SPF runs only inside that area.
Designated routers
On a broadcast network such as Ethernet, n routers could form n(n-1)/2 adjacencies and exchange LSAs over every pair. OSPF instead elects a Designated Router (DR) and a Backup Designated Router (BDR) on each segment. Other routers form full adjacencies only with the DR and BDR. They send updates to the DR, which floods them to the segment.
The election picks the highest interface priority, with the highest router ID breaking ties. It is not preemptive: a router that joins later with a higher priority does not displace the current DR. Priority 0 makes a router ineligible.
Configuration
router ospf 1
router-id 1.1.1.1
network 10.0.0.0 0.0.0.255 area 0The network command uses a wildcard mask. It enables OSPF on interfaces whose addresses match, and places them in area 0. Setting the router ID explicitly keeps it stable, since it is used for DR election and identifies the router in LSAs.
Exercise
A router joins an Ethernet segment with priority 200 while an existing router with priority 1 is DR. Does the new router become DR? Why or why not?
Show answer
No. DR election is not preemptive, so the existing DR keeps its role until it fails or its OSPF process restarts. The new router would only win a new election.
Exercise
Why would you change the reference bandwidth on a network with 1 Gbps and 10 Gbps links?
Show answer
With the default 100 Mbps reference, both links get cost 1, so OSPF cannot prefer the faster path. A higher reference bandwidth, applied consistently on all routers, gives them different costs.