The Spanning Tree Protocol (STP), is a link-management protocol that is part of the IEEE 802.1 standard for bridges and switches. STP uses the spanning-tree algorithm (STA) to prevent network loops and provide path redundancy in a LAN.
Mathematically, spanning tree protocol is to build and maintain a minimal spanning tree for connected nodes.
The STA finds the shortest path for a frame to move from source node (computer A) to destination node (computer B) via the network edges (cables connections in between).
The math model might be simple, but we need to get into details of how LAN switches establish the spanning tree with STP. The STA algorithm creates a hierarchical tree spanning the entire network, including all bridges and switches. The STA finds all the redundant paths and makes only one of them active at any given time. If a network segment becomes unreachable, the STA reconfigures the logical topology, reestablishing the link by activating the standby path.
Here is another example of STP convergence.
We will revisit root bridges, root ports and designated ports in the next section.