Spanning Tree Protocol (STP)

Bridges are software based, while switches are hardware based because they use ASIC chips to help make filtering decisions.A switch can be viewed as a multi-port bridge. Switches have a higher number of ports than most bridges.Both bridges and switches forward layer 2 broadcasts. Bridges and switches learn MAC addresses by examining the source address of each frame received.Both bridges and switches make forwarding decisions based on layer 2 addresses. Three Switch Functions at Layer 2 Functions of layer 2 switching:

  1. address learning,
  2. forward/filter decisions, and
  3. loop avoidance

Address Learning

Layer 2 switches and bridges remember the source hardware address of each frame received on an interface, and they enter this information into a MAC database called a forward/filter table.

Forward/filter decisions

When a frame is received on an interface, the switch looks at the destination hardware address and finds the exit interface in the MAC database. The frame is only forwarded out the specified destination port.

Loop avoidance

If multiple connections between switches are created for redundancy purposes, network loops can occur. Spanning Tree Protocol (STP) is used to stop network loops while still permitting redundancy.

Loop Avoidance Spanning Tree Terms

  • Root Bridge

    The root bridge is the bridge with the best bridge ID. With STP, the key is for all the switches in the network to elect a root bridge that becomes the focal point in the network. All other decisions in the network such as which port is to be blocked and which port is to be put in forwarding mode—are made from the perspective of this root bridge.
  • BPDU

    All the switches exchange information to use in the selection of the root switch as well as in subsequent configuration of the network. Each switch compares the parameters in the Bridge Protocol Data Unit (BPDU)that it sends to one neighbor with the one that it receives from another neighbor.
  • Bridge ID

    The bridge ID is how STP keeps track of all the switches in the network. It is determined by a combination of the bridge priority (32,768 by default on all Cisco switches) and the base MAC address. The bridge with the lowest bridge ID becomes the root bridge in the network.
  • Nonroot bridges

    These are all bridges that are not the root bridge. Nonroot bridges exchange BPDUs with all bridges and update the STP topology database on all switches, preventing loops and providing a measure of defense against link failures.
  • Port cost

    Port cost determines the best path when multiple links are used between two switches and none of the links is a root port. The cost of a link is determined by the bandwidth of a link.
  • Root port

    The root port is always the link directly connected to the root bridge, or the shortest path to the root bridge. If more than one link connects to the root bridge, then a port cost is determined by checking the bandwidth of each link. The lowest-cost port becomes the root port.If multiple links have the same cost, the bridge with the lower advertising bridge ID is used. Since multiple links can be from the same device, the lowest port number will be used.
  • Designated port

    A designated port is one that has been determined as having the best(lowest) cost. A designated port will be marked as a forwarding port.
  • Non designated port

    A non designated port is one with a higher cost than the designated port. Non designated ports are put in blocking mode they are not forwarding ports.
  • Forwarding port

    A forwarding port forwards frames.
  • Blocked port

    A blocked port is the port that, in order to prevent loops, will not forward frames. However, a blocked port will always listen to frames.

Spanning Tree Operations

  • Selecting the Root Bridge

    The bridge ID is used to elect the root bridge in the STP domain and to determine the root port for each of the remaining devices in the STP domain. This ID is 8 bytes long and includes both the priority and the MAC address of the device. The default priority on all devices running the IEEE STP version is 32,768.To determine the root bridge, you combine the priority of each bridge with its MAC address. If two switches or bridges happen to have the same priority value, the MAC address becomes the tiebreaker for figuring out which one has the lowest (best) ID

    We’ll use the show spanning-tree command: 

    Switch B(config)#do show spanning-tree VLAN0001

    Spanning tree enabled protocol ieee
    Root ID    Priority    32769
    Address     0005.74ae.aa40
    Cost        19
    Port        1 (FastEthernet0/1)
    Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
    Bridge ID Priority    32769 (priority 32768 sys-id-ext 1)
    Address     0012.7f52.0280
    Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
    Aging Time 300

    Use the following command to change a bridge priority on a Catalyst switch:

    Switch B(config)#spanning-tree vlan 1 priority ?

    < 0-61440 >bridge priority in increments of 4096

    Switch B(config)#spanning-tree vlan 1 priority 4096

    You can set the priority to any value from 0 through 61440. Setting it to zero (0) means that the switch will always be a root bridge, and the bridge priority is set in increments of 4096.If you want to set a switch to be the root bridge for every VLAN in your network, then you have to change the priority for each VLAN, with 0 being the lowest priority you can use. It would not be advantageous to set all switches to a priority of 0.

    Check out the following output—now that we’ve changed the priority of Switch B for VLAN 1 to 4096, we’ve successfully forced this switch to become the root:

    Switch B(config)#do show spanning-tree VLAN0001

    Spanning tree enabled protocol ieee
    Root ID    Priority    4097
    Address     0012.7f52.0280
    This bridge is the root
    Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
    Bridge ID Priority    4097   (priority 4096 sys-id-ext 1)
    Address     0012.7f52.0280
    Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
    Aging Time 15
  • Spanning-Tree Port States

    The ports on a bridge or switch running STP can transition through five different states:


    A blocked port won’t forward frames; it just listens to BPDUs. The purpose of the blocking state is to prevent the use of looped paths. All ports are in blocking state by default when the switch is powered up.


    The port listens to BPDUs to make sure no loops occur on the network before passing data frames. A port in listening state prepares to forward data frames without populating the MAC address table.


    The switch port listens to BPDUs and learns all the paths in the switched network.A port in learning state populates the MAC address table but doesn’t forward data frames. Forward delay means the time it takes to transition a port from listening to learning mode,which is set to 15 seconds by default and can be seen in the show spanning-tree output.


    The port sends and receives all data frames on the bridged port. If the port is still a designated or root port at the end of the learning state, it enters the forwarding state.


    A port in the disabled state (administratively) does not participate in the frame forwarding or STP. A port in the disabled state is virtually nonoperational.

    Switches populate the MAC address table in learning and forwarding modes only.Switch ports are most often in either the blocking or forwarding state. A forwarding port is one that has been determined to have the lowest (best) cost to the root bridge. But when and if the network experiences a topology change (because of a failed link or because someone adds in a new switch), you’ll find the ports on a switch in listening and learning states. Blocking ports is a strategy for preventing network loops. Once a switch determines the best path to the root bridge, all other redundant ports will be in blocking mode.

    Blocked ports can still receive BPDUs—they just don’t send out any frames.If a switch determines that a blocked port should now be the designated or root port because of a topology change, it will go into listening mode and check all BPDUs it receives to make sure it won’t create a loop once the port goes to forwarding mode.

h4 ExamMATE

Online Personalised Exam Preparation Tool to score higher using Assessment, Analytics & Artificial Intelligence

Copyright ©2015, All Rights Reserved. h4 ExamMATEâ„¢ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.
Need help? Ask h4 ExamMATE Bot