Tutorial 4: OSPF – Architecture and Operation Expanded

Table of Contents

  1. Learning Objectives
  2. Overview
  3. Detailed Technical Content
  4. Quiz
  5. Exercises
  6. Homework
  7. Summary

Learning Objectives

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:

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).

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:

4. OSPF Packet Types and Formats

OSPF packets are encapsulated in IP (protocol 89). There are five types:

TypeNamePurpose
1HelloDiscover and maintain neighbors; used for DR/BDR election.
2Database Description (DBD)Summarize the LSDB content during adjacency establishment.
3Link State Request (LSR)Request specific LSAs from a neighbor.
4Link State Update (LSU)Carry LSAs; used to flood and respond to LSRs.
5Link 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:

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:

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 AnswerAll 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 AnswerTo limit LSA flooding and reduce the size of the link-state database, improving scalability.

Question 3: Name the five OSPF packet types.

Show AnswerHello, 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 Answer2-Way.

Question 5: Which router generates Type 2 (Network) LSAs?

Show AnswerThe Designated Router (DR) on a multi-access network.

Question 6: What is the purpose of Type 3 (Summary) LSAs?

Show AnswerABRs 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 AnswerType 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 AnswerThe 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 AnswerTo take over as DR if the DR fails, ensuring quick recovery.

Question 10: What authentication modes does OSPF support?

Show AnswerNull (no authentication), plaintext password, and cryptographic (MD5, SHA).

Question 11: How does OSPFv3 differ from OSPFv2 in terms of authentication?

Show AnswerOSPFv3 does not have built-in authentication; it relies on IPv6 IPsec for security.

Question 12: What is an ABR in OSPF?

Show AnswerAn Area Border Router, which connects to multiple areas and maintains separate LSDBs for each.

Question 13: What is an ASBR?

Show AnswerAn 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 AnswerCost = 100/1000 = 0.1, rounded to 1 (since costs are integers).

Question 15: What is the purpose of the Database Description (DBD) packet?

Show AnswerTo 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 AnswerTo 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 AnswerInternal: 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 AnswerA 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 AnswerAll 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 AnswerIt is used in DR/BDR election on multi-access networks.

Question 21: How does OSPF support Variable Length Subnet Mask (VLSM)?

Show AnswerLSAs include the subnet mask, allowing OSPF to carry classless information.

Question 22: What is a Not-So-Stubby Area (NSSA)?

Show AnswerAn 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.

Exercise 2: Explain the OSPF neighbor state machine step by step from Down to Full.

Show Sample Solution
  1. Down: No hellos received.
  2. Init: Hello received with neighbor's Router ID not listed.
  3. 2-Way: Hello received with own Router ID included; bidirectional communication established. On multi-access, DR/BDR election occurs.
  4. Exstart: Master/slave negotiation; first DBD exchanged.
  5. Exchange: DBD packets exchanged describing the LSDB.
  6. Loading: LSR/LSU exchange for missing LSAs.
  7. 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.


End of Tutorial 4 .