Home Search Center Intelligent Model Selection IP Encyclopedia

What Is OSPF?

The Open Shortest Path First (OSPF) protocol is a link-state Interior Gateway Protocol (IGP) developed by the Internet Engineering Task Force (IETF).
Currently, OSPF Version 2 defined in RFC 2328 is intended for IPv4, and OSPF Version 3 defined in RFC 2740 is intended for IPv6. Unless otherwise stated, OSPF in this document refers to OSPF Version 2.

Why Do We Need OSPF?

Before the emergence of OSPF, the Routing Information Protocol (RIP) was the most widely used IGP.

RIP is a distance-vector routing protocol which is gradually being replaced by OSPF, due to the former's slow convergence, tendency to form routing loops, and poor scalability.

OSPF is a link-state routing protocol featuring:

  • Multicast packet transmission, reducing load on the routers that do not run OSPF
  • Support for Classless Inter-Domain Routing (CIDR)
  • Load balancing among equal-cost routes
  • Packet authentication

With the preceding advantages, OSPF is widely accepted and used as an IGP.

Basic Concepts of OSPF

Router ID

A router requires a router ID if it is to run OSPF. A router ID is a 32-bit unsigned integer, uniquely identifying a router in an AS.

A router ID can be manually configured or automatically selected by a router:

  • It is recommended that you manually configure a router ID to ensure OSPF stability.
  • If no router ID is manually configured for a router, the router selects an interface IP address as its router ID. A router selects its router ID based on the following rules:
    1. The router preferentially selects the largest IP address among loopback interface addresses as its router ID.
    2. If no loopback interface is configured, the router selects the largest IP address among other interface addresses as its router ID.

After the router has been running OSPF and selected its router ID, it still uses this router ID if the interface whose IP address is used as the router ID is Down or disappears (for example, the undo interface loopback loopback-number command is run) or a larger interface IP address exists. The router can obtain a new router ID only after a router ID is reconfigured for the router or an OSPF router ID is reconfigured and the OSPF process restarts.

Link State

OSPF is a link-state protocol. A link can be considered as a router interface. The link state is a description of that interface and of the relationship with its neighboring routers. For example, a description of the interface includes the IP address and mask of the interface, the type of the connected network, and the connected neighbors. The collection of all these link states forms a link-state database (LSDB).

Cost

  • OSPF uses the cost as the route metric.
  • Each OSPF-enabled interface has a cost value. The cost of an OSPF interface is calculated as follows: Cost = Reference bandwidth/Interface bandwidth. The default reference bandwidth is 100 Mbit/s.
  • The cost of an OSPF route is the sum of the cost values of all inbound interfaces from the source device to the destination device.

    The default reference bandwidth is 100 Mbit/s. If the transmission medium has a bandwidth higher than 100 Mbit/s, a cost of less than 1 is calculated, which is not allowed in OSPF and will be rounded off to 1. Currently, many network devices use interfaces with more than 100 Mbit/s bandwidth. In this case, route cost calculation is inaccurate. To address this problem, run the bandwidth-reference command to change the reference bandwidth. If you need to configure this command, you are advised to configure it on all OSPF routers on the entire network.

Packet Types

Table 1-1 Packet types

Packet Type

Function

Hello packet

Sent periodically to discover and maintain OSPF neighbor relationships.

Database Description (DD) packet

Contains brief information about the local link-state database (LSDB) and synchronizes the LSDBs on two devices.

Link State Request (LSR) packet

Requests the required LSAs from neighbors.

LSR packets are sent only after DD packets are exchanged successfully.

Link State Update (LSU) packet

Sends the required LSAs to neighbors.

Link State Acknowledgment (LSAck) packet

Acknowledges the receipt of an LSA.

LSA Types

Table 1-2 LSA types

LSA Type

Function

Router-LSA (Type 1)

Describes the link status and link cost of a router. It is generated by every router and advertised in the area to which the router belongs.

Network-LSA (Type 2)

Describes the link status of all routers on the local network segment. Network-LSAs are generated by a designated router (DR) and advertised in the area to which the DR belongs.

Network-summary-LSA (Type 3)

