STP – Spanning Tree Protocol Explained Thoroughly

A Spanning Tree Protocol, or STP, is a layer-2 protocol used to prevent network loops by ensuring that a single path exists between every pair of network nodes. In this blog post, I will describe the Spanning Tree protocol, the problems it solves, its core components, how it operates, and best practises for configuring it.

As a final note, I will use Spanning Tree Protocol, and STP interchangeably throughout this post; they all serve the same purpose. In this post, bridge and switch have the same meaning.

 

What is the purpose of Spanning Tree Protocol in networking?

The Spanning Tree Protocol, abbreviated STP, is a layer-2 network protocol that runs on switches and prevents loops in Ethernet networks by blocking redundant links. To know more Spanning Tree Protocol visit the website howtonetwork.com & get full fledged information about STP

What is the function of STP (spanning tree protocol)?

The primary function of the spanning tree algorithm is to prevent layer2 loops and the resulting broadcast storms in the logical layer2 topology.

Due to the fact that STP always creates a single path between two nodes, another purpose of spanning trees is to design networks with built-in redundancy via backup links in the event that an active link fails.

 

Spanning Tree Protocol – History

Sun Microsystems’ Dr. Radia Perlman was the inventor of STP, which was specified as IEEE 802.1D.

In 2001, the IEEE defined Rapid Spanning Tree Protocol as 802.1w. RSTP introduces new convergence behaviours and bridge port roles to accelerate network change and recovery from failure. RSTP is also backwards compatible with STP.

STP was originally defined as IEEE 802.1D, but spanning tree (802.1D), rapid spanning tree (802.1w), and multiple Spanning tree (802.1s) capabilities have since been incorporated into IEEE 802.1Q-2014. MSTP is also compatible with the STP protocol.

 

Types of Spanning Tree Protocol

There are both IEEE and Cisco proprietary versions of the STP protocol.

Included in IEEE Versions of STP are:

  1. IEEE 802.1D is the original version of STP. One instance of STP for all VLANs.
  2. IEEE 802.1w, or Rapid STP or RSTP, is also known as RSTP. It has a quicker convergence rate than STP.
  3. MSTP, or IEEE 802.1s, is Multiple Spanning Tree Protocol. As an IEEE response to Cisco’s Per VLAN STP, multiple VLANs can be mapped to a single STP instance.

Cisco proprietary STP versions include the following:

  1. Per VLAN STP+ or PVSTP, there is one STP instance.
  2. PVRSTP or R-PVSTP+ or VLAN Rapid STP is faster than PVSTP.

 

How Spanning Tree Protocol Works?

STP selects a network’s root bridge. The root bridge is located at the centre of the spanning tree, and all other bridges must take the shortest route possible to reach it. The spanning tree computes the cost of each path from each network bridge to the root bridge. Only the least expensive route is maintained and utilised. By putting these ports into a blocking state, all other paths are put on hold.

The above functions and many others are carried out by exchanging BPDUs (Bridge Protocol Data Unit) every 2 seconds between the switches.

Let us understand BPDU first.

 

What is Bridge Protocol Data Unit?

BPDU (Bridge Protocol Data Unit) transports vital STP messages. Herein are the specifics.

  • BPDUs are 8-byte control frames used to transmit STP data between switches.
  • STP uses BPDUs to choose a single root bridge and to discover and promote TCs (Topology Changes).
  • BPDUs contain the information needed to assign distinct port responsibilities between switches and detect/eliminate loops.
  • In a stable STP (802.1D) topology, only the root bridge sends BPDUs, while other bridges relay the BPDUs from the root bridge.
  • The most recent BPDU received on each port is stored until the maximum age of the timer is reached.
  • An inferior BPDU contains root bridge information that is worse than the BPDU currently stored for the port on which it was received.
  • A superior BPDU contains root bridge information that is superior to the BPDU currently stored for the port it was received on.
  • When a superior BPDU is received on a port, the previous BPDU is overwritten, and the port is promoted to root/designated port.
  • BPDUs are generated per-VLAN with PvST.
  • PvST BPDUs include the VLAN-ID in a ‘PVID’ TLV field, the sending port’s MAC address, and a destination multicast MAC of 0100.0ccc.cccd.

Let us now look at all the operations performed by STP inside switches:-

 

States of Spanning Tree Protocol

When a port is brought online on a switch, it passes through a sequence of spanning-tree port states. Based on the information derived from BPDUs received at the port, these states change in a predictable manner.

Spanning tree has the following states on a port:

 

Disabled

A port is in the downstate and is not involved with STP.

Initializing

Recently, a port in the initialising state was powered on or removed from the administratively downstate.

 

Blocking

A blocked port is essentially inactive. The blocking delay is twenty seconds long.

  • The port cannot transmit or receive frames, nor can MAC addresses be recorded.
  • The port’s sole responsibility is to receive and process BPDUs.
  • If necessary, the port can receive and respond to network management messages.

 

Listening

In contrast to the blocking state, BPDUs are sent and received during the listening state. Once more, frame forwarding is prohibited and no addresses are learned.

The delay in listening is 15 seconds.

 

Learning

A port in the learning state does not forward frames, but it analyses incoming frames to extract their MAC addresses and insert them into the MAC address table or CAM table. Once the frames have been analysed, they are discarded.

The delay in learning is 15 seconds.

 

Forwarding

You can consider the forwarding state to be “normal.” In this state, a port receives and transmits BPDUs, examines incoming packets for their MAC addresses, and forwards frames from other switch ports.

When a port is in the forwarding state, the connected device or network is operational and prepared to communicate.

 

Disabled

A port that has been disabled does not forward frames and is not a part of the spanning tree. It only responds to and accepts network management messages.

 

Important details regarding STP port states

  • The IEEE standard stipulates that the Listening and Learning timers must have identical values.
  • The blocking state delay only applies when a port initialises for the first time, i.e. after a reboot, and not when a port changes from blocking to forwarding.
  • When a port is first enabled, there is a total delay of 50 seconds (20+15+15) during which no data is transmitted.
  • When a port enters the forwarding state, the delay is comprised solely of the listening and forwarding delays, such as when a port is unshut down.
  • In addition, when a port’s status changes, data flow is unavailable for a total of 30 seconds (15 + 15).

 

Conclusion

STP is a protocol for preventing network loops in switches. Cisco switches have STP enabled by default, and it must be used to prevent network loops. This article described the Spanning Tree Protocol (STP) concept, its operation, its port states, and other STP features. After discussing how to configure and test STP in your network, we concluded the article with a discussion of best practices. To read more about networking & Comptia Security+ Certification & its study guide follow this link.