Spanning Tree Protocol
BPDU
Configuration BPDU
BPDU Field | Length in Octets |
---|---|
Protocol Identifier | 2 |
Protocol Version | 1 |
BPDU Type | 1 |
Flags | 1 |
Root Bridge ID | 8 |
Root Path Cost | 4 |
Sending Bridge ID | 8 |
Sending Port ID | 2 |
Message Age | 2 |
Max Age | 2 |
Hello Time | 2 |
Forward Delay | 2 |
Topology Change Notification BPDU
BPDU Field | Length in Octets |
---|---|
Protocol Identifier | 2 |
Protocol Version | 1 |
BPDU Type | 1 |
Protocol Version
- 0 for legacy STP
- 2 for RSTP
Flags
BPDU Flag Field | Length in Bits |
---|---|
Topology Change Acknowledgment | 1 |
Agreement | 1 |
Forwarding | 1 |
Learning | 1 |
Port Role | 2 |
Proposal | 1 |
Topology Change | 1 |
Message Age
Serves as a TTL to prevent a BPDU being forwarded in a loop which can cause all the ports in a forwarding state and not expired.
BPDU is assumed to be expired when MaxAge - MessageAge less than 0. MessageAge increases before being transmited to other bridge.
Port Cost
Port Speed | Pre-802.1D-1998 | 802.1D-1998(PVST, RSTP) | 802.1D-2004(MSPT) |
---|---|---|---|
10 Mbps | 100 | 100 | 2000000 |
100 Mbps | 10 | 19 | 200000 |
1 Gbps | 1 | 4 | 20000 |
10 Gbps | 1 | 2 | 2000 |
The following command can be used to change which cost standard to used.
(config)# spanning-tree pathcost method [short | long]
Example
IOU2(config)#do sh spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.0200
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.0200
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 Shr
Et0/1 Desg FWD 100 128.2 Shr
Et0/2 Desg FWD 100 128.3 Shr
Et0/3 Desg FWD 100 128.4 Shr
Et1/0 Desg FWD 100 128.5 Shr
Et1/1 Desg FWD 100 128.6 Shr
Et1/2 Desg FWD 100 128.7 Shr
Et1/3 Desg FWD 100 128.8 Shr
Et2/0 Desg FWD 100 128.9 Shr
Et2/1 Desg FWD 100 128.10 Shr
Et2/2 Desg FWD 100 128.11 Shr
Et2/3 Desg FWD 100 128.12 Shr
Et3/0 Desg FWD 100 128.13 Shr
Et3/1 Desg FWD 100 128.14 Shr
Et3/2 Desg FWD 100 128.15 Shr
Et3/3 Desg FWD 100 128.16 Shr
IOU2(config)#spanning-tree pathcost method ?
long Use 32 bit based values for default port path costs
short Use 16 bit based values for default port path costs
IOU2(config)#spanning-tree pathcost method long
IOU2(config)#do sh spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.0200
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.0200
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 2000000 128.1 Shr
Et0/1 Desg FWD 2000000 128.2 Shr
Et0/2 Desg FWD 2000000 128.3 Shr
Et0/3 Desg FWD 2000000 128.4 Shr
Et1/0 Desg FWD 2000000 128.5 Shr
Et1/1 Desg FWD 2000000 128.6 Shr
Et1/2 Desg FWD 2000000 128.7 Shr
Et1/3 Desg FWD 2000000 128.8 Shr
Et2/0 Desg FWD 2000000 128.9 Shr
Et2/1 Desg FWD 2000000 128.10 Shr
Et2/2 Desg FWD 2000000 128.11 Shr
Et2/3 Desg FWD 2000000 128.12 Shr
Et3/0 Desg FWD 2000000 128.13 Shr
Et3/1 Desg FWD 2000000 128.14 Shr
Et3/2 Desg FWD 2000000 128.15 Shr
Et3/3 Desg FWD 2000000 128.16 Shr
Topology Change Event
- A Topology Change Notification BPDU is received by a Designated Port of a switch
- A port moves to the Forwarding state and the switch has at least one Designated Port (meaning that it is not a standalone switch with just a Root Port connected to an upstream switch and no other connected ports)
- A port moves from Learning or Forwarding to Blocking
- A switch becomes the root switch
Advanced Feature
Portfast
When an interface receives BPDU, it disables portfast.
IOU1(config-if)#spanning-tree portfast [trunk]
UplinkFast
Uplinkfast assumes the switch is not the root bridge, so it increases its bridge-id by increasing its priority, and all ports have their STP cost increased by 3000.
When uplinkfast changes a port to forwarding, it floods dummy packets with the MAC address in its CAM table to let the upstream devices know where to forward the upcoming frames.
Switch(config)# spanning-tree uplinkfast
Switch# sh spanning-tree uplinkfast
BackboneFast
Switch(config)# spanning-tree backbonefast
BPDU Filter
Switch(config)# spanning-tree portfast bpdufilter default
Enables the BPDU filter on the portfast interfaces. This prevents switch from sending BPDUs but receiving BPDU is allowed. A few BPDUs will be sent as a safety mechanism as well.
Switch(config-if)# spanning-tree bpdufilter enable
BPDU Guard
(config)# spanning-tree bpduguard enable
Loop Guard
(config)# spanning-tree loopguard default
(config-if)# spanning-tree guard loop
UDLD
(config)# udld enable
This will only activate UDLD for fiber links.
STP EtherChannel Misconfig Guard
This mechanism makes an assumption that if multiple ports are correctly bundled into a Port-channel at the neighbor side, all BPDUs received over links in this Port-channel must have the same source MAC address in their Ethernet header, as the Port-channel interface inherits the MAC address of one of its physical member ports. The EtherChannel Misconfig Guard is active by default and can be deactivated using the no spanning-tree etherchannel guard misconfig global configuration command.