The physical topology of the experiment in this chapter is shown in Figure 3-0. Unless otherwise specified, the IP addressing rules are as follows: the G4 interface address of XE3 is 13.1.1.3/24 (xy.1.1.x, where xy is the device number), and the loopback interface address is 33.1.1.1/32
Core routing protocol OSPF - This article comes from QYTang CCIE certification training instructor Jun Ge's "Cisco Operator CCIE Certification Implementation Guide"
-This article comes from QYTang CCIE certification training instructor Jun Ge's "Cisco Operator CCIE Certification Implementation Guide"
The physical topology of the experiment in this chapter is shown in Figure 3-0. Unless otherwise specified, the IP addressing rules are as follows: the G4 interface address of XE3 is 13.1.1.3/24 (xy.1.1.x, where xy is the device number), and the loopback interface address is 33.1.1.1/32

Figure 3-1 Physical topology used in part of the OSPF protocol
3.1 OSPFv2 theoretical basis
The Open Shortest Path First (OSPF) protocol is a routing protocol developed by the Internet Engineering Task Force (IETF). The OSPF protocol is a link state protocol. As its name states, OSPF uses Dijkstra's Shortest Path First (SPF) algorithm, which is open and not proprietary to any one vendor or organization. The development of the OSPF protocol has gone through several RFCs. OSPFv2 is the OSPF currently used in IPv4 networks and is described in RFC2328.
Like all link state protocols, the main difference between the OSPF protocol and the distance vector protocol is its rapid convergence, which allows the OSPF protocol to support larger networks. Other features of the OSPF protocol are:
?The concept of areas is used, which can effectively reduce the CPU and memory usage of the router by the routing protocol; dividing areas can also reduce the number of OSPF packets on the link, which allows OSPF to build a hierarchical network topology;
? Fully supports classless addresses, eliminating routing problems such as discontinuous subnets. VLSM can be used to effectively manage IP addresses, and it can also support supernet technology;
?Support measurement values of any size;
?Support equal-cost load balancing of multiple paths;
?Use multicast address communication to reduce the impact on non-OSPF devices;
?Support more secure (ciphertext) authentication;
?External routes can be marked.
3.1.1 Basic principles of OSPF
From a general perspective, the implementation process of the OSPF protocol is easy to explain:
1. The router running OSPF sends Hello packets from all interfaces that enable the OSPF protocol. Directly connected OSPF routers will compare certain parameters specified in their respective Hello data. If they are consistent, they will become neighbors.
2. Start establishing an adjacency relationship. The OSPF protocol defines adjacency relationships between some network types and some router types.
3. After the adjacency relationship is established, the router starts sending Link State Advertisement (LSA) to synchronize the Link State Database (LSDB).
4. After the LSDB synchronization of each area is completed, each router uses itself as the root and uses the SPF algorithm to calculate a loop-free topology diagram to describe the shortest path (minimum cost) to each known destination network.
5. Finally, write the optimal path obtained by the SPF algorithm into the routing table. At this point, all OSPF routers in the network have calculated their respective paths, sent Hello packets to each other to maintain neighbor relationships, and resent all LSAs every 30 minutes.
3.2 OSPFv2 network type and designated router
3.2.1 OSPFv2 network type
The OSPF protocol defines the following 5 network types
1. Point-to-point network (Point-to-point)
2.Broadcast network
3. Non-broadcast multiple access (NBMA)
4. Point-to-multipoint network (Point-to-multipoint)
5.Virtual links
?Point-to-point network (Point-to-point)
Point-to-point network, the default network type for T1 links (serial links), there are only two devices on a link. In a point-to-point network, valid OSPF neighbors form adjacencies. OSPF data packets in the network are delivered in the form of multicast, and the destination address is the Class D multicast address 224.0.0.5. This multicast address is called All OSPF Routers.
?Broadcast network
Broadcast network, the default network type of Ethernet, can also be defined as broadcast multi-access to distinguish NBMA networks. In a broadcast network, more than two devices can be connected. It is precisely because of the broadcast network that the data sent by one router can be received by all devices on the network. In order to facilitate "management", in the broadcast network, it is necessary to elect a designated router (DR, main room) and a backup designated router (BDR, side room). In a broadcast network, Hello packets from all OSPF routers are sent to the multicast address 224.0.0.5. Link status advertisements from non-designated routers are sent to the designated routers and backup designated routers through the multicast address 224.0.0.6 (All DR Routers). The designated routers send them to other OSPF routers through the multicast address 224.0.0.5.
?Non-broadcast multiple access network (NBMA)
NBMA networks, the default network type for X.25, Frame Relay, and ATM, can connect more than two routers, but they do not have the ability to broadcast packets. By default, packets sent by routers cannot be received by other routers, so routers on these networks must add configuration to establish their neighbors. OSPF routers in NBMA networks need to elect DR and BDR, and all OSPF packets are unicast.
?Point-to-multipoint network (Point-to-multipoint)
Point-to-multipoint network is a special configuration of NBMA network and can be regarded as a collection of point-to-point links. OSPF routers in this kind of network do not need to elect DRs and BDRs, and OSPF packets are sent in unicast mode to every known neighbor.
?Virtual links
Virtual links will be explained in a later section and can be considered by routers as special point-to-point networks. OSPF data packets are sent in unicast mode on virtual links.
3.2.2 Designated router and backup designated router
For the OSPF protocol, there are still two problems related to LSA flooding on multi-access networks:
?When establishing adjacencies between routers, many unnecessary LSAs will be created. Assume that there are n routers on a multi-access network, which will form nn-1/2 adjacencies, as shown in Figure 3-1. Each router will advertise n-1 LSA information to other adjacent routers, plus a network LSA. The final result of this calculation is that n2 LSA advertisements will be generated on this network.
?The flooding of the multi-access network itself appears chaotic. A router sends an LSA to all its adjacent routers, and these adjacent routers in turn send this LSA to all its adjacent routers. This will create many identical copies of the LSA on the same network.

