Spanning Tree Protocol (STP)

The Spanning Tree Protocol (STP) is used in switched networks with redundant links to avoid loops in the network that will, if not blocked, lead to broadcast storms.

The picture below shows a network with three switches interconnected with Ethernet links. With Spanning tree active in the network, redundant links will be blocked, and by that loops and broadcast storms avoided.
Figure 1. Spanning Tree
If any of the links currently in service fails, STP will activate earlier blocked redundant links. Hereby network traffic could continue after a small disturbance. See the following figure.
Figure 2. STP Blocked Link Activated

The Spanning Tree Protocol exists in different versions:

Spanning Tree Protocol (STP) is the oldest version and is much slower than the other versions to de-block redundant links in case of failure. STP is normally too slow, 30-50 seconds, to respond to a change in the network.

Rapid Spanning Tree Protocol (RSTP) is a quicker variant of STP and will normally change within 6-30 seconds.

Note: RSTP is recommended to be used in all redundancy cases where several switches are involved

Multiple Spanning Tree Protocol (MSTP) is a variant of RSTP for Virtual LANs (VLAN). A separate Spanning Tree could be defined for each VLAN. Normally change occurs within 6-30 seconds.