OSPF Fundamentals and Neighbor Relationships
OSPF begins by establishing neighbor relationships between routers. Routers then exchange Link State Advertisements (LSAs) to build a complete network topology map.
How Neighbors Form
Routers send Hello packets at regular intervals to detect neighbors. On broadcast networks, the default is 10 seconds. On non-broadcast networks, it is 30 seconds. These packets contain Router ID, Area ID, authentication settings, and network mask.
For routers to become neighbors, they must match on:
- Hello interval and Dead interval
- Area ID
- Authentication parameters
Once neighbors are confirmed, routers move to the exchange state and share their Link State Databases.
Understanding OSPF Cost
OSPF uses cost as its metric. Cost is calculated as 100,000,000 divided by interface bandwidth in bits per second.
Example costs:
- 100 Mbps interface = cost of 1,000
- 1 Gbps interface = cost of 100
- 1.544 Mbps Serial = cost of 64,835
Faster interfaces always get lower costs. OSPF selects paths with the lowest total cost.
The Designated Router Role
On multi-access networks, routers elect a Designated Router (DR) and Backup Designated Router (BDR). The DR optimizes bandwidth by becoming the hub for adjacencies. Election is based on OSPF priority values and Router IDs. Understanding DR election is essential for exam success.
OSPF Area Design and Hierarchical Architecture
OSPF uses a two-level hierarchical design with areas. This design allows OSPF to scale to very large networks by limiting the scope of link-state updates.
Area Structure
Area 0, called the backbone, is the network core. All other areas must connect to the backbone to maintain connectivity. This hierarchical structure reduces memory and CPU requirements on individual routers.
Different router types emerge based on area connections:
- Internal routers: Exist entirely within a single area
- Area Border Routers (ABRs): Connect multiple areas
- Backbone routers: Reside in Area 0
- Autonomous System Boundary Routers (ASBRs): Connect to external routing domains
How Route Summarization Works
Each area maintains its own link-state database. Detailed topology information does not flood beyond area boundaries. Instead, ABRs summarize routes from one area and advertise them to others. This significantly reduces routing table size on routers that do not need every path.
Area IDs are 32-bit values written in dotted decimal notation. Common examples include Area 0 for backbone, Area 1 for a branch office, and Area 2 for another region.
LSAs, Link State Database, and Route Calculation
Link State Advertisements (LSAs) are the building blocks of OSPF's topology exchange. The CCNA focuses on LSA Types 1 through 5.
LSA Types
- Type 1 (Router LSA): Originated by every router. Describes directly connected links within an area.
- Type 2 (Network LSA): Originated by the DR on multi-access segments. Describes all routers connected to that segment.
- Type 3 (Summary LSA): Originated by ABRs. Advertises routes between areas.
- Type 4 (Summary LSA): Describes routes to ASBRs.
- Type 5 (External LSA): Describes routes outside the OSPF autonomous system.
Building the Link State Database
Every router builds a complete Link State Database (LSDB) containing all LSAs for areas it connects to. The LSDB is flooded using a controlled process. Each router forwards LSAs out all interfaces except the one where the LSA arrived. This ensures all routers in an area receive every LSA.
How Route Calculation Works
Once the LSDB converges, each router runs Dijkstra's shortest path first algorithm. This algorithm calculates the best routes to all known destinations. The router builds a shortest path tree with itself at the root.
When network changes occur, routers recalculate the shortest path tree in an SPF recalculation. OSPF includes timers to delay recalculations and prevent thrashing during unstable conditions.
OSPF Configuration, Timers, and Troubleshooting Commands
Configuring OSPF on a Cisco router requires entering OSPF configuration mode. You specify which networks will participate in OSPF routing.
Basic Configuration Steps
Use the command "router ospf process-id" to enter OSPF mode. The process ID ranges from 1 to 65535 and is locally significant. Next, define which interfaces participate using the network command with wildcard mask.
Example configuration:
network 192.168.1.0 0.0.0.255 area 0
This configures all interfaces in the 192.168.1.0/24 network for OSPF in Area 0.
Router ID and Timers
The Router ID is a critical 32-bit identifier unique within the OSPF domain. It defaults to the highest loopback IP address. You can set it explicitly with the "router-id" command.
Key timers include:
- Hello interval: Default 10 seconds on broadcast networks
- Dead interval: Default 40 seconds (4 times the Hello interval)
- SPF calculation timer: Delays recalculations after network changes
Timers must match between neighbors to form adjacencies.
Essential Troubleshooting Commands
- "show ip ospf" - View OSPF process information
- "show ip ospf neighbor" - Display neighbor relationships and states
- "show ip ospf database" - Examine the Link State Database
- "show ip route ospf" - View OSPF-derived routes in the routing table
- "show ip ospf interface" - Reveal interface-specific OSPF information
Common configuration issues include mismatched area IDs, incompatible interface masks, and network statements that do not match actual interface configurations.
OSPF Metrics, Path Selection, and Convergence
Understanding OSPF's metric calculation and route selection is essential for predicting network behavior. This knowledge directly impacts CCNA exam success.
How OSPF Selects Paths
The OSPF metric called cost is determined by dividing reference bandwidth by interface bandwidth. The default reference bandwidth is 100 Mbps. A Serial interface at 1.544 Mbps has cost 64,835. A Fast Ethernet at 100 Mbps has cost 1.
The total cost of a path is the sum of costs along all interfaces. OSPF selects the path with the lowest total cost. If equal-cost paths exist, OSPF can load-balance traffic across up to 16 paths by default.
Adjust the reference bandwidth using the "ospf auto-cost reference-bandwidth" command. This is critical for networks with interfaces faster than 100 Mbps.
OSPF Convergence Speed
OSPF converges quickly when network changes occur. Affected routers generate new LSAs and flood them throughout the network within seconds. The shortest path tree recalculates quickly, allowing traffic to reroute around failures.
However, during convergence, some routers may have inconsistent routing information. This can temporarily cause packet loss or loops. The SPF hold timer and SPF start timer balance convergence speed against CPU utilization.
Administrative Distance and Redistribution
Administrative distance is 110 for OSPF. This value determines how much trust is placed in OSPF routes compared to other routing sources. Default routes can be injected using the "default-information originate" command. Specific routes can be redistributed from other routing domains.
