Networking Tutorials

Spanning Tree Protocol Explained: Stopping Layer 2 Loops

Spanning Tree Protocol (STP) prevents Layer 2 loops — which would otherwise cause broadcast storms that crash a network in seconds. It does this by electing a root bridge and logically blocking redundant links, leaving one loop-free path while keeping the blocked links as backups.

How the root bridge is elected

Every switch has a bridge ID = priority (default 32768) + MAC address. The switch with the lowest bridge ID wins and becomes the root. All other switches choose their lowest-cost path toward the root; any link that would create a loop is put into a blocking state. To control which switch is root, lower its priority manually.

Port states and RSTP

Classic STP moves ports through Blocking → Listening → Learning → Forwarding, taking up to 50 seconds to converge. Rapid STP (RSTP, 802.1w) cuts this to a few seconds with new port roles (alternate, backup). PortFast moves access ports straight to forwarding for end devices. Loops and slow convergence are common troubleshooting scenarios.

Frequently asked questions

What is the purpose of Spanning Tree Protocol?

STP prevents Layer 2 switching loops — which cause broadcast storms — by blocking redundant paths while keeping one active loop-free path.

How is the STP root bridge chosen?

The switch with the lowest bridge ID (priority plus MAC address) becomes the root bridge. Lowering a switch's priority makes it the root.

What is the difference between STP and RSTP?

RSTP (802.1w) converges in seconds versus up to 50 seconds for classic STP, using improved port roles and states.

VS
Vipul Sir — Lead Instructor, Attila Technologies20+ years in Cisco networking. Teaching CCNA, CCNP, CCIE & CyberOps in Ahmedabad since 2004.

Want hands-on training?

Learn this on real Cisco lab devices with placement support at Attila Technologies, Ahmedabad.

Start your networking career with Attila Technologies

Hands-on Cisco training, real lab devices and placement support in Ahmedabad.