Table of contents

Terminology

The OSPF protocol

OSPF (Open Shortest Path First) - a dynamic routing protocol based on an algorithm that constructs a shortest path tree. The OSPF protocol has the following features:

OSPF area

The number of autonomous system routers that use OSPF to exchange routing information can be large. This leads to a high load of the communication channels because of the large number of OSPF service messages. To reduce the amount of the transmitted service information, the OSPF protocol divides the autonomous system into areas.

Each area has a 32-bit identifier, which is usually written in two formats:

It is not necessary to use sequential identifiers for the areas. For example, the network can include areas with the identifiers 0, 2 and 7 (Figure 1a).

An interface belongs to an area, not the device itself. Thus, one router can be connected to multiple areas through its interfaces (Figure 1a).

The area with the identifier 0.0.0.0 has a special role - this area is called the backbone area. The backbone area is a requirement for the OSPF operation. Each area must be directly connected to the backbone area, i.e. a scheme in which some area is connected to another one without having a direct connection to the backbone is prohibited (Figure 1b).

Figure 1a - Allowed network scheme with multiple OSPF areas

Figure 1b - Prohibited network scheme with multiple OSPF areas

Router types

Depending on the router's place in the network, the following types of devices are distinguished (Figure 2):

Figure 2 - Network scheme with different router types

OSPF's operation

The OSPF process follows the below steps. Some steps will require a detailed explanation which is provided in the sections below.

OSPF protocol launching

Two actions are performed when the OSPF service is launched: the selection of the router identifier  and the definition of a list of interfaces that will participate in OSPF.

The router has a 32-bit identifier, which is usually written in the IP address format. Usually, the identifier is not related with the device's IP address and can be set manually. If the identifier is not set manually, it will be automatically selected as the highest IP address of the device. In case of manual setting of the ID, it is recommended to set it in the IP address of the loopback0 interface. This will help to identify the devices easier and to speed up the diagnostic of the network problems.

During the automatic router ID selection, the InfiNet device generates a special address from the 224. *. *. * multicast subnet, associated with the router's serial number. This helps to avoid the necessity of redefining the router ID when the IP address or the network interface are removed.

The set of interfaces that will take part into the OSPF protocol is determined based on the following rules:

If OSPF has not been started on a network interface, this does not mean that the network associated with this interface will not be advertised to the other routers. Launching OSPF on an interface only impacts the discovery of the neighbors.

Let's take a look at some examples of how to start the OSPF service on router R1 (Figure 3). The table below contains the configuration commands and their correspondence with the router's interfaces; if a match is found, a neighbor discovery process will be performed on the interface.

CommandCorrespondence to eth1Correspondence to eth2Description
network 0.0.0.0/0 area 0yesyes

The 0.0.0.0/0 network includes all IP addresses, so the networks associated with eth1 and eth2 are in this range.

Such a configuration has a hidden behavior: if a new IP address appears in the device's configuration, then OSPF will be launched on the interface associated with it. This is because the 0.0.0.0/0 network includes all the networks.

network 10.10.30.0/24 area 0

network 192.168.6.0/28 area 1

yesyesThe command contains the networks associated with the eth1 and eth2 interfaces, so OSPF will use both interfaces.

network 10.10.30.0/25 area 0

network 192.168.6.0/28 area 1

noyes

Although the IP address of the eth1 interface of R1 belongs to the 10.10.30.0/25 network, OSPF will not be launched on this interface. This is because the network associated with interface eth1 contains addresses in the range 10.10.30.0-255, which is not fully included in the 10.10.30.0/25 (10.10.30.0-127) network range.

OSPF will be launched only on eth2.


Figure 3 - Router with two network interfaces

Passive interfaces

After the router has determined the list of interfaces where OSPF is running, it starts looking for neighbors connected to these interfaces. Besides that, all the networks assigned to these interfaces will be advertised to the other routers. This behavior can be exploited by an attacker: the router will establish neighboring relations with the attacker's device and will transmit all the routing information about the network.

This type of attack can be prevented by using passive interfaces. Any interface participating in OSPF can be configured as passive. In this case, the search for neighbors via such an interface will not be performed, however, the network assigned to this interface will be advertised to the other routers.

External routes

The list of networks that are assigned to the interfaces is defined when OSPF starts. in addition, OSPF can advertise routes towards other networks, that were added to the device's routing table. The announcement of such routes is called redistribution. These routes are external to OSPF.

The routing sources for redistribution can be other dynamic routing protocols, static entries or directly connected networks not added to OSPF.

Setting up neighboring relations

The routing information exchange is possible only after the establishment of the neighboring relations between the routers. Two routers having a common link will establish a neighboring relation if the following parameters match:

The neighboring relations are established in several steps. Let's look at an example (Figure 4a): the network consists of three routers R1, R2 and R3 connected to the switch. Neighboring relations are established between the routers ( the R2 router is selected as the designated router (DR), R3 as the backup designated router (BDR) ). Router R4 will be added to the network scheme and let's assume that the conditions for establishing neighboring relations are met.

Figure 4a - The R4 router was added to the network scheme

