This is the 10th day of my participation in Gwen Challenge

The characteristics of the OSPF

Each router knows the topology of the entire network through the Link State DataBase (LSDB). As shown in the figure, each router collects Lsas from other routers. All Lsas are put together to form the LSDB. An LSA describes the network topology around a router, and an LSDB describes the network topology of an entire AS. The router converts the LSDB into a weighted directed graph, which is a true reflection of the entire network topology. When the network topology is stable, the digraph obtained by each router is exactly the same.

Routers calculate the route to the destination network based on the Shortest Path First (****) algorithm instead of obtaining routing information from routing advertisements.

OSPF operating mechanism

1. Establish a neighbor relationship by exchanging Hello packets

After OSPF is enabled, the router sends Hello packets from all OSPF enabled interfaces. If two routers share a common data link and can successfully negotiate certain parameters specified in their Respective Hello packets, the neighbor relationship can be established.

2. Advertise link state information through flood LSA

Adjacency routers can exchange Lsas. An LSA describes all links, interfaces, neighbors, and link status of a router. Routers exchange these links to learn about the topology of the entire network. Due to the diversity of links, OSPF defines multiple LSA types.

3. Create an LSDB to form a weighted directed graph

After LSA flooding, the router collects received Lsas and records them in the LSDB. Eventually, all routers form the same ****LSDB. An LSA describes the network topology around a router, while an LSDB describes the network topology of an entire AS. An LSDB is a summary of Lsas.

4. Use the SPF algorithm to calculate and form routes

After LSDB synchronization is complete, each router takes itself as the root and uses the SPF algorithm to calculate a loop-free topology to describe the shortest path (minimum path cost) that it knows to reach each destination. This topology is known as the shortest path tree, with which the router knows the optimal path to each node in the autonomous system.

5. Maintain and update the routing table

After obtaining the shortest path tree based on the SPF algorithm, each router loads the calculated shortest path to the OSPF routing table to form routing entries that guide data forwarding and updates them in real time. At the same time, neighbors exchange Hello packets to keep alive **, maintain the neighbor relationship or adjacency relationship, and periodically retransmit ****LSA**.

Indicates the network type supported by OSPF

Broadcast type

If the link layer protocol is Ethernet or Fiber Distributed Digital Interface (FDDI), OSPF considers the network type to be Broadcast by default.

Hello packets, LSU packets, and LSAck packets are sent in multicast mode. The multicast address 224.0.0.5 is the reserved IP multicast address of the OSPF device. The multicast address of 224.0.0.6 is the reserved IP multicast address of the DR/BDR.

DD packets and LSR packets are sent in unicast mode.

Non-broadcast multi-access (NBMA)

If the link layer protocol is Frame Relay or X.25, OSPF considers the network type to be NBMA by default.

On this type of network, protocol packets such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets are transmitted in unicast mode.

Point-to-point P2P

When the link layer protocol is PPP, HDLC, or LAPB, OSPF considers the network type to be P2P by default.

On this type of network, protocol packets such as Hello packets, DD packets, LSR packets, LSU packets, and LSAck packets are sent in multicast mode (224.0.0.5).

Point-to-multipoint P2MP

None of the link layer protocols are considered P2MP by default. Point-to-multipoint changes must be enforced by other network types. A common practice is to replace a non-fully connected NBMA with a point-to-multipoint network.

Sends Hello packets in multicast mode (224.0.0.5).

Sends other protocol packets (DD packets, LSR packets, LSU packets, and LSAck packets) in unicast mode.

DR and BDR elections

Router ID

The Router ID is a 32-bit integer that uniquely identifies an OSPF Router in an AS. Each OSPF Router has a Router ID. The format of the Router ID is the same as that of the IP address. In actual network deployment, to ensure protocol stability, you are advised to use the IP address of the Loopback interface on the Router as the Router ID.

You can select a Router ID in either of the following ways: manually configure the Router ID on the CLI or automatically configure the Router ID on the device.

If the Router ID is not manually configured, the device automatically selects one of the IP addresses of the current interface as the Router ID. The order of selection is:

  1. The maximum IP address among Loopback addresses is selected as the Router ID.
  2. If no Loopback interface is configured, select the largest IP address from the interface address as the Router ID.

The Router ID can be selected again only after the Router ID of the system or OSPF is reconfigured and the OSPF process is restarted.

Reasons for DR and BDR elections

