OSPF (Open Shortest Path First) Routing Protocol

OSPF Open Shortest Path First

What is OSPF Routing Protocol?

Open Shortest Path First (OSPF) is a Link State Routing Protocol primarily designed for larger networks.

Key Characteristics

  • Hierarchical Network Design: OSPF uses areas to create a hierarchical network design.
  • Neighbor Relationships: OSPF forms neighbor relationships with routers within the same area.
  • Link State Advertisements (LSAs): Instead of using distance, OSPF advertises the status of connected links using LSAs.
  • Triggered Updates: OSPF advertises updates only when there are changes in link status, refreshing LSAs every 30 minutes.
  • Multicast Traffic: OSPF traffic is multicast to 224.0.0.5 for all OSPF routers or 224.0.0.6 for all designated routers.
  • Dijkstra Algorithm: OSPF uses the Dijkstra Shortest Path First algorithm to find the shortest path.
  • Classless Protocol: OSPF supports Variable Length Subnet Masks (VLSMs).
  • IP Routing Only: OSPF supports only IP routing.
  • Administrative Distance: OSPF’s administrative distance is 110.
  • Cost-Based Path Selection: OSPF uses cost, computed based on link bandwidth, to determine the best path.

OSPF Routing Tables

  • Neighbor Table: Lists all neighbor routers.
  • Topology Table: Contains all possible routes to known networks within an area.
  • Routing Table: Contains the best path for the known networks.

OSPF Neighbors Table

In which OSPF Open Shortest Path First forms neighbor relationships with adjacent routers to share hello packets within the area. Each OSPF router is identified by its router ID, which can be determined by:

  1. Manually specifying the router ID.
  2. Using the highest loopback address if available.
  3. Using the highest physical address if no loopback address is configured.

By default, OSPF sends hello packets every 10 seconds for broadcast and point-to-point interfaces, and every 30 seconds for non-broadcast and non-point-to-point interfaces. The dead interval is 40 seconds for point-to-point and broadcast, and 120 seconds for non-broadcast and non-point-to-point interfaces. These timers can be manually adjusted:

Router(config-if)# ip ospf hello-interval 15
Router(config-if)# ip ospf dead-interval 30

OSPF forms neighbor relationships if certain parameters match identically on all routers:

  • Area ID
  • Area Type
  • Prefix
  • Subnet Mask
  • Hello Interval
  • Dead Interval
  • Network Type
  • Authentication

Hello packets also contain the list of all router IDs to facilitate quick convergence if a link goes down.

Neighbor Table

  • Router ID of each neighbor
  • Current status of each neighbor router
  • Directly connected interfaces with neighbors
  • IP address of remote neighbors

Election of DR and BDR

To understand the election process for the DR and BDR lets discuss with the example with small topology

OSPF Open Shortest Path First

In a multi-access network such as Ethernet, there is a possibility that an OSPF router forms many relationships with neighboring routers. Using the formula n(nāˆ’1)/2, where n is the number of routers, 6 separate adjacencies are required to make a fully meshed network if there are 4 routers. If one link goes down, it spreads LSAs (Link State Advertisements) to all other routers. Those routers then propagate these LSAs to other connected routers, resulting in significant bandwidth and process load.

To prevent this, OSPF elects a Designated Router (DR). If a link goes down, advertisements are sent only to the DR, which then forwards them to the Backup Designated Router (BDR) if necessary. The election of DR and BDR depends on OSPF priority. The highest priority wins the election and becomes the DR, while the second highest becomes the BDR. If there is a tie based on priority, the router with the highest router ID becomes the DR.

By default, OSPF router priority is 1. Setting the priority to 0 excludes the router from the election process. OSPF priority can be adjusted manually using the following command:

Router(config-if)# ip ospf priority 120

where <value> is the desired priority level.

Neighbor States

