TechKnowSurge
Cisco CCNA 2.5 Cisco CCNA 1.13
VideoNetworkFree

Spanning-Tree Algorithm (STA)

The Spanning Tree Algorithm is the logic behind Spanning Tree Protocol, guiding switches through a structured election process to eliminate network loops. This overview covers how switches exchange Bridge Protocol Data Units, elect a root bridge, calculate path costs, and assign port roles to maintain a loop-free topology.

Complete this video to capture a CTF flag worth 1 point.

About this video

The Spanning Tree Algorithm is the underlying logic that Spanning Tree Protocol (STP) follows to eliminate Layer 2 loops in a switched network. Rather than a single action, it is a sequential process that switches execute automatically whenever ports become active, ensuring that only one logical path exists between any two network devices at any given time. Understanding this algorithm is foundational to managing and troubleshooting modern switched infrastructures. The process begins when switches exchange special frames called Bridge Protocol Data Units (BPDUs) out of every active port. These BPDUs carry each switch's Bridge ID as well as STP timer values and information about the lowest Bridge ID detected on the network. As switches share and compare this information, they collectively agree on which device holds the lowest Bridge ID, and that device is elected the root bridge — the central reference point for the entire spanning tree. Once the root bridge is established, every other switch calculates the cost of each available path to reach it, assigning a root port to the single lowest-cost link. From there, the algorithm determines which ports on each network segment should be designated as forwarding ports and which should be blocked. Ports that are neither root ports nor designated ports are placed into a blocked state, effectively pruning the topology of any redundant links that could form loops. The end result is a stable, loop-free network path from every switch to the root bridge.

What you'll learn

What's covered

Spanning Tree Algorithm

Aligned to

Cisco CCNA
2.5 Interpret basic operations of Rapid PVST+ Spanning Tree Protocol
1.13 Describe switching concepts

Key terms

Spanning Tree Protocol
STP
A network protocol that prevents loops in Ethernet networks by creating a loop-free logical topology.
Bridge Protocol Data Unit
BPDU
A data message exchanged between switches running Spanning Tree Protocol to detect network loops and elect a root bridge. BPDUs contain the sending switch's BID and path cost information used to build the loop-free spanning tree.
Bridge
A network device that connects two or more network segments and filters traffic based on MAC addresses.
Switch
A network device that connects devices within a LAN and forwards traffic based on MAC addresses.
Root Bridge
The switch elected as the reference point for the Spanning Tree Protocol topology, determined by the switch with the lowest Bridge ID (priority + MAC address). All other switches calculate their best path to the root bridge and block redundant links to create a loop-free tree.
Root Port
The port on a non-root switch that provides the least-cost path to the root bridge.
Designated Port
DP
In STP, the port on each network segment that provides the best path to the root bridge and is placed in a forwarding state. Each segment has exactly one designated port, which is selected based on the lowest cumulative path cost to the root.
Blocked Port
A switch port that is shut down by the Spanning Tree Algorithm to eliminate loops, preventing it from forwarding traffic while the topology remains stable.

Topics

Spanning Tree Protocol Network Switching Bpdu Root Bridge Election Loop Prevention Networking

Transcript

The spanning tree algorithm is that set of instructions that spanning tree protocol uses to eliminate loops.

This is going to be more of an overview, and then we'll go over the specific steps: electing a root bridge, then calculating root path costs and how it applies to electing root ports, and then finally we'll sum it up with electing designated and non-designated ports.

Bridge protocol data units

When you turn on spanning tree protocol on your switch — and a lot of switches already have spanning tree protocol enabled on them — what's going to happen is every time you plug something into one of those ports and those ports go live, it's going to send out what's called bridge protocol data units. It's just a frame that it sends out the port with certain pieces of information.

So if switch 2 on here would turn on, it would send out bridge protocol data units down each one of the links, and then it would send that out and those other switches would get that.

Some of the information that it sends out is things like information about STP, like the timers and that type of stuff. It will also send out its own bridge ID, so it sends out its ID to these other devices. It also sends out information about what the lowest bridge ID that it's found on the network is.

Electing a root bridge

What essentially happens is at some point in time all these switches get that same information, and then they determine who has the lowest bridge ID, and it will elect a root bridge. So we elect one of these devices as being the root bridge.

Root path cost and the root port

The next thing it does is calculate: okay, what is my fastest route, what is my least cost route to get to that root bridge? So for each one of these links on switch 2, it's going to determine that there are four ways to get to the root bridge, and then it's going to calculate the cost that it takes to get to that root bridge on each one of those links.

Once it's done that, what it will do is elect a root port out of those four links. It will choose one of them to say, that is the link that I'm going to use to get to the root bridge, so I'll send it out in that direction. So, elect a root port.

Designated and blocked ports

Then it will elect designated ports. We will talk about what specifies a designated port, but on this network there are going to be a lot of different designated ports that are on this network.

And then it will shut off all other ports, so it will elect alternate or blocked ports. So for switch 2 it would shut down all other ports going towards that root bridge.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →