Every spanning tree switched network or broadcast domain has a switch designated as the root bridge. The root bridge serves as the reference point for all spanning-tree enabled switches. The spanning tree algorithm determines which redundant paths to block. It is selected as an election process.
The figure below illustrates the bridge ID (BID) fields. BID is a unique identity when the switch is the part of a network. It is a 64 bits field which is divided into three parts. The first part is 4 bits Bridge Priority field, the second field is 12 bits extended system ID while the third part is the 48 bits MAC address of the switch. The Bridge Priority is configurable while the MAC address is unique among all switches and the sum of these two ensure a unique Bridge ID.
Root Bridge election
All switches in the broadcast domain join the election process. When switches complete their booting process, it begins sending out BPDU frames every two seconds containing the switch BID and the root ID. The adjacent switches receive the BPDU frames and read the root ID information from the BPDU frames. If the root ID of BPDU sending switch is lower than the root ID on the receiving switch, then the receiving switch updates its root ID, identifying the adjacent switch as the root bridge.
It doesn’t need to be the adjacent switch. It could be any other switch in the broadcast domain. The switch then sends out new BPDU frames with the lower root ID to the other adjacent switches. Finally, the switch with the lowest BID ends up being selected as the root bridge for the spanning-tree instance.
Now look the election process at another angle. Before configuring the bridge priority manually all the switches have a default priority, therefore, it is a tie based on priority. Now, the switch with the lowest Mac address will become a root bridge. In the figure below switch-3 is elected as Root Bridge because the bridge priority ID is default which is 32769, So the switches elect root bridge based on MAC address. The switch-3 is the lowest MAC address, so all the ports of the root bridge become in the forwarding state i.e. designated port.