OSPF hello packets pass through several stages to establish neighbor relationships:

  • Down: No hello packets are received from neighbors.
  • Init: Hello packets are heard from neighbors.
  • 2-Way: Bidirectional communication is established, and DR and BDR are elected.
  • ExStart: Begins sharing link state information and forming master/slave relationships.
  • Exchange: Routers exchange Database Descriptors (DBDs) containing the topology database.
  • Loading: Routers fully exchange LSAs and share their topology databases.
  • Full: Routers are fully synchronized, ensuring identical topology tables.

OSPF Open Shortest Path First Network Types

It operates differently across various network topologies:

  • Broadcast Multi-Access:
    • DRs and BDRs are elected.
    • Traffic to DRs and BDRs is multicast to 224.0.0.6; traffic to other routers is multicast to 224.0.0.5.
    • Neighbors are not manually specified.
    • Examples: Ethernet, Token Ring.
  • Point-to-Point:
    • DRs and BDRs are not elected.
    • Traffic is multicast to 224.0.0.5.
    • Neighbors are not manually specified.
    • Examples: Point-to-point T1.
  • Point-to-Multipoint:
    • DRs and BDRs are not elected.
    • Traffic is multicast to 224.0.0.5.
    • Neighbors are not manually specified.
    • Examples: Point-to-multipoint Frame Relay.
  • Non-Broadcast Multi-Access (NBMA):
    • DRs and BDRs are elected.
    • Traffic is unicast instead of multicast.
    • Neighbors must be manually configured.

OSPF Hierarchy

OSPF Hierarchy

The OSPF hierarchy system divides every autonomous system into individual areas. OSPF traffic can be intra-area (within one area), inter-area (between areas), or external (from different autonomous systems).

OSPF builds a topology database of all routers within an area, and this topology table is the same for all those routers. These routers contain information about local links and also share information about their local links with other areas. This reduces the usage of bandwidth and load.

In Addition, Area 0, also known as the backbone area, shares information between different areas. All other areas must be linked with the backbone area through virtual links. Area 0 is also called the transit area.

OSPF routers can also link with multiple areas, managing their separate topology tables. These routers are called Area Border Routers (ABRs).

Let’s consider the following diagram:

  • Router A and Router B are the internal routers of Area 1.
  • Router E and Router F are the internal routers of Area 2.
  • Area 0 contains Router C and Router D, which are called Area Border Routers (ABRs).
OSPF Open Shortest Path First

Now consider the above example with the addition of external networks. Router G belongs to the external network, which is called an ASBR (Autonomous System Border Router).

A router can become an ASBR in two ways:

  1. By connecting to an external network like the Internet.
  2. By redistributing routes from another routing protocol.

ASBRs provide access to external networks in two types:

  1. Type 2 (E2) ā€“ This includes only the external cost outside the OSPF domain.
  2. Type 1 (E1) ā€“ This includes the cost of both external and internal routes.

LSAs and OSPF Topology Database

OSPF uses LSAs to ensure consistent topology databases across routers within an area. LSA types include:

  • Router LSA (Type 1): Contains local link details with status and cost.
  • Network LSA (Type 2): Generated by DRs, lists all routers.
  • Network Summary LSA (Type 3): Generated by ASBRs, contains information about destination networks.
  • ASBR Summary LSA (Type 4): Generated by ABRs, contains routes to ASBR destinations.
  • External LSA (Type 5): Generated by ASBRs, contains routes to external destinations.
What is OSPF Routing Protocol
Let’s understand the LSAs with the above diagram in detail:
  • Routers A, B, E, and F are the Internal Routers.
  • Routers C and D are the ABRs.
  • Router G is the ASBR.

In this topology, all routers will generate Type 1 LSAs. For instance, Router A will advertise the status of its interfaces fa0/0 and fa0/1. These LSAs will be flooded to all other routers in area 1. Let’s assume Router C is the DR (Designated Router); it will advertise Type 2 LSAs, containing a list of all routers attached to it. Since Router C is an ABR, Further, it will generate Type 3 network summary LSAs. Type 3 LSAs sent into area 0 will contain information about all networks along with their costs, and also share information about connected areas. Type 3 LSAs sent into area 1 will contain information about all connected networks of area 0.

