Someone please explain what Spanning Tree Protocol (STP) actually does in layman's terms. I know it can cause problems with some network gear, but that's the extent of my knowledge.
It disables dynamically all links except one connecting two any switches. So it prevents network loops. And allows to have automatically enabled backup link in case the main one stops working.
But under bad configuration it can leave more then one link connecting two switches, then broadcast traffic starts multiplying and kills all network.
Quoting Wikipedia Spanning tree protocol -
Spanning tree protocol is a link layer network protocol that ensures a loop-free topology for any bridged LAN. It is based on an algorithm invented by Radia Perlman while working for Digital Equipment Corporation.1 In the OSI model for computer networking, STP falls under the OSI layer-2. Spanning tree allows a network design to include spare (redundant) links to provide automatic backup paths if an active link fails, without the danger of bridge loops, or the need for manual enabling/disabling of these backup links. Bridge loops must be avoided because they result in flooding the network.
The Spanning Tree Protocol (STP), is defined in the IEEE Standard 802.1D. As the name suggests, it creates a spanning tree within a mesh network of connected layer-2 bridges (typically Ethernet switches), and disables those links that are not part of the tree, leaving a single active path between any two network nodes.
STP short summary:
Prevents network loops which cause network crashes.
Provides automatic link redundancy for continuous operation.
As a follow on as to why you need STP: bridging and switching operates at layer 2 of the OSI model and is commonly associated with MAC addresses in Ethernet networks. Unlike TCP/IP, which operates at layer 3, at layer 2 there is no concept of a hop count which cause packets to expire after a period of time.
Bridges and switches, operating at layer 2, will forward (if the destination mac address is known) or flood (if it is not) traffic out ports except the one it is received on. If there is a loop in the network this would prevent packets from ever expiring and quickly consume all available bandwidth.
The spanning-tree protocol prevents this from happening, while permitting redundant links to be 'standing by'. If a link fails, the previously blocked connection is enabled and in a matter of seconds restors connectivity.
The Spanning Tree Protocol addresses the problem of packet collisions/network loops in a bridget network with redundant network paths.
Here is a nice article which explains the problem and the mechanism behind STP: Understanding Spanning Tree Protocol -- the Fundamental Bridging Algorithm.
[...] Redundancy eliminates a single point of hardware failure in a network. Whenever switch redundancy is present in a network, there is a loop. The trick here is to allow for multiple bridges and only allow for a singular path. The Spanning Tree Protocol (STP) algorithm provides the missing component the Sprocket network needs to implement a redundant network without the redundant traffic paths.