STP Topology Generation

Election of a Root Bridge

The first step in any Spanning Tree Protocol topology generation is to identify the root bridge. When a switch initialises it will assume that it is the root bridge and uses its local bridge identifier as a root bridge identifier.

The ports on the local switch will then transition to a listening state and listens for its neighbours bridge protocol data units (BPDUs). If a BPDU is received it will do one of two options:

  • If the neighbours configuration BPDU is inferior to its own BPDU, the switch will ignore it.
  • If the neighbours configuration BPDU is preferred to its own, the switch will update its topology and BPDUs to include the new root bridge identifier along with a new root path cost. The root path cost adds up the cumulative cost to reach the new root bridge.

Spanning Tree Protocol will deem a neighbouring switch more preferable if the priority in the bridge identifier is lower than the priority of the other switches configurations BPDUs. If the priority is the same between the switches it will prefer the BPDU with the lower switch MAC address. This may not be ideal in certain cases as a older switches tend to have lower MAC addresses.

The priority of the bridge can be determined by the configured priority (default 32768) and adding the system-id on top of it, which is the VLAN number. VLAN 1 for example would be 32768 + 1 = 32769

On a Catalyst switch participating in a spanning tree protocol topology, the root bridge can be shown by running the command show spanning-tree root

The root path cost is always the value that is generated on the local switch, as a BPDU is received on a port, the local root path cost is the advertised cost plus the local interface port cost. The root path cost is set to 0 on the root bridge.

Determining a Root Port

Once a switch has determined the root bridge on a topology, it next needs to determine its root port.

The root bridge continues to advertise configuration BPDUs out of all of its ports. The receiving switch compares this information in order to identify the root port. The root port is selected using the following logic:

  1. The interface with the lowest path cost to the root bridge is preferred
  2. If tied, the interface associated to the lowest system priority of the advertising switch is preferred
  3. If tied, the interface associated to the lowest system MAC address of the advertising switch is preferred
  4. If tied, for example multiple links to the same switch, the lowest port priority from the advertising switch is preferred.
  5. If tied again, such as port priorities being the same, the lowest port number from the advertising switch is preferred.

Determining Blocked and Designated Switch Ports

The next step after identifying root ports is determining the remaining ports and their states: blocked or designated?

Generally all remaining ports as set to port roles of designated unless two non-root switches are connected together on their designated ports, this creates a network loop.

To resolve this network loop once of the switches will need to change their port to a blocking port type. Similar to determining a root port this follows a set of logical steps:

  1. The interface is designated port and can not be considered a root path.
  2. The switch with the lower path cost to the root bridge will continue to forward packets on its port, and the switch with the higher path cost will block. If there is a tie in the path cost to the root bridge there are additional steps.
  3. The system priority of the switches are compared, The switch with the lower system priority is moved to a blocking state. If it is tied it moves onto the next step.
  4. The MAC addresses of the switches are compared. The switch with the lower MAC address is to set their port type to blocking, the other switch continues to forward on its port.

Verifying STP Information on a Network Switch

The command show spanning-tree with the optional suffix of vlan x can provide a large amount of useful information for determining a ports STP state.

The output will show information regarding the root bridges information along with the local bridge information. Each STP ports cost, priority, and port type will be displayed too.

An additional column in the output can provide information on the port-type, Cisco Catalyst switches may show:

  • P2P – This port connects to a networked device
  • P2P Edge – Port-fast is enabled on this port
  • *TYPE_Inc – There is a port configuration mismatch between the local port and the port that it connects too.

Additional prefixes that can be set to the show spanning-tree command are the words interface X or detail

Adding the interface suffix will only show information regarding the interface specified in the command.

The detail addition provides information on port cost, port priority, number of transitions, link type and a count of BPDUs sent or received for each VLAN registered on that interface.




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.