Spanning Tree Protocol


The Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for any bridged Ethernet local area network. The basic function of STP is to prevent bridge loops and ensuing broadcast radiation.


Spanning Tree defines 3 port roles. They are:

  1. Root Port
  2. Designated Port
  3. Blocking (Alternative Port)


The following states show in sequential order the various states that a port transitions through once the port is opened.

  1. Blocking – As the name suggests the port blocks all traffic and does not participate in frame forwarding / receiving. Due to this no MAC address are learnt. Though BPDU`s from neighbouring switches are excepted.
  2. Listening – The port still cannot forward or receive frames but can receive and send BPDU`s.
  3. Learning – Once the port is in the learning state the port starts learning MAC address.
  4. Forwarding – When in the forwarding state the port sends/receives frames and BPDU`s in addition to populating its MAC address table.
  5. Disabled – The port is administratively shutdown.


Spanning Tree consists of the following steps:

  1. Root Bridge election
  2. Root Port election
  3. Designated Port election
  4. Alternative (Blocking) Port election

    Root Bridge Election

    The bridge with the lowest bridge ID is elected as the root bridge. The bridge ID comprises of the following:

    1. Priority number
    2. MAC address of bridge

      Example: 32768.00:00:00:00:00:01 / [Priority number].[MAC Address]

      During the Root Bridge election process the Priority number is compared first. If the Priority number is equal then the MAC address is then used.

      Root Port Election

      Each port that has the lowest path cost to the Root Bridge is assigned the role of the root port. The path cost is calculated by the accumulative cost of all paths to the Root Bridge.

      Note :

      1. Root Ports are only assigned to non-root bridges.
      2. Each non-root bridge only has 1 root port

      Designated Port Election

      Each port with the lowest accumulative path cost to the root bridge is assigned the role of designated port.


      1. Every segment (path) has one designated port.
      2. Designated Ports are assigned to all bridges (non-root and root).

      In the event of 2 ports having the same path cost the neighbouring switches bridge ID is used. Again the lowest bridge ID wins.

      Alternative Port Election

      All remaining ports are set to Alternative and the state transitioned to blocking.

      5. EXAMPLE

      Below shows an example of Spanning Tree before and after transition.

      Before Transition

      Port Election

      Topology Summary


      About the Author


      R Donato

      Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

      You can find Rick on Twitter @f3lix001