Open Shortest Path First (OSPF) Protocol


Open Shortest Path First (OSPF) is a routing protocol for IP networks. It is used within a network or area. OSPF is an interior gateway protocol designed for a single autonomous system.

OSPF uses a link-state routing algorithm. Each router has information about every link and router in the network. It finds the shortest path to each destination. OSPF learns about all routers and subnets in the network to build a link-state database (LSDB). Routers exchange link-state advertisements (LSAs) to share information about routers, subnets, and more.

Basic Terms

  • Link-state − Description of a link between two routers, including its characteristics.

  • SPF algorithm − Computes shortest path from a source router to others.

  • OSPF cost − Metric representing the cost of using a link or path.

  • Shortest path tree − Shows the shortest path from a source router to all others.

  • Areas − Logical subdivisions of an OSPF network with similar characteristics.

  • Border routers − Connect different areas or external networks.

  • Link-state packets − Contain link-state advertisements and are sent by routers.

OSPF Operation

OSPF operates in three steps − neighbor discovery, database exchange, and route calculation.

OSPF Steps −

  • Neighbor Discovery − Routers find and communicate with neighbors on the same link.

  • Database Exchange − Routers exchange LSAs to learn about network topology.

  • Route Calculation − Routers use SPF algorithm to find the best paths.

OSPF Message Format

An OSPF message has different parts −

OSPF Protocol

  • Version − A number that shows the version of OSPF being used.

  • Type − A number that tells the type of OSPF packet.

  • Message − The length of the whole message, including the header.

Other fields in the OSPF message

  • Source IP address − The address from which the packets are sent.

  • Area identification − The area where the routing happens.

  • Checksum − Used to find and fix errors in the message.

  • Authentication type − Two types - 0 means no authentication, 1 means password-based authentication.

  • Authentication − The actual authentication data in the message.

OSPF Design

  • Divide network into areas for efficient routing.

  • Use ABRs to connect and summarize routing info between areas.

  • All areas connect to the backbone area (area 0) for network communication.

Areas in OSPF

There are different types of areas in OSPF, each with different characteristics and functions.

Types of OSPF Areas

Here are the different types of OSPF Areas −

  • Backbone area − Central area (0) connecting all others and external networks.

  • Standard area − Non-backbone area connected to backbone. Supports all LSAs except 4 and 5.

  • Stub area − Non-backbone area not accepting external routes. Receives default route from ABRs.

  • Totally stubby area − More restrictive stub area, not accepting inter-area routes.

  • Not-so-stubby area (NSSA) − Special stub area allowing external routes with type 7 LSAs.

  • Totally not-so-stubby area (NSSA) − More restrictive NSSA, not accepting inter-area routes.

Functions of Different Types of Areas

The following table summarizes the characteristics and functions of different types of areas

Area Type

Area ID

LSA Types Supported

Routes Supported

Default Route

Backbone

0

1, 2, 3, 4, 5

Intra-area, inter-area, external

No

Standard

Non-zero

1, 2, 3, 4, 5

Intra-area, inter-area, external

No

Stub

Non-zero

1, 2, 3

Intra-area, inter-area

Yes

Totally stubby

Non-zero

1, 2

Intra-area

Yes

NSSA

Non-zero

1, 2, 3, 7

Intra-area, inter-area, external (within NSSA)

Yes

Totally NSSA

Non-zero

1, 2, 7

Intra-area, external (within NSSA)

Yes

OSPF Design Tips

  • Routers per area − Keep below 50 for stability and performance.

  • Neighbors per router − Keep below 10 for optimal performance.

  • Full mesh vs partial mesh − Choose based on performance and complexity.

  • Memory requirements − OSPF needs more memory, to ensure routers have enough.

Route Summarization

Route summarization in OSPF reduces routing tables and overhead, improving stability and security. It combines multiple routes into one to represent a larger network. There are two types: inter-area and external route summarization.

  • Inter-area summarization is done by ABRs between areas in the same AS. It creates summary LSAs representing a range of networks within an area.

  • External summarization is done by ASBRs for routes from other ASes or external networks.

Guidelines for route summarization −

  • Summarize routes whenever possible for better scalability and efficiency.

  • Summarize routes only at ABRs and ASBRs to avoid issues.

  • Summarize based on natural boundaries like subnet masks or administrative areas.

  • Summarize contiguous and hierarchical routes to avoid complications.

  • Summarize routes with the same attributes for consistent behavior and optimal routing.

Redistribution

Redistribution is the process of importing routes from one routing protocol or source into another routing protocol or domain. Redistribution allows routers to exchange routing information between different routing protocols or sources, i.e., OSPF, RIP, EIGRP, BGP, static routes, connected routes, etc.

Redistribution can be useful in the following scenarios −

  • Migrating from one routing protocol to another

  • Connecting different routing domains or ASes

  • Injecting default routes or specific routes into a routing domain

  • Providing backup routes or load balancing across multiple paths

However, redistribution can also introduce problems, such as −

  • Routing loops or black holes

  • Suboptimal routing or inconsistent behavior

  • Routing overhead or instability

Therefore, redistribution should be performed carefully and with proper planning and configuration.

There are several guidelines and best practices for performing redistribution in OSPF −

  • Redistribute routes only at ABRs and ASBRs to avoid creating routing loops or black holes.

  • Redistribute routes only when necessary and with a clear purpose and scope.

  • Redistribute routes with route maps to filter and control the routes that are redistributed and to set the attributes of the redistributed routes, i.e., metric, type, tag, etc.

  • Redistribute routes with consistent policies and parameters across all ABRs and ASBRs to avoid creating suboptimal routing or inconsistent behavior.

  • Redistribute routes with a higher administrative distance than the native OSPF routes to avoid overriding the OSPF routes by the redistributed routes.

  • Redistribute routes with a lower metric than the default OSPF metric to avoid creating suboptimal routing or inconsistent behavior.

  • Redistribute routes with a different type than the native OSPF routes to avoid creating suboptimal routing or inconsistent behavior. For example, redistribute external routes as type 2 (E2) by default, unless type 1 (E1) is required for specific scenarios.

Advantages of OSPF

OSPF has many advantages over RIP. It is another interior gateway protocol based on a distance-vector routing algorithm. Advantages of OSPF are −

  • OSPF can handle variable length subnet masks (VLSM). It can support subnets of different sizes and optimize the use of IP address space.

  • OSPF can support up to 65535 hops, while RIP has a limit of 15 hops. This makes OSPF more scalable and suitable for large networks.

  • OSPF can perform route summarization and redistribution. It can reduce routing overhead and improve efficiency by aggregating routes and exchanging routes with other routing protocols.

  • OSPF can use authentication to secure routing updates and prevent unauthorized or malicious changes to the network topology.

  • OSPF can divide the network into areas and use different types of areas to reduce routing complexity and improve performance.

Conclusion

OSPF is a powerful and flexible routing protocol that can be used to design and build large and complex networks. OSPF uses a link-state routing algorithm that computes the shortest path to each destination based on the OSPF cost of each link.

OSPF allows dividing the network into areas and choosing different types of areas and border routers to optimize routing performance and efficiency. OSPF also supports authentication, VLSM, route summarization, and redistribution to enhance security and scalability.

OSPF can be used effectively in various scenarios, such as −

  • Enterprise networks that need fast convergence, high availability, and load balancing.

  • Service provider networks that need scalability, reliability, and interoperability with other routing protocols.

  • Data center networks that need high performance, redundancy, and traffic engineering.

Updated on: 01-Sep-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements