Tutorial 4: OSPF – Architecture and Operation Expanded
Learning Objectives
- Describe the OSPF architecture, including its hierarchical area structure and the role of the backbone area.
- Explain the OSPF neighbor discovery and adjacency formation process, including the state machine.
- Identify and differentiate the five OSPF packet types and their purposes.
- Describe the Designated Router (DR) and Backup DR election process and their roles in multi-access networks.
- Analyze the different LSA types (Types 1–5, 7) and understand their use in building the link-state database.
- Explain how OSPF computes routes using Dijkstra's algorithm and how it handles inter-area and external routes.
- Describe the authentication mechanisms supported by OSPF (plaintext, MD5, SHA).
- Compare OSPFv2 (IPv4) and OSPFv3 (IPv6) in terms of protocol differences and enhancements.
- Discuss advanced topics such as OSPF traffic engineering (TE) and integration with MPLS.
Overview
Open Shortest Path First (OSPF) is a widely deployed link-state Interior Gateway Protocol (IGP) used within Autonomous Systems. It is based on the principles of link-state routing described in Tutorial 3, but adds sophisticated mechanisms for scalability, security, and multi-vendor interoperability. OSPF organizes routers into areas to reduce the scope of LSA flooding and to limit the size of the link-state database. It supports classless routing, variable-length subnet masks (VLSM), and authentication. OSPFv2 is defined for IPv4, while OSPFv3 supports IPv6. This tutorial provides a deep dive into OSPF architecture, packet types, neighbor state machine, DR/BDR election, LSA types, route calculation, authentication, and advanced topics like traffic engineering.
Detailed Technical and Theoretical Content
1. OSPF Overview and History
OSPF was developed by the IETF (RFC 2328 for OSPFv2, RFC 5340 for OSPFv3) as a link-state IGP. It is an open standard, ensuring interoperability across different vendors. OSPF uses the Dijkstra algorithm to compute the shortest path tree. Key features include:
- Fast convergence (sub-second with BFD).
- Support for multiple equal-cost paths (ECMP).
- Hierarchical routing via areas.
- Type of Service (TOS) routing (now deprecated).
- Authentication (plaintext, MD5, SHA).
2. OSPF Areas and Hierarchical Design
An OSPF domain is divided into areas to limit the propagation of LSAs. Area 0 is the backbone area; all other areas must connect to the backbone (physically or via virtual links).
- Internal routers: Have all interfaces in the same area.
- Area Border Routers (ABRs): Connect to multiple areas; maintain separate LSDBs for each area and summarize routes.
- Autonomous System Boundary Routers (ASBRs): Connect to external routing domains (e.g., other ASes or redistributed routes).
Route summarization at ABRs reduces the size of routing tables and LSDBs.
3. OSPF Neighbor Relationships and State Machine
OSPF routers discover neighbors via Hello packets on each interface. They then form adjacencies to exchange LSAs. The neighbor state machine has the following states:
- Down: Initial state, no hello received.
- Attempt: Only on non-broadcast networks (NBMA).
- Init: Hello received, but router ID not in the hello.
- 2-Way: Bidirectional communication established. On multi-access, DR/BDR election occurs here.
- Exstart: Master/slave election for database synchronization.
- Exchange: Database Description (DBD) packets exchanged to describe the LSDB.
- Loading: Link State Request (LSR) and Link State Update (LSU) packets sent for missing LSAs.
- Full: Fully adjacent; databases are synchronized.
4. OSPF Packet Types and Formats
OSPF packets are encapsulated in IP (protocol 89). There are five types:
| Type | Name | Purpose |
| 1 | Hello | Discover and maintain neighbors; used for DR/BDR election. |
| 2 | Database Description (DBD) | Summarize the LSDB content during adjacency establishment. |
| 3 | Link State Request (LSR) | Request specific LSAs from a neighbor. |
| 4 | Link State Update (LSU) | Carry LSAs; used to flood and respond to LSRs. |
| 5 | Link State Acknowledgment (LSAck) | Acknowledge receipt of LSU packets. |
All OSPF packets share a common header with fields: Version, Type, Packet Length, Router ID, Area ID, Checksum, AuType, and Authentication data.
5. Designated Router (DR) and Backup DR Election
On multi-access networks (e.g., Ethernet), many routers could be connected, leading to O(n²) adjacencies. To reduce this, OSPF elects a Designated Router (DR) and a Backup DR (BDR). All routers form full adjacencies only with the DR and BDR. The DR is responsible for flooding LSAs on the segment. Election is based on Router Priority (0–255, default 1; 0 means not eligible). The router with the highest priority becomes DR; tie broken by highest Router ID.
6. OSPF LSA Types and Their Roles
OSPF uses several LSA types to convey different kinds of routing information:
- Type 1 (Router LSA): Describes links on the router, their costs, and neighbors. Generated by every router.
- Type 2 (Network LSA): Generated by the DR on a multi-access network; lists all routers attached to the network.
- Type 3 (Summary LSA): Generated by ABRs to summarize routes from one area to another.
- Type 4 (ASBR Summary LSA): Generated by ABRs to advertise the location of an ASBR.
- Type 5 (External LSA): Generated by ASBRs to advertise routes outside the OSPF domain.
- Type 7 (NSSA External LSA): Used in Not-So-Stubby Areas (NSSA) to carry external routes.
7. Route Calculation and the SPF Algorithm
Each router runs Dijkstra on its LSDB to compute the shortest path to all destinations. For inter-area routes, the ABR injects Type 3 LSAs with the cost from the ABR to the destination. The total cost is the sum of the cost from the router to the ABR plus the cost in the Type 3 LSA. External routes (Type 5) have a metric type (E1 or E2). E1 cost includes the cost to the ASBR; E2 cost is just the external cost.
8. OSPF Authentication and Security
OSPF supports three authentication modes: null, plaintext password, and cryptographic (MD5, SHA). Cryptographic authentication uses a message digest to prevent tampering. Keys are configured per interface. Authentication is optional but recommended to prevent unauthorized routers from joining the OSPF domain.
9. OSPFv2 vs OSPFv3
OSPFv3 (RFC 5340) supports IPv6. Key differences:
- Uses IPv6 link-local addresses for neighbor discovery.
- LSAs carry IPv6 prefixes.
- New LSA types: Type 8 (Link LSA), Type 9 (Intra-Area Prefix LSA).
- Authentication is handled by IPv6 IPsec rather than built-in authentication.
- Can support multiple instances per interface.
10. Advanced: OSPF Traffic Engineering and MPLS Integration
OSPF can be used with MPLS (Multiprotocol Label Switching) for traffic engineering. OSPF-TE (RFC 3630) extends OSPF to carry TE information (bandwidth, administrative groups) using opaque LSAs (Type 10). This enables MPLS-TE tunnels to compute constraint-based paths. Additionally, OSPF supports segment routing (SR) with extensions (OSPF-SR) for source routing.
Figure 1: OSPF Area Hierarchy
+-----------------------+
| Backbone Area 0 |
| (ABR1)---(ABR2) |
+-----------------------+
| |
+------+ +------+
| Area 1 | Area 2
| (Internal routers) | (Internal routers)
+-------------------------+
Quiz
Answer each question; check your understanding by revealing the answer.
Question 1: What is the role of the OSPF backbone area (Area 0)?
Show Answer
All other areas must connect to Area 0; it is the central hub for inter-area routing.
Question 2: What is the purpose of OSPF areas?
Show Answer
To limit LSA flooding and reduce the size of the link-state database, improving scalability.
Question 3: Name the five OSPF packet types.
Show Answer
Hello, Database Description (DBD), Link State Request (LSR), Link State Update (LSU), Link State Acknowledgment (LSAck).
Question 4: What is the state after bidirectional communication is established (neighbor sees its own Router ID in the Hello)?
Show Answer
2-Way.
Question 5: Which router generates Type 2 (Network) LSAs?
Show Answer
The Designated Router (DR) on a multi-access network.
Question 6: What is the purpose of Type 3 (Summary) LSAs?
Show Answer
ABRs generate them to advertise routes from one area to another.
Question 7: What is the difference between Type 5 and Type 7 external LSAs?
Show Answer
Type 5 is used in regular areas; Type 7 is used in Not-So-Stubby Areas (NSSA) to carry external routes, which are translated to Type 5 at the ABR.
Question 8: How is the Designated Router (DR) elected on a multi-access network?
Show Answer
The router with the highest Router Priority becomes DR; if tie, the highest Router ID wins. A priority of 0 disqualifies a router from being DR/BDR.
Question 9: What is the purpose of the Backup DR (BDR)?
Show Answer
To take over as DR if the DR fails, ensuring quick recovery.
Question 10: What authentication modes does OSPF support?
Show Answer
Null (no authentication), plaintext password, and cryptographic (MD5, SHA).
Question 11: How does OSPFv3 differ from OSPFv2 in terms of authentication?
Show Answer
OSPFv3 does not have built-in authentication; it relies on IPv6 IPsec for security.
Question 12: What is an ABR in OSPF?
Show Answer
An Area Border Router, which connects to multiple areas and maintains separate LSDBs for each.
Question 13: What is an ASBR?
Show Answer
An Autonomous System Boundary Router, which connects the OSPF domain to external routing domains.
Question 14: What is the default OSPF cost of a 1 Gbps Ethernet link using the default reference bandwidth of 100 Mbps?
Show Answer
Cost = 100/1000 = 0.1, rounded to 1 (since costs are integers).
Question 15: What is the purpose of the Database Description (DBD) packet?
Show Answer
To exchange a summary of the LSDB during adjacency establishment so routers can determine which LSAs they need.
Question 16: What is the purpose of the Link State Request (LSR) packet?
Show Answer
To request specific LSAs that a router does not have or has outdated versions.
Question 17: What is the difference between internal, backbone, and stub areas?
Show Answer
Internal: not ABR/ASBR; Backbone: Area 0; Stub: does not accept external routes (Type 5 LSAs), uses default route.
Question 18: What is an OSPF virtual link and when is it used?
Show Answer
A virtual link connects a non-backbone area to the backbone through another area when a physical connection to Area 0 is not possible.
Question 19: How does OSPF prevent routing loops in a multi-area environment?
Show Answer
All inter-area traffic must go through the backbone, and ABRs use split-horizon-like rules to prevent loops.
Question 20: What is the purpose of the Router Priority in OSPF Hello packets?
Show Answer
It is used in DR/BDR election on multi-access networks.
Question 21: How does OSPF support Variable Length Subnet Mask (VLSM)?
Show Answer
LSAs include the subnet mask, allowing OSPF to carry classless information.
Question 22: What is a Not-So-Stubby Area (NSSA)?
Show Answer
An NSSA is a stub area that can import external routes as Type 7 LSAs, which are translated to Type 5 by the ABR.
Exercises
Work through these problems; sample solutions are hidden.
Exercise 1: Draw an OSPF topology with three areas (Area 0, Area 1, Area 2). Label the routers as internal, ABR, and ASBR. Explain which LSA types are generated in each area.
Show Sample Solution
Area 0: backbone with ABR1, ABR2, internal router R0. Area 1: ABR1, internal routers R1, R2. Area 2: ABR2, ASBR (connected to external network), internal router R3.
- In Area 1: Type 1 from all routers, Type 2 from DR on multi-access segments.
- ABR1 generates Type 3 for routes from Area 1 to Area 0.
- In Area 2: Type 1, Type 2, and Type 5 from ASBR (or Type 7 if NSSA).
- ABR2 generates Type 3 for Area 2 routes to Area 0.
- ABRs inject Type 4 if ASBR is in a different area.
Exercise 2: Explain the OSPF neighbor state machine step by step from Down to Full.
Show Sample Solution
- Down: No hellos received.
- Init: Hello received with neighbor's Router ID not listed.
- 2-Way: Hello received with own Router ID included; bidirectional communication established. On multi-access, DR/BDR election occurs.
- Exstart: Master/slave negotiation; first DBD exchanged.
- Exchange: DBD packets exchanged describing the LSDB.
- Loading: LSR/LSU exchange for missing LSAs.
- Full: Databases are synchronized; adjacency is fully established.
Exercise 3: On an Ethernet segment with three OSPF routers (A: priority 10, ID 1.1.1.1; B: priority 5, ID 2.2.2.2; C: priority 10, ID 3.3.3.3), determine the DR and BDR after election.
Show Sample Solution
Highest priority: A and C both have 10. Tie broken by highest Router ID: C (3.3.3.3) > A (1.1.1.1), so C becomes DR. BDR is the next highest: A (priority 10) over B (priority 5), so A becomes BDR. B becomes DROTHER.
Exercise 4: What is the purpose of the MTU mismatch detection in OSPF? When does it occur?
Show Sample Solution
OSPF routers check MTU in DBD packets during Exstart/Exchange. If MTUs differ, the adjacency will not form (stuck in Exstart). This prevents fragmentation issues.
Exercise 5: Explain how OSPF handles external routes with Type 1 (E1) versus Type 2 (E2) metrics. Which is preferred?
Show Sample Solution
E1 metric = external cost + cost to ASBR; E2 metric = external cost only (internal cost not added). E1 is preferred over E2 because it reflects the total path cost.
Exercise 6: Describe the process of route summarization at an ABR. Provide an example.
Show Sample Solution
ABR summarizes multiple subnets into a single summary LSA (Type 3). Example: Area 1 has 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24; ABR advertises 192.168.0.0/22 to Area 0.
Exercise 7: What is the effect of setting a router's priority to 0 on a multi-access network?
Show Sample Solution
The router is not eligible to become DR or BDR; it will remain a DROTHER and only form full adjacencies with DR and BDR.
Exercise 8: How does OSPF handle a router failure in a multi-area network? Trace the LSA flooding.
Show Sample Solution
The failed router's neighbors detect the absence of Hellos; they generate a new Type 1 LSA without the failed links and flood it. ABRs may generate new Type 3 LSAs if inter-area reachability changes. All routers recompute SPF.
Exercise 9: Compare the use of OSPF areas with BGP route reflection in terms of scaling.
Show Sample Solution
Both limit update propagation; areas restrict LSA flooding, route reflectors reduce iBGP mesh. OSPF areas are for intra-AS; BGP RR for inter-AS. OSPF summarises, BGP aggregates.
Exercise 10: Configure OSPF on a simple router (sample Cisco commands) for a single area, with authentication.
Show Sample Solution
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
area 0 authentication message-digest
interface Ethernet0/0
ip ospf message-digest-key 1 md5 mypassword
Homework Assignments
These questions require deeper thought and research. Write comprehensive answers.
Homework 1: Explain in detail the OSPF LSA types and their flooding scope. How does the LSA age and sequence number mechanism work?
Show Answer Outline
Describe LSA types 1–5, 7, 8, 9; flooding scope: Type 1,2 within area; Type 3,4,5 flooded throughout the AS (except stub areas); Type 7 within NSSA. Age increments, max age 3600, sequence number used to determine freshness.
Homework 2: Compare OSPF and IS-IS. What are the key similarities and differences in their operation and design?
Show Answer Outline
Both are link-state IGPs; OSPF runs over IP, IS-IS runs over Layer 2; OSPF uses areas, IS-IS uses levels; OSPF has more LSA types; IS-IS is more scalable in large ISP networks.
Homework 3: Design a multi-area OSPF network for a medium-sized enterprise with four sites. Describe the addressing plan, area assignments, and summarization strategy.
Show Answer Outline
Assign each site an area (e.g., area 1,2,3), backbone area 0. Use private IP ranges, summarize at ABRs. Discuss redundancy with multiple ABRs.
Homework 4: Research and explain the OSPF "stub area" and "totally stubby area" concepts. What are the benefits and limitations?
Show Answer Outline
Stub area does not receive Type 5 LSAs; uses default route. Totally stubby also blocks Type 3 summaries except default. Benefits: reduce LSDB size, memory, and CPU.
Homework 5: How does OSPF support traffic engineering? Explain OSPF-TE opaque LSAs and their role in MPLS-TE.
Show Answer Outline
OSPF-TE floods TE information (bandwidth, affinity) in Type 10 opaque LSAs. This information is used by MPLS-TE head-end routers to compute constraint-based paths.
Homework 6: Investigate the OSPF Hello protocol parameters (Hello interval, Dead interval, etc.) and discuss how tuning them affects convergence and stability.
Show Answer Outline
Lower intervals improve convergence but increase overhead and may cause flapping. Higher intervals reduce overhead but slow detection. Need to balance.
Homework 7: Describe the process of redistributing routes from RIP into OSPF. What are the potential pitfalls and how are they mitigated?
Show Answer Outline
Use redistribution at ASBR; set metric and metric-type. Pitfalls: routing loops, suboptimal paths; use administrative distance and route maps.
Homework 8: Explain the concept of "OSPF route summarization" and the difference between inter-area and external summarization.
Show Answer Outline
Inter-area summarization at ABR (Type 3); external summarization at ASBR (Type 5). Both reduce table size.
Homework 9: How does OSPFv3 handle multiple instances on the same link? Provide a use case.
Show Answer Outline
OSPFv3 supports multiple instances per interface via the Instance ID field; used in VPN contexts where different routing domains share the same link.
Homework 10: Compare the SPF computation in OSPF with the computation in IS-IS. Are there any differences in their Dijkstra implementation?
Show Answer Outline
Both use Dijkstra; differences in metrics (IS-IS uses narrow/wide metrics), but the algorithm is the same. IS-IS may have faster convergence in some implementations.
Homework 11: Design an OSPF authentication strategy for a large enterprise using cryptographic authentication. Discuss key management and rotation.
Show Answer Outline
Use MD5 or SHA with keys per interface; plan for key rollover using multiple keys; consider using a central key management system.
Homework 12: Explain the difference between OSPF's "external type 1" and "external type 2" metrics. When would you use each?
Show Answer Outline
Type 1 adds internal cost to external; Type 2 only uses external cost. Use Type 1 when you want the total cost to reflect internal path; Type 2 when you want to preserve the external metric.
Summary
This tutorial provided a thorough examination of OSPF architecture and operation. We explored areas, the neighbor state machine, packet types, DR/BDR election, LSA types, route calculation, authentication, and OSPFv3. Advanced topics included OSPF-TE and MPLS integration. OSPF is a robust, scalable IGP that forms the backbone of many enterprise and ISP networks. Understanding its inner workings is essential for network engineers.