Describes routes to a specific network segment in an area. Network-summary-LSAs are generated by an Area Border Router (ABR) and advertised in all areas except totally stub areas and Not-So-Stubby Areas (NSSAs). For example, an ABR belongs to both area 0 and area 1. Area 0 has a network segment 10.1.1.0, and area 1 has a network segment 11.1.1.0. The Type 3 LSA of the network segment 11.1.1.0 generated by the ABR for area 0 and the Type 3 LSA of the network segment 10.1.1.0 generated by the ABR for area 1 are advertised within the non-totally stub area or NSSA.

ASBR-summary-LSA (Type 4)

Describes routes to an Autonomous System Boundary Router (ASBR). ASBR-summary-LSAs are generated by an ABR and advertised to all related areas except the area to which the ASBR belongs.

AS-external-LSA (Type 5)

Describes routes to a destination outside the AS. AS-external-LSAs are generated by an ASBR and advertised to all areas except stub areas and NSSAs.

NSSA-LSA (Type 7)

Describes routes to a destination outside the AS. NSSA-LSAs are generated by an ASBR and advertised in NSSAs only.

Opaque-LSA (Type 9/Type 10/Type 11)

Provides a universal mechanism for OSPF extension.

  • Type 9 LSAs are advertised only on the network segment where the interface originating Type 9 LSAs resides. Grace LSAs used to support GR are a type of Type 9 LSAs.
  • Type 10 LSAs are advertised inside an OSPF area. LSAs used to support TE are a type of Type 10 LSAs.
  • Type 11 LSAs are advertised within an AS. At present, there are no applications of Type 11 LSAs.

Support Status of LSAs in Different Types of Areas

Table 1-3 Support status of LSAs in different types of areas

Area Type

Router-LSA (Type 1)

Network-LSA (Type 2)

Network-Summary-LSA (Type 3)

ASBR-Summary-LSA (Type 4)

AS-External-LSA (Type 5)

NSSA-LSA (Type 7)

Common area (including standard and backbone areas)

Supported

Supported

Supported

Supported

Supported

Not supported

Stub area

Supported

Supported

Supported

Not supported

Not supported

Not supported

Totally stub area

Supported

Supported

Not supported

Not supported

Not supported

Not supported

NSSA

Supported

Supported

Supported

Not supported

Not supported

Supported

Totally NSSA

Supported

Supported

Not supported

Not supported

Not supported

Supported

Router Types

The following figure lists common router types used in OSPF.

Router types
Router types
Table 1-4 Router types

Router Type

Description

Internal router

All interfaces on an internal router belong to the same OSPF area.

Area Border Router (ABR)

An ABR belongs to two or more areas, one of which must be the backbone area.

An ABR connects the backbone area and non-backbone areas. It can be physically or logically connected to the backbone area.

Backbone router

At least one interface on a backbone router belongs to the backbone area.

Internal routers in area 0 and all ABRs are backbone routers.

Autonomous System Boundary Router (ASBR)

An ASBR exchanges routing information with other ASs.

An ASBR does not necessarily reside on the border of an AS. It can be an internal router or an ABR. An OSPF device that has imported external routing information becomes an ASBR.

Route Types

Inter-area and intra-area routes in an AS describe the AS's network structure. AS external routes describe the routes to destinations outside an AS. OSPF classifies the imported AS external routes into Type 1 and Type 2 external routes.

The following table lists route types in descending order of priority.

Table 1-5 Route types

Route Type

Description

Intra-area route

Indicates routes within an area.

Inter-area route

Indicates routes between areas.

Type 1 external route

As Type 1 external routes offer higher reliability than Type 2 external routes, their costs are approximately the same as those of AS internal routes and are comparable with the costs of routes generated by OSPF.

Cost of a Type 1 external route = Cost of the route from a local device to an ASBR + Cost of the route from the ASBR to the destination of the Type 1 external route

Type 2 external route

Because Type 2 external routes offer low reliability, OSPF considers that the cost of the route from an ASBR to the destination of a Type 2 external route is much greater than the cost of any internal route to the ASBR.

Cost of a Type 2 external route = Cost of the route from the ASBR to the destination of the Type 2 external route

Area Types

Table 1-6 Area types

Area Type

Function

Common area

OSPF areas are common areas by default. Common areas include standard areas and backbone areas.

  • A standard area is the most common area and transmits intra-area routes, inter-area routes, and external routes.
  • A backbone area connects to all the other OSPF areas. It is usually named area 0.

