top of page

How-to: Configure spanning tree protocol (STP)

STP was developed to allow redundancy in the L2 network while maintaining a loop free network. Today we are going to discover how STP is actually doing this function.

​

Step1: Electing the root bridge

​

What is the root bridge?

​

The root bridge is the master bridge of the spanning tree which all paths calculations are based upon. Each switch must have an active path to the root bridge. All bridges in the same domain must agree on the same root.The root bridge has all its ports in the forwarding state. All traffic passing from one segment to another in the network must pass the root bridge.

​

How is the root bridge elected?

​

The Bridge ID is used to determine the root bridge. The BID is a combination of the priority value (default:32768) and the MAC address of the switch. The rule is, the lower the BID the better. The lowest bridge ID becomes the root bridge.

​

If two or more switches happen to have the same priority (i.e. default value) the MAC address is used as a tie breaker; The bridge with the lowest MAC address becomes the root of the tree.

​

How to manipulate the root bridge election?

​

By default Cisco switches run a separate STP instance for every VLAN configured on the switch; this mode is called PVST.

​

In the digram below I am going to configure Switch1 as a root switch for the default VLAN (1) using two methods.

Root bridge may be elected using one of the following methods:

​

  • Election by chance: you can leave STP to do its work without even knowing about it. By default each bridge comes with a default priority value of 32768. In such case the bridge with the lowest MAC address will become the root bridge. This method is not recommended except in very simple network topologies.

  • Setting the Bridge priority using the command spanning-tree vlan [list] priority [value]. The list defines the instances that the new priority value applies to.

Switch1(config)#do debug spanning-tree root                             Switch1(config)#spanning-tree vlan 1 priority 4096                                   Switch1(config)# 01:17:58: STP: VLAN0001 we are the spanning tree root

  • Using the command spanning-tree vlan [list] root [primary | secondary]. Using this command will automatically lower the priority of the switch to a very significant value in order to make sure that the switch is elected as a root switch.

Switch1(config)#spanning-tree vlan 1 root primary

Switch1(config)#

 

01:20:59: STP: VLAN0001 we are the spanning tree root !-- Priority is lowered automatically as shown in the output below

 

Switch1(config)#do show spanning-tree vlan 1

 

VLAN0001

          Spanning tree enabled protocol ieee

          Root ID Priority 24577

          Address 001b.90b4.6900

          This bridge is the root

          Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

 

  Bridge ID Priority 24577 (priority 24576sys-id-ext 1)

  Address 001b.90b4.6900

  Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

  Aging Time 15

PVST Explained

Cisco switches run different types of STP protocol, depending on whether the connected port is access, ISL trunk or 802.1q trunk. Natively, Cisco switch runs a separate STP instance for each configured and active VLAN (this is called Per-VLAN Spanning Tree or PVST) and standard IEEE compliant switches run just one instance of STP shared by all VLANs. Due to that reason, a group of switches running IEEE compatible STP protocol is called MST (Mono Spanning Tree) region, not to be confused with MSTP (multiple spanning tree).

​

Access Ports. Cisco switches run the IEEE version of STP protocol on the access ports. The IEEE STP BPDUs are sent to IEEE reserved multicast MAC address “0180.C200.0000” using IEEE 802.2 LLC SAP encapsulation with both SSAP and DSAP fields equal to “0×42”. (By the way, for the purpose of Layer2 filtering, IEEE BPDUs could be matched using a MAC ACL with LSAP value of ”0×4242”). Note that you can plug any standard IEEE compliant switch into a Cisco switch access port and they will inter-operate perfectly, joining the respective access VLAN’s STP instance with the IEEE STP instance (MST).

​

ISL Trunks. Cisco switches run PVST (Per-VLAN Spanning Tree) on ISL trunk links. The same IEEE STP BPDUs are sent for each VLAN, encapsulated with additional ISL header, which also carries the VLAN number. The magic part is that ISL header has special flag to distinguish frames carrying STP BPDUs and this is how PVST can re-use the regular IEEE BPDUs to simulate multiple spanning trees. Since PVST BPDUs have the same format as IEEE BPDUs (that is IEEE 802.2 LLC SAP) they can be matched using the same SSAP/DSAP values of “0×42” for the purpose of Layer 2 filtering.The group of Cisco switches connected using ISL trunks only is called PVST region.

​

802.1q Trunks. Cisco switches run PVST+ (Per VLAN Spanning Tree Plus) on 802.1q trunks. This is where things are getting a bit complicated. The goal of PVST+ is to interoperate with standard IEEE STP (MST) and allow transparent tunneling of PVST BPDUs across MST region to connect to other Cisco switches across the IEEE region. For further consideration, we’ll call a group of Cisco switches connected using 802.1q trunks as PVST+ region. Note that PVST+ region may connect to a PVST region using an ISL trunk and connect to MST region using a 802.1q trunk. The STP instances in PVST and PVST+ regions maps directly to each other, so no special interoperability solution is required. However, on IEEE side only one STP instance exists, contrary to multiple STP instances of PVST+ region. The first question is: if we want to interoperate with IEEE single tree, which PVST VLAN’s STP instance should be joined with MST? Cisco has chosen VLAN 1 for this purpose. Joined together, instances of Cisco VLAN 1 STP and MST are called “Common Spanning Tree” or CST (naturally, CST spans PVST, PVST+ and MST regions). As for the detailed PVST+ operations on 802.1q port, consider two following cases:

​

Case 1: Cisco switch connects to an IEEE switch using a 802.1q trunk with default native VLAN (VLAN 1)

IEEE side sends IEEE STP BPDUs to the IEEE multicast MAC address. These BPDUs are consumed and processed by VLAN 1 STP instance on Cisco switch (PVST+ region). The Cisco switch simply recognizes untagged IEEE BPDUs as belonging to VLAN 1 STP instance.

​

The PVST+ side (Cisco switch) sends IEEE STP BPDUs corresponding to local VLAN 1 STP to IEEE MAC address as untagged frames across the link. At the same time, special new SSTP (shared spanning tree, synonym to PVST+) BPDUs are being sent to SSTP multicast MAC address “0100.0ccc.cccd” also untagged. These SSTP BPDUs are encapsulated using IEEE 802.2 LLC SNAP header (SSAP=DSAP=”0xAA” and SNAP PID=”0x010B”). These BPDUs carry the same information as the parallel IEEE STP BPDUs for VLAN 1, but have additional fields, notably a special TLV with the source VLAN number. Note that IEEE switches do not interpret the SSTP BPDUs, but simply flood them through the respective VLAN topology. This facilitates BPDU tunneling in case there are other Cisco switches connected to IEEE cloud.

​

As for non-native VLANs (VLANs 2-4095) Cisco switch sends only SSTP BPDUs, tagged with respective VLAN number and destined to the SSTP MAC address. (Please remember that all SSTP BPDUs carry a VLAN number they belong to). The respective VLAN STP instances are “transparently expanded” across the MST region, considering it as a “virtual hub”. (Note that this may have some traffic engineering implications, since to non-CST VLANs the cost of traversing MSTP region equals to the cost of the link used to connect to the first MSTP switch).

​

Now the question is, why would Cisco switch send the same VLAN1 BPDU twice – destined to IEEE and SSTP multicast MAC addresses? Isn’t it supposed for the Cisco switch to join its VLAN 1 STP instance with the MST? The reason for sending additional SSTP BPDUs across VLAN 1 is purely informational, to perform consistency checking. The idea is to inform all other potential Cisco switches attached to MST cloud about our native VLAN. The receiving switch will only use IEEE BPDUs for VLAN 1 (CST) computations and will ignore SSTP BPDUs sent on VLAN 1.

​

For the purpose of layer 2 filtering, remember that you can match SSTP BPDUs using an ethertype value “0x010B”.This works with multilayer switches even though SSTP BPDUs are SNAP encapsulated, and the actual field is not “ethertype” but rather a SNAP Protocol ID.

​

Case 2: Cisco switch connects to IEEE switch using 802.1q trunk with non-default native VLAN (e.g VLAN 100).

IEEE switch sends IEEE STP BPDUs to IEEE multicast MAC address and those BPDUs are processed by VLAN 1 (CST) STP instance in the Cisco switch.

​

PVST+ side (Cisco switch) sends untagged IEEE STP BPDUs corresponding to VLAN 1 (CST) STP to IEEE MAC address across the link. This is done for the purpose of joining the local VLAN 1 instance and the IEEE instance into CST. At the same time, VLAN 1 BPDUs are replicated to SSTP multicast address, tagged with VLAN 1 number (to inform other Cisco switches that VLAN 1 is non-native on our switch). Finally, BPDUs of the native VLAN instance (VLAN 100 in our case) are sent untagged using SSTP encapsulation and destination address. Of course, native VLAN100 BPDUs, (even though they are untagged) carry VLAN number inside a special TLV SSTP header.

​

As in Case 1 for the remaining non-native VLANs (VLANs 2-4095) Cisco switch sends SSTP BPDU only, tagged with respective VLAN tag and destined to the SSTP MAC address. The other Cisco switches connected to the MSTP cloud receive the SSTP BPDUs and process the using the respective VLAN STP instances.

​

Consider the diagram below. SW1 and SW2 are Cisco switches, running STP instances for VLANs 1,2 and 3. Router R3 is converted into bridge (CRB mode and the same bridge-group on E0/0 and E0/1 interfaces, using IEEE STP protocol) to simulate an IEEE compatible switch. VLAN 1 STP instances of SW1 and SW2 are joined with STP instance running in R3. VLANs 2 and 3 consider path across R3 as another segment linking SW1 and SW2 and their SSTP information is passed transparently across R3.

Rack1SW2#show spanning-tree vlan 1

 