From a general perspective, the implementation process of the OSPF protocol is easy to explain:
1. The router running OSPF sends Hello packets from all interfaces that enable the OSPF protocol. Directly connected OSPF routers will compare certain parameters specified in their respective Hello data. If they are consistent, they will become neighbors.
2. Start establishing an adjacency relationship. The OSPF protocol defines adjacency relationships between some network types and some router types.
3. After the adjacency relationship is established, the router starts sending Link State Advertisement (LSA) to synchronize the Link State Database (LSDB).
4. After the LSDB synchronization of each area is completed, each router uses itself as the root and uses the SPF algorithm to calculate a loop-free topology diagram to describe the shortest path (minimum cost) to each known destination network.
5. Finally, write the optimal path obtained by the SPF algorithm into the routing table. At this point, all OSPF routers in the network have calculated their respective paths, sent Hello packets to each other to maintain neighbor relationships, and resent all LSAs every 30 minutes.
3.2 OSPFv2 network type and designated router
3.2.1 OSPFv2 network type
The OSPF protocol defines the following 5 network types
1. Point-to-point network (Point-to-point)
2.Broadcast network
3. Non-broadcast multiple access (NBMA)
4. Point-to-multipoint network (Point-to-multipoint)
5.Virtual links
?Point-to-point network (Point-to-point)
Point-to-point network, the default network type for T1 links (serial links), there are only two devices on a link. In a point-to-point network, valid OSPF neighbors form adjacencies. OSPF data packets in the network are delivered in the form of multicast, and the destination address is the Class D multicast address 224.0.0.5. This multicast address is called All OSPF Routers.
?Broadcast network
Broadcast network, the default network type of Ethernet, can also be defined as broadcast multi-access to distinguish NBMA networks. In a broadcast network, more than two devices can be connected. It is precisely because of the broadcast network that the data sent by one router can be received by all devices on the network. In order to facilitate "management", in the broadcast network, it is necessary to elect a designated router (DR, main room) and a backup designated router (BDR, side room). In a broadcast network, Hello packets from all OSPF routers are sent to the multicast address 224.0.0.5. Link status advertisements from non-designated routers are sent to the designated routers and backup designated routers through the multicast address 224.0.0.6 (All DR Routers). The designated routers send them to other OSPF routers through the multicast address 224.0.0.5.
?Non-broadcast multiple access network (NBMA)
NBMA networks, the default network type for X.25, Frame Relay, and ATM, can connect more than two routers, but they do not have the ability to broadcast packets. By default, packets sent by routers cannot be received by other routers, so routers on these networks must add configuration to establish their neighbors. OSPF routers in NBMA networks need to elect DR and BDR, and all OSPF packets are unicast.
?Point-to-multipoint network (Point-to-multipoint)
Point-to-multipoint network is a special configuration of NBMA network and can be regarded as a collection of point-to-point links. OSPF routers in this kind of network do not need to elect DRs and BDRs, and OSPF packets are sent in unicast mode to every known neighbor.
?Virtual links
Virtual links will be explained in a later section and can be considered by routers as special point-to-point networks. OSPF data packets are sent in unicast mode on virtual links.
3.2.2 Designated router and backup designated router
For the OSPF protocol, there are still two problems related to LSA flooding on multi-access networks:
?When establishing adjacencies between routers, many unnecessary LSAs will be created. Assume that there are n routers on a multi-access network, which will form nn-1/2 adjacencies, as shown in Figure 3-1. Each router will advertise n-1 LSA information to other adjacent routers, plus a network LSA. The final result of this calculation is that n2 LSA advertisements will be generated on this network.
?The flooding of the multi-access network itself appears chaotic. A router sends an LSA to all its adjacent routers, and these adjacent routers in turn send this LSA to all its adjacent routers. This will create many identical copies of the LSA on the same network.
To avoid these problems on a multi-access network, you can elect a designated router (owner) on the multi-access network. This router will do the following:
?Describe the routers connected to it in this multi-access network and in the OSPF area;
?Manage the flooding process on this multi-access network.
Each router in the network will form an adjacency relationship with the DR. Figure 3-2 shows a schematic diagram of OSPF design after specifying a router (DR). Remember, DR is a characteristic of the router interface, not the entire network. In other words, an interface on a certain router will become the DR in the current multi-access network.

