Spanning Tree Protocol (STP)

Spanning Tree Protocol (STP) is a network protocol that prevents loops in Ethernet networks with redundant paths. 

When switches are connected in a mesh topology for redundancy, data packets can circulate infinitely, causing broadcast storms that crash the network. 

STP solves this by creating a loop-free logical topology.

How STP Works

STP automatically identifies and blocks redundant paths while keeping them as backup routes. It does this by:

  1. Electing a Root Bridge: All switches exchange Bridge Protocol Data Units (BPDUs). The switch with the lowest Bridge ID becomes the root bridge—the reference point for the spanning tree.

  2. Calculating Path Costs: Each switch calculates the shortest path to the root bridge based on link speeds. Lower cost = better path.

  3. Selecting Port Roles: Ports are assigned roles:

    • Root Port: Best path to root bridge
    • Designated Port: Forwards traffic on a segment
    • Blocked Port: Redundant path, blocks traffic
  4. Blocking Redundant Links: Ports that would create loops enter blocking state, preventing traffic but listening for topology changes.

Practical Example

Imagine three switches connected in a triangle:

        [Switch A - Root Bridge]
           /              \
          /                \
     [Switch B]----------[Switch C]

Port states after STP convergence:

  • Switch A (Root Bridge): All ports are Designated Ports (forwarding)
  • Switch B: Port to A = Root Port (forwarding), Port to C = Designated Port (forwarding)
  • Switch C: Port to A = Root Port (forwarding), Port to B = BLOCKED (prevents loop)

Without STP, a broadcast from Switch A would travel to B and C, then bounce between B and C indefinitely. With STP, the B-C link is blocked, creating this logical path:

        [Switch A]
           /      \
          /        \
     [Switch B]   [Switch C]

If the A-C link fails, STP detects the topology change (typically within 30-50 seconds), unblocks the B-C port, and traffic reroutes through B. Modern variants like Rapid STP (RSTP) converge in under 6 seconds.

Key Benefits

  • Prevents broadcast storms and network meltdowns
  • Provides redundancy through automatic failover
  • Works automatically without manual configuration

STP is fundamental to enterprise networks, ensuring reliability while maintaining redundant connections for fault tolerance.

No comments:

Post a Comment