The Spanning Tree Algorithm

There is a rule controlling the interconnection of bridges and switches (as there is for Ethernet Hubs). The rule says simply, that a bridge / switch /hub LAN must form a tree, and not a ring. That is, there must be only one path between any two computers. If there is more than one parallel path, a loop would be formed, resulting in overload and potentially endless circulation of frames over the loop.

To prevent this happening, the IEEE (in IEEE 802.1D) has defined the Spanning Tree Algorithm (STA) which automatically detects loops and disables one of the parallel paths. A managed switch can enable the Spanning Tree Protocol (STP), which implements STA. A switch sends short frames - identified by Ethertype (actually Bridge protocol data units (BPDUs) sent periodically on all of the active interfaces of a switch when STP is enabled. IEEE (in IEEE 802.1D) has defined the Spanning Tree Algorithm (STA) which automatically detects loops and disables all but one parallel path.

The STA works by first electing a root switch (there can be only one root in any VLAN). This can be determined by receiving STP frames from other switches (the lowest ID is elected as the root). Once the root has been found, each switch ensures there is only one path to the root by disabling any interfaces on all but the shortest path to the root (these interfaces are put in blocking mode). Blocked interfaces are not used to forward packets, but continue to exchange STP frames (in case the topology changes or a link fails). This finally leaves a single active path between any two network nodes. Although this builds a loop-free logical topology for Ethernet networks, the STA often will cause traffic to be forwarded on a suboptimal path - it does not choose the shortest path between the source and destination (compare with IP routing). This is why LAN operators often try to prioritise one of the switches to result in the root being placed at the LAN router.

There is a rule controlling the interconnection of bridges and switches (as there is for Ethernet Hubs). The rule says simply, that a bridge / switch /hub LAN must form a tree, and not a ring. That is, there must be only one path between any two computers. If there is more than one parallel path, a loop would be formed, resulting in overload and potentially endless circulation of frames over the loop.

BPDU Frames

A managed switch that enable sthe Spanning Tree Protocol (STP) sends short frames - (Bridge protocol data units (BPDUs). These frames are sent periodically on all active interfaces of a switch when STP is enabled.

Each bridge sends out BPDUs that include the following information:

Each bridge looks at the received BPDUs from all ports

All bridges record for each port:

In total this needs STA to keeps about 50 B of data per port.

Root switch selection

IEEE (in IEEE 802.1D) has defined the Spanning Tree Algorithm (STA) which automatically detects loops and disables all but one of the parallel paths. Routers can also participate in spanning tree, and the method can be used with virtual LANs (VLANs) with one instance for each VLAN.

The STA works by first electing a root switch/router. This chooses one switch to be the root in each LAN (or VLAN). The root can be determined by receiving the STP frames from other switches. Each frame contains an ID and the lowest ID is elected as the root. The root election can be influenced bye setting the priority in the advertised STP messages of specific equipment.

Once the root has been found, a switch can calculate the cost of traversing a path is the sum of the costs of the segments on the path. The cost of traversing each path to the root is calculated as the sum of the costs of the segments on the path.

Each switch also monitors the STP frames to see if more than one interface is forwarding STP messages from the root. This indicates a parallel path. Each switch ensures there is only one path to the root by disabling the interfaces on all but the shortest path to the root (these interfaces are put in blocking mode). This finally leaves a single active forwarding path between any two network switches in the LAN. Blocked interfaces do not forward packets, but continue to exchange STP frames (in case the topology later changes or a link fails).

STP allows a network to include backup links providing fault tolerance if an active link fails. It can also be used to build fault tolerant networks, since if the chosen path becomes invalid (e.g. due to a cable / bridge / switch fault), when an alternate path exists, the alternate path is enabled automatically. Although the STP builds a loop-free logical topology, in contrast to IP routing, it does not choose the shortest path between the source and destination.

The path finally used depends upon which bridge “breaks” the loop. Frames from any connected device to the root bridge traverse a least cost path, i.e., a path from the device to the root that has minimum cost among all paths from the device to the root. This can result in awkward long paths around the network. This can cause traffic to be forwarded on a suboptimal path. An administrator can use the configured priority field to override this - in the STA configuration of a switch - for instance to ensure the local IP router is normally elected as the root.

Network Partition

If one or more links fail after the STA has built the tree - one set of switches may have no way to reach the other set of switches. The network is said to have partitioned. In this case, the information about the root will time-out. Each part of the network will then elect a new root and a pair of spanning trees will be formed rooted on a node in each part of the partitioned network. If the links later become usable and the two spanning trees are connected, the STA will discover the multiple root from the STP frames and will reconfigure around a single root, healing the previous partition.

Speed of Convergence

The core issue of STA is the time it takes to detect a root for the tree and disable the interfaces. The algorithm can take a considerable time to detect and react to faults in a complex topology. More rapid versions of the protocol therefore also exist. that can reconfigure the network in very short periods of time.

Virtual LANs

Each VLAN runs the STP independently.


See also:

Ethernet

Ethernet Hubs

Ethernet Bridges

Routers

A page shows examples of various types of networking equipment, including Bridges and Switches for Ethernet.

Manged Switches (priority and VLANs)


Gorry Fairhurst - email: G.Fairhurst(at)erg.abdn.ac.uk - Date: 1/22/2020 EG3567