Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for Ethernet networks. Nowadays it is a popular solution to implement redundant networks in critical systems for Energy, Aerospace or Factory Automation. RSTP provides faster convergence than 802.1D STP when topology changes occur. It can also be combined with HSR–PRP for reliable Ethernet communications.
Loops between switches
Sometimes, when interconnecting switches, loops occur, meaning that there is more than one possible path between two networks. These loops may be made by mistake or because redundant paths are desired for reliability. If a loop occurs in a switch network, the network is out of service as soon as the first broadcast frame or unknown destination is sent. This is due to two characteristics of transparent switches:
- Proceed by flooding when the destination address is not in its address table.
- When forwarding a frame, the copy is indistinguishable from the original. There is no field (e.g. a counter of jumps) to differentiate between successive copies.
What is the solution?
There are two possible strategies:
- The creation of networks with loops is strictly forbidden.
- Enable some mechanism that allows the switches to detect the presence of loops in the topology, and thus disable the necessary interfaces so that there are no loops.
This is where Spanning Tree protocol comes into play. A Spanning Tree is a graph in which there is one and only one possible path between any pair of nodes (a tree without loops).The goal of the Spanning Tree protocol is to logically disable interfaces to always achieve a Spanning Tree.
Therefore, in order to know the topology of the network, and thus disable interfaces, Spanning Tree messages are sent, which are called BPDUs (Bridge Protocol Data Units). BPDUs use a reserved multicast address, 01-80-C2-00-00-00-00, to ensure that non-Spanning Tree switches propagate them transparently.
Spanning Tree operation
This is what the Spanning Tree protocol flow would look like:
- The switches regularly exchange BPDUs with information about the network topology.
- Each switch has an identifier (sw-ID) that it creates from its MAC address.
- In addition, each port has an identifier (port-ID) and a cost associated with it.
- The switches choose the one with the lowest sw-ID as the root of the tree. They all choose the same one.
- Each switch sends BPDUs through its interfaces indicating its sw-ID, the sw-ID of the root switch and the cost of reaching it. The BPDUs are propagated throughout the network, and each switch when forwarding a message adds the cost of the interface through which it sends it.
- With the BPDUs received, each switch calculates through which port it can reach the root at minimum cost. That is its root port. In case of a tie, it chooses the lowest port-ID.
- Each LAN has a designated port, which is the port through which that LAN accesses the root switch at minimum cost.
- Ports that are neither root nor designated are blocked ports. These ports are unnecessary for communication and if allowed to operate, they cause loops.
Traditional Spanning Tree (IEEE 802.1D) has convergence problems as it can take from 30 seconds to a few minutes for topology changes. This is excessive in some cases.
- In 1998 the Rapid Spanning Tree Protocol (RSTP, IEEE 802.1w) was standardised, a variant of the original protocol that reduces the convergence time to about 6 seconds. Today the traditional Spanning Tree is declared obsolete.
- In RSTP, switches maintain information about the second least-cost path to the root, so switching to the new topology in case of failure is much faster.
Multiple RSTP – MSTP
RSTP protocol has become the choice for preventing layer 2 loops in topologies that include redundancy. If there is a switch in the network, it must be able to run RSTP algorithm.
Another interesting form of redundancy, or security against loops, is using the Multiple Spanning Tree Protocol (MSTP). MSTP is an extension of RSTP that enables VLANs to be grouped into a spanning-tree instances. It provides multiple forwarding paths for data traffic and enables load balancing.
MSTP configures a separate spanning tree for each VLAN group, allowing to have a configured root bridge and forwarding topology for each VLAN. It blocks all but one possible alternate path within each spanning tree.
In that sense, SoC-e provides technology to integrate RSTP and MSTP functionalities into the network with the following product:
- Managed Ethernet Switch: is an IP Core for FPGAs with many configuration options, able to support both RSTP and MSTP. This makes it suitable for many types of applications.