Spanning Tree Protocol
The Spanning Tree is achieved through the exchange of BPDU frames between switches. BPDUs are Bridge Protocol Data Units using the well known STP multicast address to reach all listening switches. Basically two types of BPDU are used to achieve Spanning Tree: the Configuration BPDU and the Topology Change Notification or TCN BPDU. BPDUs are sent out all switch ports every two seconds so that current topology information is exchanged and loops are quickly identified. For this reason it is essential that Net2 devices including server and client workstations are attached to ports configured with portfast (Cisco), stpFastStart (3Com) or the OEM’s equivalent. Portfast speeds up STP convergence by keeping the ports attached to end nodes in forwarding mode (i.e. transmitting) and prevents them from sending TCN BPDUs and participating in STP.
The different stages of Spanning Tree Convergence are enumerated below with a brief description.
Electing a root Bridge
To build Spanning Tree a root must exist to build the tree from. This is called the Root Bridge and is elected automatically based on a combination of some of the Bridge’s default parameters. Since this is somewhat arbitrary it is often more efficient to determine the Root Bridge by manually configuring the parameters used in the election process. The Root Bridge should be one of the fastest switches, as close to the centre of the network as possible and situated where most of the traffic will flow. A Server farm access switch for instance would make a good choice, or a core switch.
Electing root ports.
Once the Root Bridge has been elected, each non-root switch must determine where it is in relation to the Root Bridge. It does this by electing only one root port. STP uses the concept of path cost to determine several thing in the building of the Spanning Tree. Each switch link has a path cost which is a function of the bandwidth. The original IEEE 802.1d standard defined path cost as 1000Mbps divided by the link bandwidth in Mbps. This would give a 100Mbps link a path cost of 10. Note that with the advent of Gigabit links a new non-linear standard is in operation where the 100Mbps has a path cost of 19. Different switches may be operating different standards but this is usually transparent to the operation of Spanning Tree. The important thing is to elect a suitable Root Bridge.
In the process to elect the root port the cumulative Root Path Cost (sum of the path cost over every link) to the Root Bridge from every port is calculated and stored in memory. The port with the lowest Root Path Cost to the Root Bridge is elected the Root Port
Electing designated ports
In the final computations STP identifies one Designated Port on each network segment (LAN or subnet) as the only link to forward traffic to and from that segment. This will be the port with the lowest Root Path Cost to the Root Bridge. The other links will be left in blocking mode.
STP States
To participate in STP, each port of a switch can progress through several states. The STP port states are as follows:
- Disabled: Ports administratively shut down or faulty. They cannot participate in STP in this state.
- Blocking: After a port initialises it enters Blocking state. It can participate in STP but that is all, it cannot transmit or receive data.
- Listening: The port moves from Blocking to Listening if it is elected as a Root Port or Designated Port. It can still not transmit or receive data.
- Learning: After a specified period of time in the Listening state the port moves to Learning and starts learning MAC addresses and populating the MAC address table.
- Forwarding: After another pre-specified period of time the port moves into Forwarding state. The port can now transmit or receive data, update the MAC address table and send and receive STP BPDUs.
In the VLAN configuration example, if one of the Catalyst 4500 series access switches is connected to a server farm, for instance, it would make a good Root Bridge selection. Certain parameters (discussed below) can be tuned to ensure it wins the Root Bridge election in the convergence of STP. In this case, unless other advanced configuration features exist, one of the two uplinks from the access switches will be blocked and one of the backbone trunks between the core switches will also be blocked.
Spanning Tree design
Advanced Features
Both Cisco and 3Com have proprietary STPs that offer per-VLAN Spanning Tree (PVST). This allows the STP on each VLAN to be configured independently, offering better performance and tuning. Multiple Spanning Trees also make load balancing possible over redundant links when the links are assigned to different VLANs As discussed above the selection of the Root Bridge is key to efficient network operation in Spanning Tree. Cisco allows you to force the root bridge placement by using the following commands:
Switch (enable)> set spantree priority bridge-priority (vlan)
Catalyst switches have a macro that unequivocally sets the Root Bridge:
Switch (enable)> set spantree root [secondary] [vlan-list] [dia diameter] [hello hello-time]
Also, uplinks from access switches and backbone links between the core can be tuned to recover faster than STP would normally allow Spanning Tree can be further tuned and customised by manipulating timers, path costs and port ids. This is beyond the scope of this document and details can generally be found on the switch manufacturer’s websites