Before configuring STP, the network topology should be carefully planned. Basic configuration requires that STP be enabled on all switches in the LAN and the same version of STP chosen on each. The administrator may determine which switch will be the root bridge and configure the switches appropriately. If the root bridge goes down, the protocol will automatically assign a new root bridge based on bridge ID. If all switches have the same bridge ID, such as the default ID, and the root bridge goes down, a tie situation arises and the protocol will assign one switch as the root bridge based on the switch's MAC addresses. Once the switches have been assigned a bridge ID and the protocol has chosen the root bridge switch, the best path to the root bridge is calculated based on port cost, path cost and port priority. Ultimately, STP calculates the path cost on the basis of the bandwidth of a link. Administrators can influence the protocol's choice of the preferred path by configuring the port cost; the lower the port cost, the more likely it is that the protocol will choose the connected link as root port for the preferred path. The selection of how other switches in the topology choose their root port, or the least cost path to the root bridge, can be influenced by the port priority. The highest priority will mean the path will ultimately be less preferred. If all ports of a switch have the same priority, the port with the lowest number is chosen to forward frames.
Root bridge and the bridge ID s. The smallest bridge ID is 3. Therefore, bridge 3 is the root bridge. The
root bridge of the spanning tree is the bridge with the smallest (lowest) bridge ID. Each bridge has a configurable priority number and a MAC address; the bridge ID is the
concatenation of the bridge priority and the MAC address. For example, the ID of a bridge with priority 32,768 and MAC is . The bridge priority default is 32,768 and can be configured only in multiples of 4096. When comparing two bridge IDs, the priority portions are compared first and the MAC addresses are compared only if the priorities are equal. The switch with the lowest priority of all the switches will be the root; if there is a tie, then the switch with the lowest priority and lowest MAC address will be the root. For example, if switches
A (MAC = ) and
B (MAC = ) both have a priority of 32,768 then switch
A will be selected as the root bridge. If the network administrators would like switch
B to become the root bridge, they must set its priority to be less than 32,768.
Path to the root bridge The sequence of events to determine the best received BPDU (which is the best path to the root) is: • Lowest root bridge ID (BID)Determines the root bridge. • Lowest cost to the root bridgeFavors the upstream switch with the least cost to root • Lowest sender bridge IDServes as a tiebreaker if multiple upstream switches have equal cost to root • Lowest sender port IDServes as a tiebreaker if a switch has multiple (non-
EtherChannel) links to a single upstream switch, where: • Bridge ID = priority (4 bits) + locally assigned system ID extension (12 bits) + ID [MAC address] (48 bits); the default bridge priority is 32,768, and • Port ID = priority (4 bits) + ID (Interface number) (12 bits); the default port priority is 128.
Tiebreakers ;Root ports :When multiple paths from a bridge are least-cost paths, the chosen path uses the neighbor bridge with the lower bridge ID. The root port is thus the one connecting to the bridge with the lowest bridge ID. For example, in the figures, if switch 4 were connected to
network segment d instead of segment f, there would be two paths of length 2 to the root, one path going through bridge 24 and the other through bridge 92. Because there are two least-cost paths, the lower bridge ID (24) would be used as the tiebreaker in choosing which path to use. ;Paths :When more than one bridge on a segment leads to a least-cost path to the root, the bridge with the lower bridge ID is used to forward messages to the root. The port attaching that bridge to the network segment is the
designated port for the segment. In the figures, there are two least-cost paths from network segment d to the root, one going through bridge 24 and the other through bridge 92. The lower bridge ID is 24, so the tiebreaker dictates that the designated port is the port through which network segment d is connected to bridge 24. If bridge IDs were equal, then the bridge with the lowest MAC address would have the designated port. In either case, the loser sets the port as being blocked. ;Designated ports :When the root bridge has more than one port on a single network segment, the bridge ID is effectively tied, as are all root path costs (all equal zero). The port on that network segment with the lowest port ID becomes the designated port. It is put into forwarding mode while all other ports on the root bridge on that same network segment become non-designated ports and are put into blocking mode. Not all bridge manufacturers follow this rule, instead making all root bridge ports designated ports, and putting them all in forwarding mode. ;Final tiebreaker :In some cases, there may still be a tie, as when the root bridge has multiple active ports on the same network segment (see above) with equally low root path costs and bridge IDs, or, in other cases, multiple bridges are connected by multiple cables and multiple ports. In each case, a single bridge may have multiple candidates for its root port. In these cases, candidates for the root port have already received BPDUs offering equally-low (i.e. the "best") root path costs and equally-low (i.e. the "best") bridge IDs, and the final tiebreaker goes to the port that received the lowest (i.e. the "best") port priority ID, or port ID. ==Bridge protocol data units==