Additionally, ABRs will generate Type 4 ASBR Summary LSAs. For example, Router C will send Type 4 LSAs to area 1, containing information about the path out to the autonomous system. ASBRs will generate Type 5 External LSAs. For instance, Router G will generate Type 5 LSAs containing the route to the external network outside the autonomous system.

LSAs are propagated when:
  • New neighbor relationships occur.
  • Topology table changes.
  • LSAs reach their maximum age (30 minutes by default).

What is Enhanced Interior Gateway Routing Protocol (EIGRP) | Understand and Use | Configuration Guide 2024

The OSPF Metric

The OSPF metric is determined by the cost, which is the sum of all outgoing interfaces. It is based on bandwidth, and the lowest cost will be preferred. Cisco applies default costs on each interface type as follows:

Type Cost
Serial (56K) 1785
Serial (64K) 1562
T1 (1.544 Mbps) 64
Token Ring (4 Mbps) 25
Ethernet (10 Mbps) 10
Token Ring (16 Mbps) 6
Fast Ethernet 1

On serial interfaces, OSPF uses the configured bandwidth, which is measured in Kbps, to determine the cost. For example:

Router(config)# interface s0
Router(config-if)# bandwidth 64

The default cost can also be altered:

codeRouter(config)# interface e0
Router(config-if)# ip ospf cost 5

Changing the cost of an interface should be done with great care. For instance:

codeRouter(config)# router ospf 1
Router(config-if)# ospf auto-cost reference-bandwidth 100

By default, the ospf auto-cost the command sets the reference bandwidth to 100 Mbps. This indicates that a 100 Mbps link will cost 1 (since 100/100 is 1). A Token Ring 4 Mbps interface costs 25 because 100/4 equals 25.

Basic OSPF Open Shortest Path First Configuration

Basic OSPF Configuration

To configure OSPF on Router A:

Router A(config)# router ospf 1
Router A(config-router)# router-id 1.1.1.1
Router A(config-router)# network 172.16.1.2 0.0.0.0 area 1
Router A(config-router)# network 172.17.1.1 0.0.0.0 area 0

To configure OSPF on Router B:

Router B(config)# router ospf 1
Router B(config-router)# router-id 2.2.2.2
Router B(config-router)# network 172.17.1.2 0.0.0.0 area 0
Router B(config-router)# network 172.18.1.1 0.0.0.0 area 2

OSPF Passive Interface

To prevent an interface from participating in OSPF:

Router B(config)# passive-interface e0

OSPF Authentication

In OSPF Open Shortest Path First supports authentication to protect routing updates.

OSPF Virtual Links

Virtual links are used when area 0 is not directly connected to other areas.

OSPF Area Types

  1. Standard Area:
    • Shares Type 1 and Type 2 LSAs within the area.
    • Accepts Type 3, Type 4, and Type 5 LSAs.
  2. Stub Area:
    • Accepts Type 1, Type 2, and Type 3 LSAs.
    • Does not accept Type 4 and Type 5 LSAs.
  3. Totally Stubby Area:
    • Prevents Type 3, Type 4, and Type 5 LSAs.
    • Shares only Type 1 and Type 2 LSAs.
  4. Not So Stubby Area (NSSA):
    • Similar to a stub area but accepts Type 1, Type 2, and Type 3 LSAs.
    • Does not accept Type 4 and Type 5 LSAs.
    • If an ASBR exists within NSSA, it generates Type 7 LSAs.

Troubleshooting Commands OSPF Open Shortest Path First

Show Commands
Router# show ip ospf neighbor
Router# show ip ospf database
Router# show ip ospf
Router# show ip ospf interface s0
Router# show ip protocols
Router# clear ip ospf process
Router# show ip ospf virtual-links
Router# show ip ospf border-routers
OSPF Debug Commands
Router# debug ip ospf adj
Router# debug ip ospf events
Router# debug ip ospf hello

This Post Has One Comment

Leave a Reply