Stub area

A stub area does not advertise AS external routes, but only intra-area and inter-area routes.

In a stub area, a router maintains fewer routing entries in the routing table and transmits less routing information.

To ensure reachability of AS external routes, the ABR in a stub area advertises Type 3 default routes to the entire stub area. All AS external routes must be advertised by ABRs.

Totally stub area

A totally stub area does not advertise AS external routes or inter-area routes, but only intra-area routes.

In a totally stub area, a router maintains fewer routing entries in the routing table and transmits less routing information.

To ensure reachability of AS external routes and inter-area routes, the ABR in a totally stub area advertises Type 3 default routes to the entire totally stub area. All AS external and inter-area routes must be advertised by ABRs.

NSSA

An NSSA can import AS external routes. An ASBR uses Type 7 LSAs to advertise the imported AS external routes to the entire NSSA. These Type 7 LSAs are then translated into Type 5 LSAs on an ABR and flooded within the entire OSPF AS.

An NSSA has the characteristics of the stub areas in an AS.

An ABR in an NSSA advertises Type 7 default routes to the entire NSSA. All inter-area routes must be advertised by ABRs.

Totally NSSA

A totally NSSA can import AS external routes. An ASBR uses Type 7 LSAs to advertise the imported AS external routes to the entire NSSA. These Type 7 LSAs are then translated into Type 5 LSAs on an ABR and flooded within the entire OSPF AS.

A totally NSSA has the characteristics of the totally stub areas in an AS.

An ABR in a totally NSSA advertises Type 3 and Type 7 default routes to the entire totally NSSA. All inter-area routes must be advertised by ABRs.

OSPF Network Types

The following table lists four OSPF network types that are classified based on link layer protocols.

Table 1-7 OSPF network types

Network Type

Description

Broadcast

OSPF defaults networks using Ethernet or Fiber Distributed Data Interface (FDDI) at the link layer to broadcast networks.

On a broadcast network:

  • Hello packets, LSU packets, and LSAck packets are usually transmitted in multicast mode. 224.0.0.5 is the IP multicast address reserved for an OSPF device. 224.0.0.6 is the IP multicast address reserved for OSPF DRs or backup designated routers (BDRs).
  • DD and LSR packets are transmitted in unicast mode.

Non-Broadcast Multi-Access (NBMA)

OSPF defaults networks using frame relay (FR) or X.25 at the link layer to NBMA networks.

On an NBMA network, protocol packets such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets are sent in unicast mode.

Point-to-Multipoint (P2MP)

OSPF does not default a network to a P2MP network regardless of the link layer protocol used by the network. A P2MP network must be changed from another network type. It is a typical practice to change non-fully meshed NBMA networks to P2MP networks.

On a P2MP network:

  • Hello packets are transmitted in multicast mode using the multicast address 224.0.0.5.
  • DD packets, LSR packets, LSU packets, and LSAck packets are transmitted in unicast mode.

Point-to-Point (P2P)

OSPF defaults networks using Point-to-Point Protocol (PPP), High-Level Data Link Control (HDLC), or Link Access Procedure Balanced (LAPB) at the link layer to P2P networks.

On a P2P network, protocol packets such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets are all sent in multicast mode using the multicast address 224.0.0.5.

DR and BDR

On broadcast or NBMA networks, any two routers need to exchange routing information. As shown in the following figure, n routers are deployed on the network, so n x (n - 1)/2 adjacencies need to be established. A route change on any router is transmitted to the other routers, which consumes bandwidth resources. To resolve this problem, OSPF defines designated router (DR) and a backup designated router (BDR). After a DR is elected, all the other routers send routing information only to the DR, and the DR broadcasts LSAs. Routers other than the DR and BDR are called DR others. The DR others establish adjacencies and exchange routing information only with the DR and BDR and not with each other. This reduces the number of adjacencies established between routers on broadcast and NBMA networks.

Network topologies before and after a DR election
Network topologies before and after a DR election

