The Spanning-Tree Protocol (STP) provides a loop free, layer-2 traffic path when two or more switches are connected to each other with redundant links.
Election Process
An election is held between bridges (also argued as switches) that compare each other’s bridge identifier (ID) known as the root bridge election. The bridge with the lowest bridge ID is elected as the root bridge (the winner!). The root bridge is at the center of convergence within a layer-2 topology running the Spanning-Tree Protocol (STP). As with most elections, the candidates first advertise themselves as the winner. These bridge ID ‘advertisements’ are packaged in what’s known as a Bridge Protocol Data Unit (BPDU), along with other information, by each participating bridge. The BPDU’s are then sent to all participants where the bridge ID is ‘unpacked’ (or more accurately read from the BPDU) and compared against their own. If a bridge receives an advertised bridge ID that’s better than its own, it concedes defeat and advertises the winner in subsequent BPDUs as the root bridge.
Criteria
The bridge ID is an 8-Byte (64 bit) value composed of the following elements:
- The bridge priority value and the system ID extension together make up a 16 bit (2-byte) value. The bridge priority value, making up the left most bits, is a value of 0 to 61440. The extended system ID is a value of 1 to 4095 corresponding to the respective VLAN participating in STP. The bridge priority value increments in blocks of 4096 to allow the system ID extension to squeeze in between each increment. By default, Cisco’s Per-VLAN Spanning-Tree plus (PVST+) adds this system ID extension (sys-id-ext) to the bridge priority.
- The 48 bit (6-byte) MAC address of the switch is used in conjunction with the bridge priority value and the system ID extension as criteria for the root bridge election. If the bridge priority value and the system ID extension are identical on two or more switches the lowest 48-bit MAC address is then used as a tie breaker.
These values together make up the cohesive Bridge Identifier used to elect the root bridge. The following Wireshark packet capture of a BPDU illustrates these values. The bridge priority and system ID extension are the 16-bit hexadecimal value 80 01 representing the bridge priority value of 32768 and a system ID extension of 1.
Example
The example below shows a fully converged layer-2 network with four switches that have an identical bridge priority value and system ID extension. SW3’s MAC address is the lowest value of the four, breaking the tie, making SW3 the root bridge.
