Skip to content

3.3 STP

Play

STP Overview

1. Spanning Tree Protocol (STP)

The Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for Ethernet networks. In a local area network (LAN), especially when you have redundant links (multiple paths between switches), loops can occur, which can lead to broadcast storms, duplicate frames, and network instability. STP was designed to prevent this by determining the best path and blocking any redundant paths.

1.1 How STP Works

  • Bridge Protocol Data Units (BPDU): STP uses BPDUs, which are messages exchanged between switches to determine the network topology.
  • Root Bridge: The switch with the lowest Bridge ID (priority + MAC address) is elected as the root bridge. This switch serves as the reference point for calculating the shortest path to all other switches.
  • Root Port: The port on a switch that is the closest to the root bridge (the best path).
  • Designated Port: The port on a switch that has the best path to the root bridge for a particular segment of the network.
  • Blocked Ports: Any redundant paths are placed in a blocking state to prevent network loops.

1.2 STP States

  • Blocking: The port does not forward traffic.
  • Listening: The port listens to BPDUs to ensure there is no loop.
  • Learning: The port learns MAC addresses but does not forward frames yet.
  • Forwarding: The port forwards traffic.

1.3 Example of STP in Cisco Packet Tracer

Let’s walk through an example where you have three switches connected in a triangle:

  1. Create the topology in Packet Tracer:

    • Add three switches: S1, S2, and S3.
    • Connect the switches as follows:
      • S1S2
      • S2S3
      • S3S1
    • You should now have a loop in the topology.
  2. Enable STP on the switches: STP is enabled by default on Cisco switches, but if it’s disabled or if you want to ensure it’s active, you can check it with:

    Terminal window
    show spanning-tree
  3. Verify the Root Bridge: You can see which switch is the root bridge and the role of each port by entering the following command on each switch:

    Terminal window
    show spanning-tree

    In the output:

    • The Root Bridge will be the switch with the lowest bridge ID.
    • Root Port will indicate the port closest to the root bridge.
    • Designated Port will show which port is active for forwarding traffic on each switch.
    • Blocked Ports are the ones that STP has disabled to avoid loops.
  4. Simulate a Failure (Optional):

    • You can manually break a link (for instance, disconnect S1 and S2) to see how STP reconfigures the network and selects a new path.

1.4 Example Output from show spanning-tree

If you run the command show spanning-tree on one of the switches (say, S1), you might see something like this:

Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 001b.54c3.92a0
Cost 19
Port 128 (Fa0/1)
Bridge ID Priority 32769
Address 001b.54c3.92a0
Hello Time 2 sec
Max Age 20 sec
Forward Delay 15 sec
Interface Role Sts Cost Port ID
Fa0/1 Root FWD 19 128
Fa0/2 Desg FWD 19 128
Fa0/3 Desg FWD 19 128

This output shows that:

  • The root bridge has the MAC address 001b.54c3.92a0 and is connected via port Fa0/1.
  • Fa0/2 and Fa0/3 are in designated port roles, forwarding traffic.

2. STP in Packet Tracer

STP - Part 01

STP - Part 02

STP - Part 03