If the DR fails, routers must re-elect a new DR. The new DR needs to establish adjacencies with other routers on the same network segment and exchange routing information with them. This is a lengthy process, during which route calculations may be incorrect. A BDR is used to shorten the process. The BDR is a backup for a DR. A BDR is elected together with a DR. The BDR establishes adjacencies with all routers on the network segment and exchanges routing information with them. When the DR fails, the BDR immediately becomes a new DR. The routers need to re-elect a new BDR, but this process does not affect route calculations.

The DR and BDR are not designated manually, but are elected by all routers on the local network segment. DR priorities of router interfaces determine whether the interfaces are qualified for DR/BDR election. Routers with DR priorities greater than 0 on the local network segment are considered as candidates. The ballots in this election are performed using Hello packets. Each router adds elected DR information to a Hello packet and sends the packet to other routers on the network segment. When two routers on the same network segment declare that they are DRs, the router with a higher DR priority is elected as a DR. If the two routers have the same DR priority, the router interface with a larger router ID is elected as a DR. The router whose DR priority is 0 cannot be elected as the DR or BDR.

Stub Area

Stub areas are specific areas where ABRs do not flood the received AS external routes. In stub areas, routers maintain fewer routing entries and less routing information.

Configuring a stub area is optional. Not every area can be configured as a stub area. A stub area is usually a non-backbone area with only one ABR and is located at the border of an AS.

To ensure reachability of the routes to destinations outside an AS, the ABR in a stub area generates a default route and advertises the route to the non-ABRs in the same stub area.

Note the following points when configuring a stub area:

  • A backbone area cannot be configured as a stub area.
  • Stub area attributes need to be configured on all routers in the area that needs to be configured as a stub area.
  • An ASBR cannot exist in a stub area, meaning that AS external routes cannot be advertised in the stub area.
  • A virtual link cannot pass through a stub area.

NSSA

NSSAs are a special type of OSPF areas. There are many similarities between an NSSA and a stub area. Both of them do not advertise the external routes received from other OSPF areas. The difference is that a stub area cannot import AS external routes, whereas an NSSA can import AS external routes and advertise these routes to the entire AS.

After an area is configured as an NSSA, an ABR in the NSSA generates a default route and advertises the route to other routers in the NSSA. This ensures reachability of the routes to destinations outside an AS.

Note the following points when configuring an NSSA:

  • A backbone area cannot be configured as an NSSA.
  • NSSA attributes need to be configured on all routers in the area that needs to be configured as an NSSA.
  • A virtual link cannot pass through an NSSA.

Neighbor State Machine

To exchange routing information on an OSPF network, neighbor routers must establish adjacencies. The differences between neighbor relationships and adjacencies are described as follows:

  • Neighbor relationship: After the local router starts, it sends a Hello packet to a remote router through an OSPF interface. After the remote router receives the packet, it checks whether the parameters carried in the packet are consistent with its own parameters. If they are consistent, the local and remote routers establish a neighbor relationship.
  • Adjacency: After the local and remote routers establish a neighbor relationship, they exchange DD packets and LSAs to establish an adjacency.

OSPF has eight state machines: Down, Attempt, Init, 2-way, Exstart, Exchange, Loading, and Full.

  • Down: It is in the initial stage of setting up sessions between neighbors. The state machine is Down when a router does not receive any Hello packets from its neighbor before the dead interval expires.
  • Attempt: It occurs only on an NBMA network. The state machine is Attempt when a neighbor does not reply with Hello packets before the dead interval expires. The local router, however, keeps sending Hello packets to the neighbor at every poll interval.
  • Init: The state machine is Init after a router receives Hello packets.
  • 2-way: The state machine is 2-way when the Hello packets received by a router contain its own router ID. If no adjacency needs to be established, the state machine remains in the 2-way state; otherwise, the state machine becomes Exstart.
  • Exstart: The state machine is Exstart when two neighbors start to negotiate the master/slave status and determine the sequence numbers of DD packets.
  • Exchange: The state machine is Exchange when a router starts to exchange DD packets with its neighbor after the master/slave status negotiation is completed.
  • Loading: The state machine is Loading after a router has finished exchanging DD packets with its neighbor.
  • Full: The state machine is Full when the LSR retransmission list is empty.

OSPF Packet Authentication

OSPF supports packet authentication. OSPF packets must be authenticated before a neighbor relationship is established.

The router supports two authentication modes:

  • Area-based authentication
  • Interface-based authentication

