Spanning tree protocol – How STP works

Spanning Tree Protocol (STP) Detailed Explanation

Spanning Tree Protocol (STP) Detailed Explanation

How STP Works

The Spanning Tree Protocol (STP) is used in Ethernet networks to prevent loops by creating a loop-free logical topology. Here's a step-by-step explanation of how STP operates:

Network Topology Example

            A ---- B ---- C
             |     |      |
             |     |      |
             D ---- E ---- F
            

Step-by-Step Process

1. Root Bridge Election

All switches in the network exchange Bridge Protocol Data Units (BPDUs) to elect the root bridge. The switch with the lowest Bridge ID (BID) becomes the root bridge. The BID is a combination of a configurable priority value and the switch's MAC address. The switch with the lowest BID is chosen as the root bridge.

In our example, assume the BIDs are as follows:

  • Switch A: 32768.0000.0000.0001
  • Switch B: 32768.0000.0000.0002
  • Switch C: 32768.0000.0000.0003
  • Switch D: 32768.0000.0000.0004
  • Switch E: 32768.0000.0000.0005
  • Switch F: 32768.0000.0000.0006

Since Switch A has the lowest BID, it is elected as the root bridge.

2. Root Port Selection

Each non-root switch selects a single root port. The root port is the port with the best path (lowest cost) to the root bridge. The path cost is determined by the speed of the connection. The faster the connection, the lower the path cost.

In our example:

  • Switch B selects its port connected to Switch A as the root port.
  • Switch C selects its port connected to Switch B as the root port.
  • Switch D selects its port connected to Switch A as the root port.
  • Switch E selects its port connected to Switch B as the root port.
  • Switch F selects its port connected to Switch E as the root port.

3. Designated Port Selection

On each network segment, the port with the lowest path cost to the root bridge is chosen as the designated port. The switch with the designated port will forward traffic for that segment.

In our example:

  • For the segment between A and B, A's port is the designated port since A is the root bridge.
  • For the segment between B and C, B's port is the designated port.
  • For the segment between A and D, A's port is the designated port.
  • For the segment between B and E, B's port is the designated port.
  • For the segment between C and F, C's port is the designated port.
  • For the segment between D and E, D's port is the designated port.
  • For the segment between E and F, E's port is the designated port.

4. Blocking Ports to Prevent Loops

All other ports that are neither root ports nor designated ports are set to the blocking state. Blocking ports do not forward traffic, thereby preventing network loops.

In our example:

  • Switch B's port connected to Switch E is a blocking port.
  • Switch E's port connected to Switch F is a blocking port.
  • Switch F's port connected to Switch C is a blocking port.

5. Tie-breaking Rules

If there is a tie in path cost, STP uses the following tie-breaking criteria in order:

  1. Lowest BID of the sender bridge.
  2. Lowest port ID of the sender bridge.
  3. Lowest port ID of the receiving switch.

Summary Table

Process Description
Root Bridge Election Switch with the lowest BID becomes the root bridge.
Root Port Selection Each non-root switch selects a port with the best path to the root bridge.
Designated Port Selection The port with the lowest path cost to the root bridge on each segment becomes the designated port.
Blocking Ports All other ports are set to the blocking state to prevent loops.
Tie-breaking Rules Lowest BID of sender bridge, lowest port ID of sender bridge, lowest port ID of receiving switch.

Share this post