In broadcast networks and NBMA networks, routing information is transmitted between any two routers. If there are n routers on the network, you need to establish n x (N-1)/2 adjacencies. As a result, the route changes of any router will lead to multiple transmission, wasting bandwidth resources.

To solve this problem, OSPF defines DR. After the DR is elected, all other devices only send information to the DR, and the DR broadcasts the LINK state LSA.

To prevent services from being interrupted when a DR is re-elected, a backup router BDR is also elected. In this way, routers Other than DR and BDR (called DR Other) do not establish adjacency relationships or exchange routing information. In this way, the number of adjacency relationships between routers on broadcast networks and NBMA networks is reduced.

Principles for DR and BDR elections

elections

When two routers on the same network segment declare themselves as DR routers, the router with the highest DR priority wins. If the priorities are equal, the one with the larger Router ID wins. If the priority of a router is 0, it is not elected as DR or BDR.

For life

The lifetime system is also called non-preemption.

hereditary

The DR and BDR cannot be elected on the network

If the OSPF dr-priority command is run on GE1/0/1 of R1 to set the Dr Priority of the interface to 0, R1 loses the qualification of Dr And BDR. In this case, no router on the network is eligible for the DR and BDR elections.

In this case, all the neighbor states remain in the 2-way state, the network cannot establish adjacency relationships, and routers cannot exchange routing information

OSPF interface state machine

An OSPF interface has the following seven states:

  • Down: indicates the initial status of the interface. Indicates that the interface is unavailable and cannot be used to send or receive traffic.
  • Loopback: indicates that the interface between the device and the network is in Loopback state. A loopback interface cannot be used for normal data transmission, but can be advertised through router-Lsas. As a result, connectivity testing can discover the path to this interface.
  • Waiting: The device is determining the DR and BDR on the network. Before the device participates in the DR and BDR elections, the Waiting timer is enabled on the interface. Before the timer expires, the Hello packets sent by the device do not contain the DR or BDR information, and the device cannot be elected as the DR or BDR. In this way, the DR and BDR in the link are not changed unnecessarily. Only NBMA networks and broadcast networks have this status.
  • P-2-p: Indicates that an interface is connected to a physical point-to-point network or virtual link. In this case, the device establishes an adjacency relationship with the device at the other end of the link. This state exists only on P2P and P2MP networks.
  • DROther: Devices are not elected as DR or BDR, but other devices connected to broadcast networks or NBMA networks are elected as DR. It establishes adjacencies with DR and BDR.
  • BDR: The device is the BDR of the connected network and will become the DR when the current DR fails. The device establishes adjacency relationships with all other devices connected to the network.
  • DR: The device is the DR of the connected network. The device establishes adjacency relationships with all other devices connected to the network.

OSPF neighbor state machine

There are eight OSPF neighbor states:

  • Down: indicates the initial phase of the neighbor session. It indicates that no Hello packet from the neighbor is received within the interval. OSPF routers on NBMA networks send Hello packets to Down neighbor routers (invalid neighbor routers) every PollInterval. However, other networks do not send Hello packets to invalid neighbor routers.
  • Attempt: This state applies to an NBMA network. The neighbor router is manually configured. When the neighbor relationship is in this state, the router sends Hello packets to the manually configured neighbor every HelloInterval to establish the neighbor relationship.
  • Init: Indicates that the peer end receives the Hello packet from the neighbor, but the peer end does not receive the Hello packet from the local end. The neighbor list of the received Hello packet does not contain the Router ID of the local end, and the bidirectional communication is not established.
  • 2-way: indicates the neighbor relationship. This status indicates that the two parties receive the Hello packet from the peer end. The neighbor list in the packet also contains the Router ID of the local end, and the neighbor relationship is established. If no adjacency relationship is formed, the neighbor state stays in this state. Otherwise, the neighbor state enters the ExStart state. DR and BDR are elected only when the neighbor state is in this state or higher.
  • ExStart: negotiates the master/slave relationship. The primary/secondary relationship is set up to ensure that DD packets can be sent sequentially in subsequent exchanges. Neighbors start to establish an adjacency relationship.
  • Exchange: DD packets are exchanged. The local device describes the local LSDB in DD packets and sends them to its neighbors.
  • Loading: LSDB is being synchronized. The two devices send LSR packets to the neighbor to request lsas of the other and synchronize LSDBS.
  • Full: Establishes an adjacency. The LSDB of the two devices is synchronized. The local device and its neighbor establish a complete adjacency relationship.