When both area-based authentication and interface-based authentication are configured, interface-based authentication takes effect.

OSPF Route Summarization

Route summarization allows multiple routes with the same prefix to be summarized into a single summary route. Only the summary route is advertised to other areas.

Route summarization between areas reduces the amount of routing information to be transmitted, reducing the size of routing tables, and thereby improving device performance.

Route summarization can be carried out by an ABR or an ASBR:

  • Route summarization on an ABR:

    When an ABR in an area advertises routing information to other areas, it generates Type 3 LSAs by network segment. If network segments are contiguous, you can run a command to summarize these network segments into a single one. In this way, the ABR only needs to send the summary LSA for all the network segments specified in the command.

  • Route summarization on an ASBR:

    If the local device is an ASBR and route summarization is configured, the ASBR summarizes the imported Type 5 LSAs within the summarized address range. When an NSSA is configured, the ASBR also needs to summarize the imported Type 7 LSAs within the summarized address range.

    If the local device is both an ASBR and ABR, it summarizes the Type 5 LSAs that are translated from Type 7 LSAs.

OSPF Default Route

A default route is a route of which the destination address and mask are all 0s. A device uses a default route to forward packets when no matching route is discovered in its routing table. Hierarchical management of OSPF routes prioritizes the default route carried in Type 3 LSAs over that carried in Type 5 or Type 7 LSAs.

An OSPF default route is typically used in the following scenarios:

  • An ABR advertises a default route in Type 3 LSAs for instructing routers within an area to forward packets between areas.
  • An ASBR advertises a default route in Type 5 ASE LSAs or default Type 7 NSSA LSAs for instructing routers in an AS to forward packets to other ASs.

Advertising an OSPF default route must follow these rules:

  • An OSPF router in an area can advertise LSAs carrying a default route only when the router has an interface connected to a device outside the area.
  • If an OSPF router has advertised an LSA carrying a default route, the OSPF router does not learn this type of default routes advertised by other routers. This means that the OSPF router no longer calculates routes based on the LSAs carrying the same type of default routes advertised by other routers, but it still stores these LSAs in its LSDB.
  • If a router must use a route to advertise LSAs carrying an external default route, the route cannot be a route in the local OSPF AS. This means that the route cannot be a route learned by the local OSPF process. This is because default external routes are used to guide packet forwarding outside an AS, whereas the routes within an AS have the next hops pointing to the devices within the AS.

The following table lists rules for advertising default routes in different areas.

Table 1-8 Rules for advertising OSPF default routes

Area Type

Function

Common area

By default, devices in a common OSPF area do not generate default routes, even if they have default routes.

When a default route on the network is generated by another routing process (not an OSPF process), the device that generates the default route must advertise it in the entire OSPF AS. You can run a command on an ASBR to configure it to generate a default route. After the configuration, the ASBR generates a Type 5 ASE LSA carrying the default route and then advertises the LSA to the entire OSPF AS.

Stub area

A stub area does not allow AS external routes (carried in Type 5 LSAs) to be transmitted within the area.

All routers within a stub area must learn AS external routes from the ABR. The ABR automatically generates a Summary LSA (Type 3 LSA) carrying a default router and advertises it to the entire stub area. Then, all routes to destinations outside an AS can be learned from the ABR.

Totally stub area

A totally stub area does not allow AS external routes (carried in Type 5 LSAs) or inter-area routes (carried in Type 3 LSAs) to be transmitted within the area.

All routers within a totally stub area must learn AS external routes and inter-area routes from the ABR. The ABR automatically generates a Summary LSA (Type 3 LSA) carrying a default route and advertises it to the entire totally stub area. Then, all routes to destinations outside an AS and to destinations in other areas can be learned from the ABR.

NSSA

An NSSA allows its ASBRs to import a small number of AS external routes, but not to advertise ASE LSAs (Type 5 LSAs) received from other areas within the NSSA. This means that AS external routes can be learned only from ASBRs in the NSSA.

Devices in an NSSA do not automatically generate default routes.