Figure 4b - R4 sends Hello messages

Figure 4c - R1, R2, R3 send Hello messages

Figure 4d - 2-Way relations were established

Figure 4e - Full relations were established by R4 with the DR and the BDR

Role distribution

In each broadcast segment where OSPF is running, DR and BDR elections are performed. The elections are carried out according to the following criteria:

The group address 224.0.0.6 is associated with the DR and the BDR devices, which is used for LSDB synchronization. The devices having DR and BDR roles establish a Full relation with each router in the broadcast segment and require higher device performance demands compared to the DROthers. Since the device's hardware performance can become a bottleneck, it should be taken into account during network planning. Interface prioritization should be set in order to ensure a predictable selection of the highest performing devices as DR and BDR.

The main function of the DR is the routing information exchange in the broadcast segment. The main function of the BDR is to monitor the DR's state and, if it fails, to change the role to DR. Since each DROther establishes a Full relation with both the DR and the BDR, the LSDB on the BDR is synchronous with the DR, so the BDR can start performing the DR's functions without database synchronization timing delays. If the BDR becomes DR, then the BDR is selected among the DROthers according to the algorithm described above.

LSDB synchronization

The routing information in OSPF is categorized in different types of LSAs. The LSDB is a set of LSAs. The LSA is not an OSPF service message, therefore, the DBD, LSR, LSU and LSAck messages are used to transmit it according to steps 6-8 used in the neighboring relations establishment algorithm.

 OSPF version 2 which is supported by the WANFleX OS defines 7 LSA types as described in the table below. To explain the purpose of different LSA types, the network scheme in Figure 5a will be used: the network consists of 6 routers and three OSPF areas are defined. This scheme describes the LSA types generated by the devices regardless of the neighboring relations establishment stages.

TypeNameDescriptionExample
1

Router LSA

This type of LSA is distributed by all the routers within the same area.

The LSA contains the following routing information:

  • a description of all the routes to the networks included in this area;
  • the costs of the routes;
  • a list of routers inside the routing area, specifying the established neighboring relations.

This type of LSA is distributed by all the routers in the network (Figure 5b).

This LSA type has the following features:

  • R3 will include only the 10.10.234.0/29 network in the LSA type 1 broadcasted in area 0, and the 192.168.36.0/24 network in the LSA broadcasted in area 36. This behavior is explained by the fact that LSA type 1 is designed to exchange information within a single area;
  • Router R5 does not generate an LSA type 1 with information about the external network 172.16.0.0/16;
  • The type 1 LSA generated by R4 will be received by R2 and forwarded to R1 with an increased metric value. Thus, the LSA type 1 is propagated over the entire area with metric increments, the rest of the parameters remaining unchanged.
2

Network LSA

This type of LSA is distributed by the DR within the same area.

This LSA contains the following routing information:

  • the broadcast's segment network address;
  • the broadcast's segment network mask;
  • a list of routers with the established neighboring relations.

This type of LSA is generated only by the routers having a DR role - R1, R2, R3 and R4 (Figure 5c).

Similar to LSA type 1, LSA type 2 is distributed across the entire area with metric value increments.

3

Summary Network LSA

This type of LSA is distributed by the ABR and contains a summary of the routes in one area, that it is intended to be sent through the interfaces included in a different area. LSA types 1 and 2 allow the router to build a topology of the area and calculate the data transmission paths. Type 3 LSAs are not sources of topology data, they only contain routing information about the neighboring areas. Thus, at the area borders, OSPF behaves as a distance vector protocol.

The ABR generates one LSA type 3 for each network. The number of LSA type 3 messaged can be reduced by using route summarization.

This type of LSA is generated by ABR routers - R3 and R4 (Figure 5d).

The R3 router generates the following LSA type 3 messages:

  • route to the 192.168.36.0/24 network of area 36 that will be sent to area 0 through the eth0 interface.
  • route to the 10.10.234.0/29 network of area 0 that will be sent to area 36 through the eth1 interface.
  • route to the 10.10.21.0/30 network of area 0 that will be sent to area 36 through the eth1 interface. This network information is taken from LSA types 1 and 2 received from R1;
  • route to the 192.168.45.0/24 network of area 45 that will be sent to area 36 through the eth1 interface. The route to this network is taken from the LSA type 3 received from router R4. When advertising this network, router R3 sets itself as the route source in the LSA. Source substitution is necessary, since the routers in area 36 are unaware of the R4's location.

Router R4 generates LSA type 3 messages in the same way as R3.

4

ASBR Summary LSA

This type of LSA is distributed by the ABR in addition to LSA type 5.

This type of LSA contains information about the ASBR location.

See the example for LSA type 5.
5

External LSA

This type of LSA is generated by the ASBR for the external routes, including default routes. Such messages are distributed throughout the AS unchanged.

Similar to the ABR, the ASBR can summarize the external routes, i.e. replace several routes with one. This reduces the size of the routing table and the amount of service information during the route distribution.

LSA type 5 is generated by R5 as it is the only ASBR in the network scheme (Figure 5e).

