The specific election of the Dr occurs after the routers have become neighbors but before DBD packets are sent and Exstart state. When a router reaches the 2-way state, it has received at least one Hello and has found its RID in the list of routers in the Hello.
If the Hello messages have DR of 0.0.0.0 meaning that no DR has been elected yet, the router will wait for a period of time before attempting to elect a DR. This time period is called the OSPF wait time and is set to the same value as the Dead Timer.
However if the received Hello already lists the DRs RID in the Hello packet, the router does not have to wait to begin the election process.
Having the router wait to begin the election allows other routers to come online and participate in the election. Here are the general rules for the election process:
- Routers with OSPF priority set to 1-255 are eligible to become a DR or BDR, priority of 0 is ignored in elections.
- The router performs the election locally but the algorithm ensures that all routers arrive at the same conclusion.
- Each router collects the priorities and RIDs of other participating routers on the network during the OSPF wait time, during this time the RID field is set to 0.0.0.0
- If a Hello packet comes in during the OSPF wait time and already has the RID defined with another router the election process can begin. Otherwise the OSPF wait time must expire before it begins.
- The election is performed only for roles that have not yet been determined. First looking at the priorities of the routers then the RIDs if there is a tie in priority. The highest RID wins if there is a priority tie, or no priority configured.
- There is no preemption for new devices being added to the network
- When a DR fails the BDR becomes the new DR, and a new election is held for a new BDR.
If for some reason the election is interrupted by an STP event or something of that nature, when the affected routers come online with a Dr already chosen but different than all the others will force another election to occur.