From what has been described so far, it can be seen that the designated router plays a very important role. Once the designated router fails, a new designated router must be elected. At the same time, all routers on the network must establish new adjacency relationships with the re-elected designated router and synchronize their link state databases. When the above process occurs, the network cannot deliver packets efficiently.
In order to avoid this problem, in addition to electing the designated router on the network, a backup designated router (BDR, spare tire) must also be elected. In this way, all routers and designated routers on the network form adjacency relationships with the backup designated router at the same time. DR and BDR also form adjacency relationships with each other. At this time, if the DR fails, the BDR will become the new DR. Since other routers have formed adjacencies with the BDR, the impact of being unable to deliver data can be minimized.
3.2.3 Election of designated router and backup designated router
The designated router relies on the Router Priority and Router ID fields in the Hello packet for election.
l Each multi-access interface of each router has a router priority, represented by an 8-bit binary unsigned integer, ranging from 0-255. On Cisco devices, the default priority is 1. It can be modified through the command (ip ospf priority) under the interface. Router interfaces with priority 0 will not participate in the election (cannot become DR or BDR).
l After the neighbor relationship is established, if the network type requires DR election, start the election, otherwise skip the election process.
l During the election process, the interface with the highest priority will be elected as the DR, and the interface with the second highest priority will be elected as the BDR. If the priorities are the same, compare the router IDs, the highest is DR, and the second highest is BDR. If the priority of only one interface is greater than 0, then there is only DR in the network and no BDR.
l After the DR and BDR elections are completed, all routers establish adjacency relationships with the DR and BDR.
l The election result of DR is "life-long". The DR fails, the BDR becomes the DR, re-elect a BDR and establish an adjacency relationship. The BDR fails. Re-elect the BDR and establish an adjacency relationship.
3.2.4 Designated router election case
Experimental logical topology:

Experimental purpose: Verify OSPF’s DR election principle
Basic configuration:
To be continued, the next section will talk about - basic configuration
Core routing protocol OSPF
-This article comes from QYTang CCIE certification training instructor Jun Ge's "Cisco Operator CCIE Certification Implementation Guide"
"Cisco Carrier CCIE Certification Implementation Guide" is available at JD and TB, and you can purchase it yourself.
For technical questions, you can join the group: 346968792, and Mr. Ande will answer questions online.
QYTang customer service hotline: 400-618-8070
QYTang official website: www.qytang.com
QYTang Network Lab We think more for you