What is Spanning Tree Protocol (STP)?

What is Spanning Tree Protocol (STP)?
Networking ATN Campus September 04, 2026 23 views

What is Spanning Tree Protocol (STP)?

What happens if you connect network switches together in a loop? ????

At first, having multiple connections between switches may look like a good idea because it provides redundancy and backup paths.

However, Ethernet networks can experience serious problems when Layer 2 loops exist.

This is where Spanning Tree Protocol (STP) becomes important.

STP helps prevent Layer 2 switching loops by logically blocking redundant paths while keeping them available as backup paths.


???? What is STP?

STP (Spanning Tree Protocol) is a Layer 2 protocol used by network switches to prevent switching loops.

STP allows switches to have redundant physical connections while logically blocking some of those connections to prevent loops.

        Switch A
        /       \
       /         \
      ↓           ↓
 Switch B ------ Switch C

       Physical Redundancy
               ↓
              STP
               ↓
       One path is blocked
               ↓
       Loop is prevented
        
Simple definition: STP prevents Layer 2 loops by placing redundant switch paths into a blocking state.

???? Why Do Network Loops Happen?

Ethernet switches forward frames based on MAC addresses. Without a loop-prevention mechanism, redundant connections can cause frames to circulate continuously.

        Switch A
        /       \
       ↓         ↓
 Switch B ←───→ Switch C
        \       /
         \     /
          -----

      Multiple paths
           ↓
      Layer 2 Loop
        

A frame can potentially travel around the network repeatedly because Ethernet frames do not contain a mechanism such as an IP packet's TTL to naturally stop endless Layer 2 forwarding.


???? Problems Caused by Layer 2 Loops

A switching loop can create several serious network problems.

1. Broadcast Storms

Broadcast frames can circulate repeatedly around a Layer 2 loop, consuming large amounts of network bandwidth.

Broadcast Frame
      ↓
 Switch A
      ↓
 Switch B
      ↓
 Switch C
      ↓
 Switch A
      ↓
 Switch B
      ↓
      ...
        

2. MAC Address Instability

Switches can receive frames from unexpected interfaces and may repeatedly update their MAC address tables.

3. Duplicate Frames

Frames may reach devices through multiple paths, resulting in duplicate traffic.

4. Network Performance Problems

Broadcast storms and excessive Layer 2 traffic can consume bandwidth and cause network devices to become overloaded.

A Layer 2 loop can turn a healthy network into an unstable network very quickly.

???? Why is it Called Spanning Tree?

STP creates a logical tree-like structure from the connected switches.

             Root Bridge
                  |
             +----+----+
             |         |
             ↓         ↓
          Switch B   Switch C
             |
             ↓
          Switch D
        

The network may have several physical connections, but STP logically selects paths that form a loop-free topology.


???? What is the Root Bridge?

The Root Bridge is the central reference point selected by STP when calculating the loop-free topology.

             Root Bridge
                  ????
                  |
        +---------+---------+
        |                   |
        ↓                   ↓
     Switch B            Switch C
        |                   |
        +---------+---------+
                  |
                  ↓
               Switch D
        

STP uses the root bridge as the reference when determining the best paths through the Layer 2 topology.

The switch with the best Bridge ID becomes the root bridge.


???? How is the Root Bridge Selected?

STP uses the Bridge ID when electing the root bridge.

The Bridge ID includes important information such as:

  • Bridge Priority
  • MAC Address

The switch with the lowest Bridge ID wins the root bridge election.

Bridge A
Priority: 32768
MAC: AA:AA:AA:AA:AA:AA

Bridge B
Priority: 32768
MAC: BB:BB:BB:BB:BB:BB

Bridge C
Priority: 32768
MAC: CC:CC:CC:CC:CC:CC

Lowest Bridge ID
       ↓
Bridge A
       ↓
Root Bridge ????
        

Network administrators can influence the election by configuring the bridge priority.


???? What are STP Port Roles?

STP assigns different roles to switch ports as it builds the loop-free topology.

???? Root Port

On a non-root switch, the root port provides the best path toward the root bridge.

             Root Bridge
                  |
                  ↓
             Switch B
                  |
             Root Port
                  ↓
             Switch C
        

???? Designated Port

A designated port is the forwarding port selected for a network segment.

???? Alternate / Blocking Path

A redundant path can be placed into a non-forwarding state so that it does not create a Layer 2 loop.

       Switch A
       /       \
      ↓         ↓
 Switch B ---- Switch C
      |           |
      +-----------+

              STP
               ↓
        Redundant path
          is blocked
               X
        

???? What is a Blocked Port?

A blocked port is a port that STP prevents from forwarding normal data traffic in order to eliminate a Layer 2 loop.

        Switch A
        /       \
       /         \
      ↓           ↓
 Switch B ----- Switch C
                  X
            Blocked Path
        

The physical connection still exists, but STP prevents it from being used as an active forwarding path while the current topology remains valid.

If the active path fails, STP can recalculate the topology and allow a previously blocked path to become active.


???? STP Provides Redundancy

