Hello! In our previous lesson, we explored how a switch learns MAC addresses and forwards frames. You saw that when a destination is unknown, a switch floods the frame—a behavior that is essential for initial communication but can cause major problems in a redundantly connected network.
This lesson addresses that exact problem. We will investigate what happens when you create physical loops between switches for redundancy and how the Spanning Tree Protocol (STP) comes to the rescue. You will learn the fundamental purpose of STP and the general mechanism it uses to prevent network-crippling loops while preserving the benefits of a redundant design. This is a critical concept for building stable and resilient networks for your project.
By the end of this lesson, you will be able to describe the function of Spanning Tree Protocol (STP) in preventing Layer 2 loops.
The Problem: Redundancy and Layer 2 Loops
In network design, redundancy is key. Having multiple paths between switches ensures that if one link fails, traffic can automatically use an alternate path, preventing an outage. However, while redundancy is beneficial at Layer 3 (routing), it introduces a catastrophic problem at Layer 2 (switching).
Because Ethernet frames have no "Time to Live" (TTL) field like IP packets, a frame caught in a physical loop will circle endlessly. When a switch floods a broadcast frame (like an ARP request) in a looped topology, it creates a broadcast storm.

This storm can quickly overwhelm the switches, consuming all their CPU resources and bandwidth, effectively bringing the entire network to a halt. A secondary issue is MAC address table instability, where a switch constantly updates its table for a single MAC address as it sees frames arriving on different ports, causing unicast traffic to be unreliably forwarded.
The following video provides an excellent explanation of why redundancy is important and a clear demonstration of the broadcast storm and MAC address flapping problems that arise in a Layer 2 looped environment.
Free CCNA | Spanning Tree Protocol (Part 1) | Day 20 | CCNA 200-301 Complete Course
This video from Jeremy's IT Lab, "Free CCNA | Spanning Tree Protocol (Part 1)", clearly illustrates the problems that STP is designed to solve.
Please watch from the beginning of the discussion on redundancy up to the introduction of STP. Redundancy and Loops: Pay close attention to the visual example of how a single broadcast frame multiplies and loops indefinitely, leading to a broadcast storm and MAC address flapping.
The Solution: Spanning Tree Protocol (STP)
To get the benefits of physical redundancy without the catastrophic side effects of Layer 2 loops, networks use the Spanning Tree Protocol (STP). STP's function is to create a logically loop-free topology from a physically looped one. It does this by identifying redundant paths and putting specific switch ports into a blocking state.
A port in a blocking state doesn't forward any data frames, effectively breaking the loop. However, the port remains physically active and ready to transition to a forwarding state if the primary link fails, thus preserving redundancy.

STP is enabled by default on all ports of a Cisco switch, so it starts working the moment you connect switches together.
How STP Creates a Loop-Free Topology
STP follows a systematic process to build its logical tree structure. All switches running STP exchange special messages called Bridge Protocol Data Units (BPDUs) to share information about themselves and the network topology. Using this information, STP performs three main steps.
Introduction to Spanning Tree - NetworkLessons.com
The article "Introduction to Spanning Tree" on NetworkLessons.com gives a clear, step-by-step overview of the problem and the STP process.
Please read the sections "Why do we need Spanning Tree" and "How Spanning Tree solves loops". As you read, focus on understanding the three fundamental steps STP takes to build a loop-free topology: Electing a Root Bridge: What is a root bridge and how is it chosen? Selecting Root Ports: What is a root port and how do non-root switches choose theirs? Determining Designated and Blocked Ports: How is the final decision made to block a port and break a loop?
Let's recap the core concepts from that reading:
-
Elect a Root Bridge: The first thing switches do is elect a single Root Bridge. This switch becomes the central reference point for the entire spanning tree, like the root of a tree. The election is won by the switch with the lowest Bridge ID (BID). The BID is a combination of a configurable priority value and the switch's unique MAC address. Because all switches default to the same priority, the one with the lowest MAC address usually wins, unless an administrator intervenes.
-
Elect Root Ports: Every switch that is not the root bridge (a non-root bridge) must select one Root Port. The root port is the interface on that switch that has the best, lowest-cost path back to the root bridge. This ensures every switch has a single, efficient path toward the root.
-
Elect Designated and Non-Designated (Blocked) Ports: Finally, for every network segment (link between switches), one port is elected as the Designated Port. This port is responsible for forwarding traffic onto that segment. If there's another switch port on that same segment, it becomes a Non-Designated or Alternate Port and is put into a blocking state. This is the final step that breaks the loop.
By following these three steps, STP guarantees that there is only one active logical path between any two switches in the network, even if multiple physical paths exist.
A Note on Port States
When you plug a cable into a switch, the port doesn't start forwarding traffic immediately. You may have noticed the port light stays amber for about 30 seconds before turning green. This delay is caused by STP. Before a port can enter the Forwarding state, it must first pass through the Listening and Learning states. This cautious process ensures that enabling a new port doesn't accidentally create a temporary loop while the network is converging. We will explore these states and their associated timers in detail in our next lesson.
Conclusion
In this lesson, we established the critical function of the Spanning Tree Protocol. You learned that while physical redundancy is desirable for network resilience, it creates dangerous Layer 2 loops that lead to broadcast storms and MAC table instability. STP solves this by methodically building a loop-free logical topology.
Key Takeaways:
- Redundant physical paths in a Layer 2 network create loops, causing broadcast storms that can crash the network.
- STP's primary function is to prevent these loops by placing redundant ports into a blocking state.
- This creates a logical, tree-like topology that is free of loops while keeping the blocked paths available for backup.
- The STP process involves three main steps:
- Electing one Root Bridge for the network.
- Each non-root switch selecting one Root Port (its best path to the root).
- On each remaining link, electing one Designated Port (to forward traffic) and blocking all other ports.
Now that you have a solid grasp of why STP is necessary and what it does, our next lesson will focus on the details of how it does it. We will take a closer look at the root bridge election process and the different port states a switch interface transitions through.