Description OSPF neighbor status switchover

Adjacency establishment in broadcast networks

Adjacency establishment on an NBMA network

Point-to-point networks and point-to-multipoint networks

The process of establishing OSPF adjacencies on point-to-point networks and point-to-multipoint networks is similar to that on broadcast networks. DR and BDR do not need to be elected in point-to-point or point-to-multipoint networks, and DD packets are unicast in point-to-point networks.

Stub area and Totally Stub area

From the perspective of network optimization, the size of routing entries should be reduced as much as possible to reduce the flooding of LSA packets in the network while ensuring network accessibility. Area 2 if Area 2 is a common Area, five types of lsas may exist: Type1, Type2, Type3, Type4, and Type5. For routers in Area 2, no matter which network they want to access outside the Area, they must reach the ABR router first. That is, other routers in Area 2 do not need to know the details of the external network. In this case, the OSPF Stub area is generated.

A Stub area is a special area. The ABRS in the Stub area do not propagate the routes they receive from the external AS. Therefore, the size of the routing table and the amount of routing information transmitted by the routers in the Stub area are greatly reduced.

The Stub area is an optional configuration attribute, but not all areas meet the configuration requirements. Generally speaking, a Stub area is a non-backbone area that has only one ABR and is located at the border of an AS.

To ensure the reachable route to the external as, the ABR in the Stub area generates a default route and advertises it to other non-ABR routers in the Stub area.

Note the following when configuring the Stub area:

  • The backbone area cannot be configured as a Stub area.
  • To configure an area as a Stub area, all routers in the area must be configured with Stub area attributes.
  • Asbrs cannot exist in the Stub area, that is, routes outside the AS cannot be transmitted in the Stub area.
  • The virtual link cannot pass through the Stub area.

For routers in Area 2, it is not necessary to know all the detailed routes between areas. It is sufficient to reserve only one egress to allow packets from routers in Area 2 to go out. This generates an OSPF Totally Stub Area. A Totally Stub area does not allow routes outside the AS to be transmitted in the area, nor does it allow routes between areas to be transmitted in the area, which further reduces the number of Lsas in the area.

NSSA area and Totally NSSA area

Compared with the Stub area, the NSSA area can import and propagate external routes from the AS to the entire OSPF AS, but does not learn routes from other AREAS of the OSPF network.

In the NSSA area, the ABR in the NSSA area generates a default route and advertises it to other routers in the NSSA area to ensure the route to the external AS is reachable.

Note the following when configuring NSSA areas:

  • The backbone area cannot be configured as an NSSA area.
  • To configure an area as an NSSA area, all routers in the area must be configured with NSSA area attributes.
  • The virtual link cannot pass through the NSSA area.
  • In the NSSA area, multiple ABRs may exist at the same time. To prevent routing loops, border routers do not calculate the default routes advertised by each other.

Similar to the Totally Stub area, OSPF defines a Totally NSSA area to further reduce the number of Lsas in the NSSA area.

OSPF interarea loop and anti-loop method

OSPF runs the SPF algorithm inside an area, which ensures that the routes in the area do not form loops. However, after region division, route transmission between regions is actually a way similar to distance vector algorithm, which is easy to generate loops.

To avoid inter-area loops, OSPF does not allow routing information to be directly advertised between two non-backbone areas. Routing information can only be advertised within an area or between backbone areas and non-backbone areas. Therefore, each ABR must be connected to the backbone area.

If OSPF allows direct route transfer between non-backbone areas, inter-area loops may occur. As shown in Figure 5, routing information for backbone connections to other networks is passed to Area 1. If routing information is allowed to be directly transmitted between non-backbone areas, the routing information is eventually transmitted back to form a routing loop between areas. To prevent such interarea loops, OSPF forbids direct route interaction between Area 1 and Area 3, and between Area 2 and Area 3. Instead, route interaction must be carried out through the backbone Area. This prevents interregional loops.

OSPF Default Route

A default route is a route whose destination address and mask are both 0. If the device does not have an exact route, packets can be forwarded through the default route. Due to the hierarchical management of OSPF routes, the preference of default Type3 routes is higher than that of Type5 or Type7 routes.

