OSPF, the Open Shortest Path First protocol, is one of the interior gateway protocols used within an autonomous system. It is based on link-state routing.
OSPF has five network types:
1. Point-to-Point type, proposed by Cisco, automatically discovers neighbors, does not elect a DR/BDR, and the hello packet interval is 10s.
2. Broadcast type, a network type proposed by Cisco, automatically discovers neighbors, elects a DR/BDR, and the hello packet interval is 10s.
3. Non-Broadcast network type, proposed by RFC, neighbors are manually configured, elects a DR/BDR, and the hello packet interval is 30s.
4. Point-to-Multipoint network type, proposed by RFC, automatically discovers neighbors, does not elect a DR/BDR, and the hello packet interval is 30s.
5. Point-to-Multipoint Non-Broadcast, a network type proposed by Cisco, neighbors are manually configured, does not elect a DR/BDR, and the hello packet interval is 30s.
Because the Point-to-Point network type is easier to understand, this article will mainly focus on the Broadcast network type.
In a broadcast OSPF network, before DR/BDR existed, every router had to establish an adjacency with its neighbors, resulting in numerous adjacency relationships between routers. This led to an excessive number of LSAs being sent. Furthermore, in a broadcast type, an LSA sent by a router could be sent back by a neighbor, creating a lot of duplicate information in the network. Therefore, the DR and BDR were created.
The roles of the DR and BDR are:
1. To describe this multi-access network and the other related routers attached to it.
2. To manage the flooding process on this multi-access network.
3. For redundancy, a BDR is also elected as a backup.
DR/BDR Election Rules
1. Each router port has a priority, an 8-bit field ranging from 0 to 255. The default port priority is 1. A port with a priority of 0 is ineligible for DR/BDR election. The code to set the port priority is: `ip ospf priority`.
2. The hello packet contains the port priority and the IP addresses of the ports that could become DR/BDR.
3. When a port is first activated on a multi-access network, it sets the DR/BDR addresses to 0.0.0.0 and starts a wait timer, setting its value equal to the dead interval.
Definition of the Router ID:
1. The Router ID can be manually configured within OSPF.
2. If no Router ID is manually defined but a loopback interface is configured, the loopback interface with the highest IP address is chosen as the Router ID.
3. If neither is present, the highest IP address among the active physical interfaces is used as the Router ID.
The DR/BDR Election Process:
1. After establishing two-way communication with a neighbor, a router checks the Priority, DR, and BDR fields in the neighbor’s hello packet to list all neighbors eligible for DR/BDR election (excluding those with a Priority of 0).
2. If multiple routers declare themselves as BDR (i.e., identifying themselves as BDR in their hello packets), the one with the highest priority is elected BDR. If priorities are equal, the one with the highest Router ID is chosen. If no router declares itself BDR, the one with the highest priority is elected BDR (excluding those declaring themselves as DR). If priorities are equal, the Router ID is used as a tie-breaker.
3. If one or more routers declare themselves as DR, the one with the highest priority is elected DR; if