The spanning tree algorithm exchange Bridge Protocol Data Unit (BPDU) to elect Root Bridge. It is a frame containing 12 different fields with different information. The information in the BPDU is used to determine the root bridge as well as the paths to the root bridge. The figure below illustrates the Bridge Protocol Data Unit (BPDU) frame fields.
The first four fields recognize the protocol, version, message type, and status flags. The next four fields identify the root bridge and the cost of the path to the root bridge. The last four fields decide the timer values for Bridge Protocol Data Unit (BPDU) messages. The Bridge Protocol Data Unit (BPDU) frame is encapsulated in an 802.3 Ethernet frame when it is sending across the network.
The 802.3 Ethernet headers contain the source and destination addresses of the Bridge Protocol Data Unit (BPDU) frame. The figure below illustrates an in STP packet encapsulated into 802.3 headers. This frame has a destination MAC address of 0180:C200:0000.
This is a multicast address for the spanning-tree group. When a frame is addressed with this MAC address, each switch the domain configured for spanning tree accepts and reads the information from the frame. All other devices on the network ignore the frame.
The figure below illustrates the Bridge Protocol Data Unit (BPDU) detail inside the 802.3 headers. The root ID and the BID is the same in the captured Bridge Protocol Data Unit (BPDU) frame. This indicates that the frame was captured from a root bridge. All the timers are set to the default values.
802.1D Bridge Protocol Data Unit (BPDU) Propagation and Process
When a switch booted, it sends a Bridge Protocol Data Unit (BPDU) to assume that it is a root bridge for the spanning-tree protocol. The BPDU frames contain the BID of the local switch as the root ID as you can see in the above image.
The default, BPDU sending time is two seconds, so the switch sends a BPDU after every two seconds. The default value of the Hello timer in the BPDU frame is set to two seconds. Each switch maintains local information about its self BID, root ID, and the path cost to the root.
When nearby switches receive a Bridge Protocol Data Unit (BPDU) frame containing root ID, it compares the root ID from the BPDU frame with the local root ID. If the root ID in the BPDU frame is lower than the local root ID of that switch, it updates the local root ID and the ID in its Bridge Protocol Data Unit (BPDU) messages.
These messages show the new root bridge on the network. The distance to the root bridge is also updated by increasing the path cost of the incoming interface, for example, if the Bridge Protocol Data Unit (BPDU) frame is received on an Ethernet port, the path cost would increment by 1100. If the root ID of the local switch is lower than the root ID received in the Bridge Protocol Data Unit (BPDU) frame, the Bridge Protocol Data Unit (BPDU) frame is discarded.
When root ID is updated to identify a new root bridge, all consequent Bridge Protocol Data Unit (BPDU) frames sent from that switch contain the new root ID including the path cost. So, all other nearby switches can see the lowest root ID identified at all times.
As the BPDU frames received and pass between other adjacent switches, the path cost is constantly increased to indicate the total path cost to the root bridge. Each switch chooses the best path in the spanning tree to using its path costs to reach its root bridge.