The type 5 LSA generated by R5 contains information about the 172.16.0.0/16 network which is distributed through the entire autonomous system unchanged. Thus, each router in the scheme receives the information that the 172.16.0.0/16 network is external and is available via the R5 router.

The hidden problem is that R1, R2, R3, and R6 do not know R5's location. LSA type 1, where R5's ID is specified, is only propagated within area 45.

To solve this problem, border routers R4 and R3 generate an LSA type 4 in addition to the transmitted LSA type 5. In the LSA type 4, the routers advertise that all the traffic directed to R5 can be sent to the ABR.

6

Group Membership LSA

The LSAs of this type are used in Multicast networks and contain a list of groups whose consumers are in the network segment. This type of LSA will not be described in this article.

-
7

Type 7 LSA

This type of LSA is similar to LSA type 5 and is used in NSSA areas. The use of LSA type 7 is necessary for the compatibility between Stub areas and NSSA areas. LSA type 7 is converted to LSA type 5 by the ABR during the export from the NSSA area.An example of LSA type 7 generation is presented in the NSSA area description.

Figure 5a - Network scheme used for analyzing the LSA types

Figure 5b - Distribution of the LSA type 1

Figure 5c - Distribution of the LSA type 2

Figure 5d - Distribution of the LSA type 3

Figure 5e - Distribution of the LSA type 4 and of the LSA type 5

Building the shortest path tree

After the LSDB synchronization, each router performs a shortest path tree calculation using Dijkstra's algorithm.

In the networks having redundancy implemented, the LSDB contains announcements 1about the same network received from different sources. Such routes are transmitted to the RIB in the following order:

Area types

The way to reduce the OSPF service traffic volume is to use different types of areas. The OSPF protocol provides the following types of areas:

Let's look at the main features of different area types using the example in (Figure 6): routers R1, R2, R3 and R4 are connected in chain with each other, forming three OSPF areas. Routers R3 and R4 have external links. In each example, we will change the type of area 4 and analyze the LSA types associated with that area. In these examples, the LSA's not related with area 4 and the type 1 and 2 LSAs will be omitted because they are distributed within any area type.

Figure 6 - Network scheme used for the description of the area types

Normal

Normal areas do not change the propagation of the LSAs and the processing logic described above (Figure 7a). This area type is used by default. The backbone area is a special case of the Normal area.

Figure 7a - LSA distribution in the Normal area

Stub

The Stub area is characterized by the following features (Figure 7b):

Stub areas are used in LAN segments that have no connection with the external networks, but the routers in this area must receive full routing information from the neighboring areas. Using Stub areas allows to obtain a small increase in performance by reducing the LSA number and to protect the network from attacks from the external network segment.

Figure 7b - LSA distribution in the Stub area

Totally Stub

The Totally Stub area behaves similarly to the Stub area with one exception: LSA's of types 3 and 5 from the neighboring areas are replaced with one LSA type 3 with a default route (Figure 7c).

Totally Stub area applications are similar to the ones of the Stub area, but the routers in a totally stub area will not have all the routing information about the neighboring areas. This offers a significant performance increase, as Totally Stub area routers will use a single default route to transmit data to the neighboring areas.

Figure 7c - LSA distribution in the Totally Stub area

NSSA

The NSSA area has characteristics similar to the Stub area with one exception: the NSSA can have an external link (Figure 7d). Since LSA type 5 which is used to distribute routing information about the external links, is prohibited in Stub areas, NSSA areas use LSA type 7 for this purpose. This LSA type has the same structure as LSA type 5, but it is permitted in NSSA areas. At the area border, the ABR converts the LSA type 7 to LSA type 5, setting itself as the routing source. Since the ABR performing the LSA conversion becomes the source, there is no need to generate an additional type 4 LSA.

Usually, the NSSA area usage is a result of the network's development: connecting an external communication channel to the Stub area requires changing its type to NSSA.

Figure 7d - LSA distribution in the NSSA area

Totally NSSA

Totally NSSA areas behave similarly to the NSSA areas with one exception: only one type 3 LSA with a default route is exported to the Totally NSSA area (Figure 7e).

Totally NSSA areas are a result of the network development: connecting an external link to a Totally Stub area requires changing the type of the area to Totally NSSA.

Figure 7e - LSA distribution in the Totally NSSA area

Virtual link

One of the OSPF principles is to always connect two non-backbone areas only through the backbone area. Despite that, as a result of the historical development, the structure of some networks does not match with this principle. Bringing such networks up to the OSPF backbone can be costly, so OSPF has been extended with the virtual link concept.

The virtual link has the following features (Figure 8):

Figure 8 - Network scheme with a virtual link

OSPF's protocol features

The OSPF protocol features can be summarized as follows:

The examples on how to configure OSPF are present in the child page: OSPF protocol's configuration.

Additional materials

Webinars

  1. Typical scenario of routing setting using Infinet Wireless devices. Part II

Other

  1. Ifconfig command (interfaces configuration)
  2. ARDA (Aqua Router Daemon)
  3. OSPF command
  4. arip command
  5. rip command
  6. RFC 2328