VLAN1 is executing the ieee compatible Spanning Tree protocol Bridge Identifier has priority 32768, address cc07.00c1.0000 Configured hello time 2, max age 20, forward delay 15 Current root has priority 32768, address cc02.00c0.0000 Root port is 44 (FastEthernet1/3), cost of root path is 19 Topology change flag set, detected flag not set Number of topology changes 12 last change occurred 00:00:39 ago Times: hold 1, topology change 35, notification 2 hello 2, max age 20, forward delay 15 Timers: hello 0, topology change 0, notification 0, aging 300

 

Port 44 (FastEthernet1/3) of VLAN1 is forwarding Port path cost 19, Port priority 128, Port Identifier 128.44. Designated root has priority 32768, address cc02.00c0.0000 Designated bridge has priority 32768, address cc02.00c0.0000 Designated port id is 128.5, designated path cost 0 Timers: message age 2, forward delay 0, hold 0 Number of transitions to forwarding state: 2 BPDU: sent 7650, received 2445

 

Port 56 (FastEthernet1/15) of VLAN1 is blocking Port path cost 19, Port priority 128, Port Identifier 128.56. Designated root has priority 32768, address cc02.00c0.0000 Designated bridge has priority 32768, address cc06.00c0.0000 Designated port id is 128.56, designated path cost 19 Timers: message age 3, forward delay 0, hold 0 Number of transitions to forwarding state: 2 BPDU: sent 7, received 3827

 

Rack1SW2#show spanning-tree vlan 2 VLAN2 is executing the ieee compatible Spanning Tree protocol Bridge Identifier has priority 8192, address cc07.00c1.0006 Configured hello time 2, max age 20, forward delay 15 Current root has priority 8192, address cc06.00c0.0006 Root port is 44 (FastEthernet1/3), cost of root path is 19 Topology change flag set, detected flag not set Number of topology changes 7 last change occurred 00:00:14 ago from FastEthernet1/15 Times: hold 1, topology change 35, notification 2 hello 2, max age 20, forward delay 15 Timers: hello 0, topology change 0, notification 0, aging 300

 

Port 44 (FastEthernet1/3) of VLAN2 is forwarding Port path cost 19, Port priority 128, Port Identifier 128.44. Designated root has priority 8192, address cc06.00c0.0006 Designated bridge has priority 8192, address cc06.00c0.0006 Designated port id is 128.44, designated path cost 0 Timers: message age 2, forward delay 0, hold 0 Number of transitions to forwarding state: 2 BPDU: sent 5889, received 372

 

Port 56 (FastEthernet1/15) of VLAN2 is blocking Port path cost 19, Port priority 128, Port Identifier 128.56. Designated root has priority 8192, address cc06.00c0.0006 Designated bridge has priority 8192, address cc06.00c0.0006 Designated port id is 128.56, designated path cost 0 Timers: message age 2, forward delay 0, hold 0 Number of transitions to forwarding state: 1 BPDU: sent 2, received 3821

 

Rack1SW2#show spanning-tree vlan 3 VLAN3 is executing the ieee compatible Spanning Tree protocol Bridge Identifier has priority 32768, address cc07.00c1.0001 Configured hello time 2, max age 20, forward delay 15 Current root has priority 8192, address cc06.00c0.0007 Root port is 44 (FastEthernet1/3), cost of root path is 19 Topology change flag set, detected flag not set Number of topology changes 4 last change occurred 00:00:16 ago from FastEthernet1/15 Times: hold 1, topology change 35, notification 2 hello 2, max age 20, forward delay 15 Timers: hello 0, topology change 0, notification 0, aging 300

 

Port 44 (FastEthernet1/3) of VLAN3 is forwarding Port path cost 19, Port priority 128, Port Identifier 128.44. Designated root has priority 8192, address cc06.00c0.0007 Designated bridge has priority 8192, address cc06.00c0.0007 Designated port id is 128.44, designated path cost 0 Timers: message age 1, forward delay 0, hold 0 Number of transitions to forwarding state: 2 BPDU: sent 3689, received 332

 

Port 56 (FastEthernet1/15) of VLAN3 is blocking Port path cost 19, Port priority 128, Port Identifier 128.56. Designated root has priority 8192, address cc06.00c0.0007 Designated bridge has priority 8192, address cc06.00c0.0007 Designated port id is 128.56, designated path cost 0 Timers: message age 1, forward delay 0, hold 0 Number of transitions to forwarding state: 2 BPDU: sent 3, received 3832

Case 1: Change the native VLAN on SW1 connection to R3:

​

SW1: interface FastEthernet 1/3 switchport trunk native vlan 2

 

Rack1SW2# %SPANTREE-2-RECV_PVID_ERR: Received BPDU with inconsistent peer vlan id 2 on FastEthernet1/3 VLAN1.

​

%SPANTREE-2-BLOCK_PVID_PEER: Blocking FastEthernet1/3 on VLAN2. Inconsistent peer vlan.PVST+: restarted the forward delay timer for FastEthernet1/3

 

%SPANTREE-2-BLOCK_PVID_LOCAL: Blocking FastEthernet1/3 on VLAN1. Inconsistent local vlan.PVST+: restarted the forward delay timer for FastEthernet1/3

Lets Connect The World

Subscribe to CCIE topics

Mohammed Anwarul Islam

bottom of page