Tutorial 3: 802.1d - Spanning Tree Protocol

This is the last part of the series introducing Spanning Tree Protocol.   We will walk through a few examples of how the states of ports changes as the network converges on topology events.


As we covered briefly in Tutorial 1, STP removes loops by selectively blocking ports.

In effect, it unplugs a cable, cutting off the circular path.

Today, we will go over my rendition of how the protocol comes to the decision on what port to block and on which switch. 

We will also look how the switch transitions the blocked port back to forwarding mode (plugs the cable back in) when the circular path is cut at some other point.

When a switch is configured to be STP enabled there's a few things it need to do.

  • STP Todos:
    • Select a root switch
    • Identify the root port (RP)
    • Identify the designated port (DP)
    • Cut the loop, Block port (BP)
    • Toggle between port types (RP/DP/BP)


In a converged topology, the root switch sends out a beacon every two seconds announcing it's presence.

All other switches receives this message via their root port (RP) and echoes it out their "other" ports or designated port (DP) to it's downstream neighbor (into the neighbor's RP, and echo'd out their DP).   In a circular path, the beacon travels both direction from the root switch, across each neighboring switch and ends in an almost completed circle stopping only at the blocked port (BP).

How we get here:

Selecting a root switch:

As a STP enabled switch comes online (id. Switch_2), it notices that it hasn't received any beacon identifying the root switch.   It takes immediate action and identify itself as the root switch, stores it's own Bridge ID as the root switch, and sends a beacon (hello packet) out every interface claiming it's the root switch.    This hello packet is sent every two seconds and contains it's Bridge ID (comprised of a configurable priority + mac address of the bridge).    

As other switches come online, they begin to do the same.

Identifying the root port:

Upon hearing a hello packet from another switch, Switch_2 (SW2) compares it with its known root switch, and if the Bridge ID on the packet is "superior" than it's known root switch, it stores that switch's id.   It also flags the port in which hello packet came in as the RP.  It then adds a path cost to the hello packet and sends it out to it's neighbor.  It would also cease sending it's own hello packet, as only the root switch is allowed to do this.


Table 3.1:   Default Path Costs

Speed 10 Mbps 100 Mbps 1 Gbps 10 Gbps
Cost 100 19 4 2

 

 

 

 

The other ports:

The root switch propagate the beacon both direction downstream, at some point in time within that looped network, every non root switch will receive a hello packet from two sides.   Of the two hello packets received on a particular switch, the port receiving the hello packet with the least cost will win and remain RP.  

As this algorithm proceeds, we will naturally end up with switch that is not designated for any segments on the loop.  The root switch gets two leg of the circle since all it's ports are DP, every other switch will fight for n-1 segments to assign as DP.  One switch is left behind.  This switch will end up blocking the port with the higher cost back to the root.

When things become unstable:

When the network is converged, all switches and port roles would be defined, the topology would be considered stable.    If at any point, a port is changed from one classification to another (DP/RP/BP), a Topology Change Notification is sent from the affected switch and STP begins to reconverge.

This happens primarily when a RP goes down.   In a stable topology, the hello packets will only originate from one direction.   If that path is down, the switch will notice that there is no hello packets and take charge, setting itself as the root switch, changing it's BP or RP to a DP and send out a TCN packet.   This initiates the root switch selection process again, and any BP port will slowly transition from blocking to forwarding and eventually become a RP or DP port.

When I say slowly, I mean slowly:

  • 10 Missing Hello = No root in network (Maxage Timer)
  • Missing beacon triggers switch to be root
  • DP to RP transition causes TCN messages
  • TCN causes BP to go from Block to Listening
  • Multiple Hello beacon triggers root switch election
  • 15 seconds later BP goes from Listening to Learning  (Forward Delay Timer = 15s)
  • 15 seconds later BP goes from Learning to Forwarding
  • BP now becomes DP or RP.

All together now:

Using the configuration: stp.net & nvram files from Tutorial 2, we can watch some of this in action live.

Start up dynamips and follow along as needed.

 

Comments

There have been no comments made on this article. Why not be the first and add your own comment using the form below.

Leave a comment

Commenting is restricted to registered users only. Please register or login now to submit a comment.