Use either of the following methods to generate default routes:

  • Method 1: To advertise AS external routes through the ASBR in the NSSA and advertise other external routes through other areas, configure a Type 7 LSA carrying a default route on the ABR and advertise this LSA in the entire NSSA.
  • Method 2: To advertise all external routes through the ASBR in the NSSA, configure a Type 7 LSA carrying a default route on the ASBR and advertise this LSA in the entire NSSA.

The difference between the two methods is:

  • An ABR generates a Type 7 LSA carrying a default route regardless of whether the routing table contains the default route 0.0.0.0.
  • An ASBR generates a Type 7 LSA carrying a default route only when the routing table contains the default route 0.0.0.0.

A default route is flooded only in the local NSSA and is not flooded in the entire OSPF AS. If routers in the local NSSA cannot find routes to the outside of the AS, the routers can forward packets outside of the AS through an ASBR. Packets of other OSPF areas, however, cannot be sent to the outside of the AS through this ASBR. Type 7 LSAs carrying default routes will not be translated into Type 5 LSAs on the ABR to make the default routes be flooded in the entire OSPF AS.

Totally NSSA

A totally NSSA does not allow ASE LSAs (Type 5 LSAs) received from other areas or inter-area routes (carried in Type 3 LSAs) to be transmitted within the area.

All routers within a totally NSSA must learn routes to other areas from the ABR. The ABR automatically generates a Type 3 LSA carrying a default route and advertises it to the entire totally NSSA. Then, all external routes received from other areas and inter-area routes can be advertised within the totally NSSA.

OSPF Route Filtering

OSPF supports route filtering using routing policies. By default, OSPF does not filter routes.

Routing policies used by OSPF include route-policy, access-list, and prefix-list.

OSPF route filtering can be used to:

  • Import routes.

    OSPF can import routes learned by other routing protocols. You can configure routing policies to filter the imported routes to allow OSPF to import only the routes that match specific conditions.

  • Advertise imported routes.

    An OSPF device advertises the imported routes to its neighbors.

    You can configure filtering rules to filter the routes to be advertised. The filtering rules take effect only on ASBRs.

  • Learn routes.

    Filtering rules can be configured to allow OSPF to filter the received intra-area, inter-area, and AS external routes.

    After receiving routes, an OSPF device adds only the routes that match the filtering rules to the local routing table. However, the device can still advertise all routes from the OSPF routing table.

  • Learn inter-area LSAs.

    You can run a command to configure an ABR to filter incoming Summary LSAs. This configuration takes effect only on ABRs because only ABRs can advertise Summary LSAs.

Table 1-9 Differences between inter-area LSA learning and that for route learning

Inter-area LSA Learning

Route Learning

Directly filters incoming LSAs.

Filters the routes that are calculated based on LSAs to determine the routes to be added to the local routing table. This means that all incoming LSAs are learned.

  • Advertise inter-area LSAs.

    You can run a command to configure an ABR to filter outgoing Summary LSAs. This configuration takes effect only on ABRs.

OSPF Multi-Process

OSPF supports multi-process. This allows multiple OSPF processes to run independently on the same router. Route exchanges between different OSPF processes are similar to route exchanges between different routing protocols.

Each interface on the router belongs to only one OSPF process.

A typical application of OSPF multi-process is that OSPF runs between provider edges (PEs) and customer edges (CEs) in a VPN, whereas OSPF is used as an IGP on the backbone of the VPN. Two OSPF processes on the same PE are independent of each other.

OSPF RFC 1583 Compatibility

RFC 1583 is an earlier version of OSPFv2.

When OSPF calculates external routes, routing loops may occur because RFC 2328 and RFC 1583 define different route selection rules. To prevent routing loops, both communication ends must use the same route selection rules. The mechanism is as follows:

  • When RFC 1583 compatibility is enabled, OSPF uses the route selection rules defined in RFC 1583.
  • When RFC 1583 compatibility is disabled, OSPF uses the route selection rules defined in RFC 2328.

OSPF calculates external routes based on Type 5 LSAs. If the router enabled with RFC 1583 compatibility receives a Type 5 LSA:

  • The router selects a route to the ASBR that originates the LSA or to the forwarding address (FA) described in the LSA.
  • The router selects external routes to the same destination.

By default, OSPF uses the route selection rules defined in RFC 1583.

How Does OSPF Work?