OSPF default routes are usually applied to the following situations:

  • The Area Border Router (ABR) advertises Type3 default Summary Lsas to guide devices in an area to forward packets between areas.
  • The ASBR advertises Type5 external default ASE Lsas or Type7 external default NSSA Lsas to guide devices in the AS to forward packets outside the AS.

The principles for advertising OSPF default routes are as follows:

  • An OSPF router can advertise default route Lsas only when it has egress to outside areas.
  • If an OSPF router advertises default route Lsas, it does not learn the same type of default routes advertised by other routers. That is, default route Lsas of the same type advertised by other routers are not counted during route calculation, but corresponding Lsas exist in the database.
  • If external default routes depend on other routes to advertise, the routes to be relied on cannot be those in the OSPF routing domain, that is, the routes not learned by the OSPF process. The external default route is used to guide packet forwarding outside the domain. However, the next hops of the routes in the OSPF routing domain all point to the inside domain. Therefore, the external default route cannot guide packet forwarding outside the domain.

OSPF LSA types

Router-LSA

A router-LSA is a basic LSA, that is, a Type1 LSA.

Each routing device on an OSPF network advertises Type1 Lsas. This type of LSA describes the link status and cost of the device and is advertised in the area where the router belongs.

Network-LSA

Network-lsas, namely Type2 Lsas, are generated by the Designated Router (DR) and describe the link status of the local Network segment. They are advertised in the area to which they belong. As shown in The figure, R3 sends a Network-LSA to R2, listing the ids of all routers that are fully adjacent to the DR.

Network-summary-LSA

Network-summary-lsa, also called Type3 LSA, is advertised by ABRS to describe the routing information between areas. An ABR advertises a Network-summary-LSA to an area to advertise the destination address of the area to other areas. In fact, an ABR collects Type1 and Type2 information within an area, summarizes it, and then diffuses it out. This is the meaning of Summary. As shown in the figure, R2 acts as an ABR and advertises routing information in Area 0 and Area 1 to each other’s areas.

ASBR-Summary-LSA

Asbr-summary-lsa, also called Type4 LSA, is advertised by the ABR, describes the route information to the ASBR, and advertises the route information to other related areas except the area where the ASBR resides. As shown in The figure, R3 advertises asBR-summary-LSA to Area 0 as an ABR.

AS-external-LSA

As-external-lsa, also called Type5 LSA, is generated by the ASBR. It describes routes to the outside of the AS and advertises them to all areas except the Stub area and NSSA area. AS shown in the figure, R4 advertises an OSPF AS route to the external destination network AS an ASBR.

NSSA LSA

In addition to the preceding lsas, there is a special LSA, NSSA LSA, also called Type7 LSA. The NSSA LSA is generated by the ASBR and describes the route to the outside of the AS. It is propagated only in the NSSA area. When an ABR in the NSSA area receives an NSSA LSA, it converts it into a Type5 LSA to advertise external routing information to other areas of the OSPF network.

LSA propagation in different areas

OSPF Fast Convergence

OSPF fast convergence is an extended feature to improve the route convergence speed. Include:

  • OSPF convergence by Priority OSPF convergence by priority is a technology that enables the convergence of certain routes in a large number of routes. You can configure different convergence priorities for different routes to achieve convergence of important routes first and improve network reliability. Therefore, you can set the routes related to key services to a higher priority to accelerate the convergence of these routes and minimize the impact on key services.
  • Partial Route Calculation (PRC) When network routing changes, only the changed routes are recalculated.

The intelligent timer controls the generation and receipt of Lsas to quickly respond to low-frequency changes and effectively suppress high-frequency changes. RFC2328 uses the following two rules to prevent excessive device resource occupation caused by frequent network connection or route turbulence:

The same LSA cannot be generated within one second, that is, the LSA update interval is five seconds.

The interval for receiving lsas is 1 second. In a stable network that requires a high time for route convergence, you can set the interval for updating and receiving Lsas to 0 by using an intelligent timer. In this way, topology or route changes can be advertised to the network through Lsas or detected immediately, accelerating route convergence.

  • Using intelligent timers To control route calculation When the network changes, OSPF needs to recalcate routes. To avoid the impact of frequent network changes on the device, standard RFC2328 stipulates that a delay timer should be used in route calculation and route calculation should be performed only after the timer expires. However, in the standard protocol, the timer interval is fixed, so it can not respond quickly and suppress the oscillation. Intelligent timer is used to control the delay time of route calculation, which can quickly respond to low frequency changes and effectively suppress high frequency changes.

