Networking 101: Understanding Spanning Tree
Learn the basics of the Spanning Tree Protocol (STP) and its drawbacks and alternatives with the ENP primer.
Updated by Paul Rubens.
The Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for any bridged Ethernet local area network.
STP was invented by Dr. Radia Perlman, distinguished engineer at Sun Microsystems. Dr. Perlman devised a method by which bridges can obtain Layer 2 routing utopia: redundant and loop-free operation. Think of spanning tree as a tree that the bridge keeps in memory for optimized and fault-tolerant data forwarding.
Spanning tree in a nutshell
- STP provides a means to prevent loops by blocking links in an Ethernet network. Blocked links can be brought in to service if active links fail.
- The root bridge in a spanning tree is the logical center and sees all traffic on a network.
- Spanning tree recalculations are performed automatically when the network changes but cause a temporary network outage.
- Newer protocols, such as TRILL, prevent loops while keeping links that would be blocked by STP in service.
Eliminating loops with spanning tree
If your switches are connected in a loop without STP, each switch would infinitely duplicate the first broadcast packet heard because there's nothing at Layer 2 to prevent a loop.
STP prevents loops by blocking one or more of the links. If one of the links in use goes down, then it would fail over to a previously blocked link. How spanning tree chooses which link to use depends entirely on the topology that it can see.
The idea behind a spanning tree topology is that bridges can discover a subset of the topology that is loop-free: that's the tree. STP also makes certain there is enough connectivity to reach every portion of the networkby spanning the entire LAN.
Bridges will perform the spanning tree algorithm when they are first connected to the network or whenever there is a topology change.
When a bridge hears a "configuration message," a special type of BPDU (bridge protocol data unit), it will begin its disruptive spanning tree algorithm. This starts with the election of a "root bridge" through which all data will flow.
Tip: Cisco hardware normally uses the device with the lowest MAC address as the root bridge. Since this is the oldest and probably slowest device, it's best to configure the root bridge manually.
The next step is for each bridge to determine the shortest path to the root bridge so that it knows how to get to the "center." A second election happens on each LAN, and it elects the designated bridge, or the bridge that's closest to the root bridge. The designated bridge will forward packets from the LAN toward the root bridge.
The final step for an individual bridge is to select a root port. This simply means "the port that I use to send data towards the root bridge."
Note: Every single port on a bridge, even ones connected to endpoints, will participate in the spanning tree unless a port is configured as "ignore."
A newly connected bridge will send a reconfiguration BPDU, and the other connected devices will comply. All traffic is stopped for 30-50 seconds while a spanning tree calculation takes place.
Continued on Page 2: Rapid STP, solving VLAN challenges with PVST, and the drawbacks and alternatives to STP