OSPF route calculation involves the following processes:

  1. Adjacency Establishment

    The adjacency establishment process is as follows:

    1. The local and remote routers use OSPF interfaces to exchange Hello packets to establish a neighbor relationship.
    2. The local and remote routers negotiate a master/slave relationship and exchange Database Description (DD) packets.
    3. The local and remote routers exchange link state advertisements (LSAs) to synchronize their link state databases (LSDBs).
  2. Route Calculation

    OSPF uses the shortest path first (SPF) algorithm to calculate routes, resulting in fast route convergence.

Adjacency Establishment

Adjacencies can be established in either of the following situations:

  • Two routers have established a neighbor relationship and communicate for the first time.
  • The designated router (DR) or backup designated router (BDR) on a network segment changes.

The adjacency establishment process is different on different networks.

Adjacency establishment on a broadcast network

On a broadcast network, the DR and BDR establish adjacencies with each router on the same network segment, but DR others establish only neighbor relationships.

The following figure shows the adjacency establishment process on a broadcast network.

Adjacency establishment process on a broadcast network
Adjacency establishment process on a broadcast network

The adjacency establishment process on a broadcast network is as follows:

  1. Neighbor relationship establishment
    1. Device A uses the multicast address 224.0.0.5 to send a Hello packet to Device B through the OSPF interface connected to a broadcast network. The packet carries the DR field of 1.1.1.1 (ID of Device A) and the Neighbors Seen field of 0. A neighbor device has not been discovered, and Device A regards itself as a DR.
    2. After Device B receives the packet, it returns a Hello packet to Device A. The returned packet carries the DR field of 2.2.2.2 (ID of Device B) and the Neighbors Seen field of 1.1.1.1 (Device A's router ID). Device A has been discovered but its router ID is less than that of Device B, and therefore Device B regards itself as a DR. Then Device B's status changes to Init.
    3. After Device A receives the packet, Device A's status changes to 2-way.

    The following procedures are not performed for DR others on a broadcast network.

  2. Master/Slave negotiation and DD packet exchange
    1. Device A sends a DD packet to Device B. The packet carries the following fields:
      • Seq field: The value x indicates the sequence number is x.
      • I field: The value 1 indicates that the packet is the first DD packet, which is used to negotiate a master/slave relationship and does not carry LSA summaries.
      • M field: The value 1 indicates that the packet is not the last DD packet.
      • MS field: The value 1 indicates that Device A declares itself a master.

        To improve transmission efficiency, Device A and Device B determine which LSAs in each other's LSDB need to be updated. If one party determines that an LSA of the other party is already in its own LSDB, it does not send an LSR packet for updating the LSA to the other party. To achieve the preceding purpose, Device A and Device B first send DD packets, which carry summaries of LSAs in their own LSDBs. Each summary identifies an LSA. To ensure packet transmission reliability, a master/slave relationship must be determined during DD packet exchange. One party serving as a master uses the Seq field to define a sequence number. The master increases the sequence number by one each time it sends a DD packet. When the other party serving as a slave sends a DD packet, it adds the sequence number carried in the last DD packet received from the master to the Seq field of the packet.

    2. After Device B receives the DD packet, Device B's status changes to Exstart and Device B returns a DD packet to Device A. The returned packet does not carry LSA summaries. Because Device B's router ID is greater than Device A's router ID, Device B declares itself a master and sets the Seq field to y.
    3. After Device A receives the DD packet, it agrees that Device B is a master and Device A's status changes to Exchange. Then Device A sends a DD packet to Device B to transmit LSA summaries. The packet carries the Seq field of y and the MS field of 0. The value 0 indicates that Device A declares itself a slave.
    4. After Device B receives the packet, Device B's status changes to Exchange and Device B sends a new DD packet containing its own LSA summaries to Device A. The value of the Seq field carried in the new DD packet is changed to y + 1.

      Device A uses the same sequence number as Device B to confirm that it has received DD packets from Device B. Device B uses the sequence number plus one to confirm that it has received DD packets from Device A. When Device B sends the last DD packet, it sets the M field of the packet to 0.

  3. LSDB synchronization
    1. After Device A receives the last DD packet, it finds that many LSAs in Device B's LSDB do not exist in its own LSDB, so Device A's status changes to Loading. After Device B receives the last DD packet from Device A, Device B's status directly changes to Full, because Device B's LSDB already contains all LSAs of Device A.
    2. Device A sends an LSR packet for updating LSAs to Device B. Device B returns an LSU packet to Device A. After Device A receives the packet, it sends an LSAck packet for acknowledgement.

      The preceding procedures continue until the LSAs in Device A's LSDB are the same as those in Device B's LSDB. Device A's status changes to Full. After Device A and Device B exchange DD packets and update all LSAs, they establish an adjacency.

Adjacency establishment on an NBMA network

The adjacency establishment process on an NBMA network is similar to that on a broadcast network. The blue part shown in the following figure highlights the differences from a broadcast network.

On an NBMA network, all devices establish adjacencies only with the DR and BDR.

Adjacency establishment process on an NBMA network
Adjacency establishment process on an NBMA network

The adjacency establishment process on an NBMA network is as follows:

  1. Neighbor relationship establishment
    1. After Device B sends a Hello packet to a Down interface of Device A, Device B's status changes to Attempt. The packet carries the DR field of 2.2.2.2 (ID of Device B) and the Neighbors Seen field of 0. A neighbor device has not been discovered, and Device B regards itself as a DR.
    2. After Device A receives the packet, Device A's status changes to Init and Device A returns a Hello packet. The returned packet carries the DR and Neighbors Seen fields of 2.2.2.2. Device B has been discovered but its router ID is greater than that of Device A, and therefore Device A agrees that Device B is a DR.

    The following procedures are not performed for DR others on an NBMA network.

  2. Master/Slave relationship negotiation and DD packet exchange

    The procedures for negotiating a master/slave relationship and exchanging DD packets on an NBMA network are the same as those on a broadcast network.

  3. LSDB synchronization

    The procedure for synchronizing LSDBs on an NBMA network is the same as that on a broadcast network.

Adjacency establishment on a point-to-point (P2P)/point-to-multipoint (P2MP) network

The process for establishing an adjacency on a P2P/P2MP network is similar to that on a broadcast network except that no DR or BDR needs to be elected on a P2P/P2MP network. DD packets are transmitted in multicast mode on P2P networks and in unicast mode on P2MP networks.

Route Calculation

OSPF uses an LSA to describe the network topology. A Type 1 LSA describes the attributes of a link between devices. A router transforms its LSDB into a weighted, directed graph, which reflects the topology of the entire AS. All routers in the same area have the same graph. The following figure shows a weighted, directed graph.

Weighted, directed graph
Weighted, directed graph

Based on the graph, each device uses an SPF algorithm to calculate an SPT with itself as the root. The SPT shows routes to nodes in the AS. The following figure shows an SPT.

SPT
SPT

When a device's LSDB changes, the router recalculates a shortest path. Frequent SPF calculations consume a large amount of resources and affect router efficiency. Changing the interval between SPF calculations can prevent resource consumption caused by frequent LSDB changes. The default interval between SPF calculations is 5 seconds.

The route calculation process is as follows:

  1. A device calculates intra-area routes.

    The device uses an SPF algorithm to calculate shortest paths to other routers in an area. Type 1 and Type 2 LSAs accurately describe the network topology in an area. Based on the network topology described by a Type 1 LSA, the router calculates paths to other routers in the area.

    If multiple equal-cost routes are produced during route calculation, the SPF algorithm retains all these routes in the LSDB.

  2. The device calculates inter-area routes.

    The network segment of the routes in an adjacent area can be considered to be directly connected to the area border router (ABR). Because the shortest path to the ABR has been calculated in the preceding phase, the router can directly check a Type 3 LSA to obtain the shortest path to the network segment. The autonomous system boundary router (ASBR) can also be considered to be connected to the ABR. Therefore, the shortest path to the ASBR can also be calculated in this phase.

    If the device performing an SPF calculation is an ABR, the device needs to check only Type 3 LSAs in the backbone area.

  3. The device calculates AS external routes.

    AS external routes can be considered to be directly connected to the ASBR. Because the shortest path to the ASBR has been calculated in the preceding phase, the device can check Type 5 LSAs to obtain the shortest paths to other ASs.

About This Topic
  • Author: Tang Dandan
  • Updated on: 2021-12-15
  • Views: 5747
  • Average rating:
Share link to