OSPF virtual connection

A Virtual link is a logical connection channel established between two ABRs through a non-backbone area.

According to RFC 2328, when deploying OSPF, all non-backbone areas must be connected to backbone areas; otherwise, some areas may be unreachable. However, in actual applications, all non-backbone areas cannot be connected to backbone areas due to various conditions. In this case, you can configure OSPF virtual links to solve this problem.

Area 2 is not connected to backbone Area 0. Therefore, RouterA cannot be used as an ABR to generate routing information about Network1 in Area 0 to Area 2. Therefore, there is no route to Network1 on RouterB. In this case, you can deploy virtual links to solve this problem.

Through a virtual link, OSPF packets are directly transmitted between two ABRs. The OSPF devices between the two ABRs only forward packets. The destination ADDRESSES of OSPF packets are not those of the devices. Therefore, these packets are transparent to the devices and are forwarded as common IP packets.

A virtual link forms a point-to-point connection between two ABRs. Therefore, you can configure interface parameters, such as the interval for sending Hello packets, on both ends of the virtual link as on physical interfaces. The Transit Area provides a non-backbone internal route for both ends of the virtual link. The virtual link configuration takes effect only when it is configured on both ends.

However, the existence of virtual links increases the complexity of the network and makes troubleshooting more difficult. Therefore, you should avoid using virtual links in network planning. Virtual links are intended only as a temporary fix for unavoidable network topology problems. Virtual links can be regarded as a sign indicating whether a part of the network needs to be redesigned.

OSPF Route Aggregation

In route aggregation, an ABR can aggregate routes with the same prefix and advertise only one route to other areas.

Inter-area route aggregation reduces routing information, reduces the size of the routing table, and improves device performance.

OSPF has two route aggregation modes:

  • ABR Aggregation When an ABR sends routing information to other areas, it generates Type3 Lsas in the unit of network segment. If there are some consecutive network segments in the region, you can run a command to aggregate these consecutive network segments into one network segment. In this way, the ABR sends only one aggregated LSA. All lsas that belong to the aggregation network segment specified by the command are not sent separately.
  • ASBR aggregation After route aggregation is configured, if the local device is an ASBR, the imported Type5 Lsas within the aggregation address range are summarized. When the NSSA area is configured, the Imported Type7 Lsas within the imported aggregate address range are aggregated.

If the local device is both an ASBR and an ABR, the Type5 Lsas converted from Type7 Lsas are summarized.

OSPF Route Filtering

OSPF supports routing policies to filter route information. By default, OSPF does not filter routes.

OSPF can use routing policies including route-policy, access-list, and prefix-list.

OSPF route filtering can be applied to the following aspects:

  • Route Import OSPF can import routes learned by other routing protocols. You can configure a routing policy to filter routes and import only the routes that meet the conditions.
  • Advertise imported routes After OSPF imports routes, it advertises the imported routes to other neighbors. You can configure filtering rules to filter the routes advertised to neighbors. The filtering rule is valid only on the ASBR.
  • Route learning By configuring filtering rules, you can configure OSPF to filter the received intra-area, inter-area, and external as routes. The filtering takes effect only on whether routing entries are added. That is, only the routes that pass the filtering are added to the local routing table. However, all routes can still be advertised in the OSPF routing table.
  • Learning inter-area Lsas You can configure the ABR to filter Summary Lsas that enter the local area by running commands. This configuration takes effect only on abRs (only ABRs can advertise Summary Lsas). The differences between interarea LSA learning and route learning are as follows: Interarea LSA learning directly filters incoming Lsas. Route learning does not filter Lsas, but whether the routes calculated by Lsas are added to the local routing table. The learned Lsas are complete.
  • Advertisement of inter-area Lsas You can configure the ABR to filter outgoing Summary Lsas in the local area by running commands. This configuration takes effect only on abRS.

OSPF process more

OSPF supports multi-process. Multiple OSPF processes can run on the same router and are independent of each other. Route interaction between OSPF processes is equivalent to route interaction between different routing protocols.

An interface on a router can belong to only one OSPF process.

A typical application of OSPF multi-process is to run OSPF between PES and ces in VPN scenarios, and OSPF is also used on IGPs on VPN backbone networks. On the PE, the two OSPF processes do not affect each other.

Finally is a finishing OSPF mind map!

This article is compiled from huawei official documents!