One of the biggest advantages of STP is that it allows network administrators to build redundant physical connections without creating an active Layer 2 loop.

              Switch A
              /       \
             ↓         ↓
        Active Path   Backup Path
             |           |
             ↓           X
          Switch B   Blocked by STP

          Link Failure
               ↓
        STP Recalculates
               ↓
        Backup Path Used
        

This provides an additional level of network resilience.


⚙️ How STP Works

Switches running STP exchange special control messages called BPDU (Bridge Protocol Data Unit) frames.

Switch A ←──── BPDU ────→ Switch B
   ↑                         ↑
   |                         |
   +──────── BPDU ──────────+
               |
               ↓
        STP Information
               |
               ↓
      Calculate topology
               |
               ↓
      Select forwarding
          and blocked paths
        

Using the information exchanged between switches, STP determines the root bridge and the best paths toward it.


⏱️ Traditional STP Port States

Traditional IEEE 802.1D STP uses several port states during topology calculation and operation.

Blocking
   ↓
Listening
   ↓
Learning
   ↓
Forwarding
        

A port can spend time transitioning through these states as STP establishes or changes the topology.

Modern networks commonly use Rapid Spanning Tree Protocol (RSTP), which provides faster convergence than traditional STP.


⚡ STP vs RSTP

Feature STP RSTP
Standard IEEE 802.1D IEEE 802.1w
Convergence Slower Faster
Loop Prevention Yes Yes
Modern Usage Legacy environments Common in modern networks

Understanding traditional STP is still important because it forms the foundation for understanding modern spanning-tree technologies.


???? STP in an Enterprise Network

Consider a company with multiple access switches connected to redundant distribution switches.

             Distribution Switch A
                    ????
                  /   \
                 /     \
                ↓       ↓
          Access 1     Access 2
             |             |
             +------X------+
                    |
             Redundant Path
               Blocked
                 by STP
        

STP can prevent the redundant connection from creating a Layer 2 loop while keeping the physical link available for redundancy.


???? Cisco STP Verification Commands

If you are learning CCNA, you should become familiar with commands used to inspect STP.

show spanning-tree
        

This command provides information about the spanning-tree topology, root bridge, port roles, and port states.

show spanning-tree vlan 10
        

This can be used to examine spanning-tree information for a specific VLAN on supported Cisco switches.

???? Practice these commands in Cisco Packet Tracer to see how STP changes when you add or remove redundant links.

???? Simple STP Lab

You can create a simple STP practice topology using three switches.

          Switch 1
          /      \
         /        \
        ↓          ↓
    Switch 2 ---- Switch 3
        

Configure the switches and connect them in a triangle.

Then use:

show spanning-tree
        

Observe which switch becomes the root bridge and which port is placed into a non-forwarding state.

Next, disconnect one of the active links and observe how the spanning-tree topology changes.


???? Easy Way to Remember STP

Multiple Physical Paths
          ↓
Potential Layer 2 Loop
          ↓
        STP
          ↓
Choose Best Paths
          ↓
Block Redundant Path
          ↓
Loop-Free Network
        
Think of STP as a traffic controller for switch connections: it keeps the useful paths open and blocks paths that could create a loop. ????????

???? Test Your Networking Knowledge

What is the primary purpose of Spanning Tree Protocol?

  1. Assign IP addresses to computers
  2. Translate domain names into IP addresses
  3. Prevent Layer 2 switching loops
  4. Encrypt network traffic
???? Click here to reveal the answer

✅ Correct Answer: C) Prevent Layer 2 switching loops

STP prevents Layer 2 loops by calculating a loop-free topology and placing redundant paths into a non-forwarding state when necessary.


???? Key Takeaways

  • STP prevents Layer 2 switching loops.
  • Layer 2 loops can cause broadcast storms, duplicate frames, and MAC address instability.
  • STP elects a Root Bridge.
  • The Root Bridge is selected using the lowest Bridge ID.
  • STP selects appropriate forwarding paths through the network.
  • Redundant paths can be placed into a blocking/non-forwarding state.
  • STP uses BPDU messages to exchange spanning-tree information.
  • RSTP provides faster convergence than traditional STP.
  • STP is an important concept for anyone learning CCNA, switching, and enterprise networking.
Master STP and you will have a much better understanding of how enterprise switches maintain stable and redundant networks. ????

Start Your Networking Journey with ATN Campus

Want to learn STP, VLANs, switching, routing, subnetting, network security, and other essential networking concepts?

ATN Campus provides industry-focused networking and cybersecurity training that combines theory with practical hands-on experience.

Courses Available

  • CCNA – Cisco Certified Network Associate
  • CCNP – Cisco Certified Network Professional
  • CEH – Certified Ethical Hacker
  • Cisco CyberOps
  • Network Security
  • Cloud Networking
  • Python for Network Automation
  • Practical Networking Labs
  • Cybersecurity Fundamentals
  • Career Guidance & Certification Preparation

Whether you're starting from zero or preparing for a professional networking or cybersecurity certification, ATN Campus can help you build the practical knowledge and hands-on skills needed for today's IT industry.

???? Learn networking. ???? Master switching & routing. ???? Practice with real-world labs. ???? Prepare for certifications. ???? Build your IT career with ATN Campus.
Document ATN CAMPUS