Sub topic 2
BPDUs: how switches talk about the topology
Spanning tree only works if every switch in the Layer 2 network agrees on one loop-free tree. Switches agree by exchanging a small control frame called a Bridge Protocol Data Unit (BPDU). This chapter covers what a BPDU carries, how it is sent and forwarded, which types exist, and how a switch decides whether a received BPDU is better than what it already knows.
This chapter assumes you know how switches learn MAC addresses, how unknown-unicast and broadcast flooding work, and what a VLAN and a trunk are. It also assumes you can read a switch command line. It does not cover the root election in full. The next chapters build on the fields introduced here.
What a BPDU is
A BPDU is a Layer 2 frame that switches use to share spanning tree information with their neighbors. End hosts do not take part in this exchange. A BPDU is never routed. It travels only across one link, from a switch port to the port at the other end.
Three facts about BPDUs shape everything else in spanning tree:
- BPDUs are sent to a reserved multicast MAC address,
01:80:C2:00:00:00. Standards-compliant switches do not forward frames sent to this address like normal traffic. They hand the frame to their own spanning tree process instead. - BPDUs are not encapsulated in IP. They are carried in IEEE 802.3 frames with an LLC header (destination and source service access point
0x42). - A BPDU is not flooded across the network as-is. Each switch receives it, processes it, and generates its own BPDU on the ports where it is entitled to send one.
The last point matters most. Information flows outward from the root bridge one hop at a time, and each switch rewrites the message as it passes it on.
BPDU types
Classic 802.1D defines two BPDU types. Rapid STP (802.1w) adds a third version of the format.
| Type | Purpose | Sent by |
|---|---|---|
| Configuration BPDU | Carries the root and path information used to build the tree | The root bridge, then relayed by designated ports on every other switch |
| Topology Change Notification (TCN) BPDU | Tells upstream switches that the topology changed | A non-root switch, out its root port |
| RSTP BPDU (version 2) | Same fields as a configuration BPDU, plus port role and state flags | All RSTP switches, on all designated ports and, when needed, other ports |
A TCN BPDU is very short. It has no tree information, only a type value. Its job is to prompt the root to announce that MAC tables should age out quickly. Topology changes and MAC table flushing get their own chapter.
What a configuration BPDU carries
The fields in a configuration BPDU are the inputs to every spanning tree decision. The table lists the ones you need to know.
| Field | Meaning |
|---|---|
| Root Bridge ID | The bridge ID the sender currently believes is the root |
| Root Path Cost | The total cost from the sender to that root |
| Sender Bridge ID | The bridge ID of the switch that built this BPDU |
| Sender Port ID | The priority and number of the port the BPDU left from |
| Message Age | How many hops the information has traveled from the root |
| Max Age | How long a switch keeps this information without a refresh |
| Hello Time | How often the root sends BPDUs |
| Forward Delay | The wait used by classic port state transitions |
| Flags | Topology change bits (and, in RSTP, role, proposal, agreement and learning/forwarding bits) |
Two of these fields do the work of an election. Root Bridge ID names the best root candidate. Root Path Cost, sender bridge ID and sender port ID are used to compare competing paths to that root. How to read the bridge ID itself is covered in the next chapter, and how costs are assigned follows after that.
The timer fields (Hello, Max Age and Forward Delay) are set by the root. Other switches copy them from the root's BPDUs rather than using their own configured values. This keeps the whole network on one set of timers.
How BPDUs propagate
At startup, every switch assumes it is the root. It sends BPDUs on all ports that list itself as the Root Bridge ID, with a root path cost of 0. When a switch hears a BPDU that names a better root, it stops claiming to be the root. From then on it only relays information on behalf of the better root.
The diagram shows the steady state in a three-switch chain after the election has finished.
The steps for a non-root switch in classic 802.1D are:
- Receive a configuration BPDU on the root port.
- Add the cost of the receiving port to the Root Path Cost in the BPDU.
- Build a new BPDU with that cost and its own sender bridge ID and port ID.
- Send it out each designated port, once per hello interval, driven by the receipt of the root's BPDU.
In classic STP, a non-root switch does not originate BPDUs on its own schedule. It sends them only after hearing from the root. If the root's BPDUs stop arriving, the switch eventually ages out the stored information. RSTP changes this: every switch sends its own BPDU every hello time, which is one reason RSTP detects failures faster.
Comparing BPDUs: which one is better
When a port receives a BPDU, the switch compares it to the best information it already has for that port. A lower value wins at every step. The comparison goes in this order:
- Lowest Root Bridge ID.
- Lowest Root Path Cost.
- Lowest Sender Bridge ID.
- Lowest Sender Port ID.
The first step that differs decides the result. This single ordered comparison is the basis for root bridge election, root port selection and designated port selection. You will meet the same four-step order again in later chapters, so it helps to memorize it now.
A BPDU that is better than what a port was sending or storing replaces the old information. A BPDU that is worse than what the switch would send on that port is answered by the switch sending its own, better BPDU back. This is how a port learns that it should be the designated port for its segment.
Timers and BPDU loss
The stored information from a BPDU has a lifetime. If a switch stops receiving BPDUs on a port, it counts up until the information is as old as Max Age, which is 20 seconds by default. At that point it discards the information and reruns the calculation. That wait is a large part of why classic STP is slow to react to indirect failures.
You can see BPDU timing on a Linux bridge. This example creates a bridge with STP on, sets a low priority so it is preferred as root, and then lists the settings and port states.
# Linux bridge with STP enabled
sudo ip link add name br0 type bridge stp_state 1
sudo ip link set dev eth0 master br0
sudo ip link set dev eth1 master br0
sudo ip link set dev br0 type bridge priority 4096
sudo ip link set dev br0 up
# Inspect the bridge and its ports
ip -d link show br0
bridge link showThe ip -d link show br0 output includes the bridge's priority, hello time, max age and forward delay. The bridge link show output lists each member port and its STP state. On a Cisco switch, show spanning-tree vlan 10 shows the root bridge ID, the local bridge ID, and the timers copied from the root.
Common errors and gotchas
- Treating BPDUs as ordinary multicast. Some devices, such as certain unmanaged switches, media converters and virtual switches, either forward BPDUs on every port or drop them. Forwarding hides a switch from the spanning tree. Dropping them removes the loop protection between two devices and can create a loop.
- Expecting BPDUs from hosts. A BPDU arriving on a port that should face an end host usually means a switch or a bridged device was plugged in. Later chapters show how BPDU Guard reacts to this.
- Assuming BPDUs are sent only on blocked links. Designated ports send BPDUs. A blocking port receives them but does not send them. That silence is normal, not a fault.
- Mismatched timers. Configuring different hello, forward delay or max age values on non-root switches has no effect. Only the root's values count.
- Per-VLAN differences. Under PVST+, a separate BPDU stream exists for each VLAN. The BPDU for VLAN 1 uses the standard address, and the others use a Cisco-specific multicast address with a VLAN tag on trunks.
Key points
- A BPDU is a Layer 2 control frame sent to
01:80:C2:00:00:00and consumed by the next switch, not flooded. - A configuration BPDU carries the root bridge ID, root path cost, sender bridge ID and sender port ID, plus timers.
- Every switch starts by claiming to be the root and gives up the claim when it hears a better BPDU.
- BPDUs are compared by root ID, root path cost, sender bridge ID and sender port ID. Lower is better at each step.
- In classic STP, only the root originates BPDUs and others relay them. In RSTP, every switch sends its own.
- Timers are taken from the root.
Exercise
Switch SW2 has a stored BPDU on port Gi0/1 with root ID 32778:0011.1111.1111, root path cost 19, sender bridge ID 32778:0022.2222.2222. A new BPDU arrives on the same port with root ID 32778:0011.1111.1111, root path cost 19, sender bridge ID 32778:0011.1111.1111. Is the new BPDU better, and which step of the comparison decides it?
Show answer
Yes, the new BPDU is better. The root bridge IDs are equal, and the root path costs are equal (19). The comparison reaches the third step, sender bridge ID. The new sender, 32778:0011.1111.1111, is lower than the stored sender, 32778:0022.2222.2222, so the new BPDU wins and replaces the stored information.
Exercise
A non-root switch in a classic 802.1D network is configured with a hello time of 1 second, while the root uses the default of 2 seconds. Which hello time does the network use, and why?
Show answer
The network uses 2 seconds. Non-root switches copy the Hello Time, Max Age and Forward Delay values from the root's BPDUs, so a locally configured value on a non-root switch has no effect unless that switch becomes the root.