The Spanning Tree Protocol (STP) is a network protocol that is situated in Layer 2 (Data Link Layer) of the Open Systems Interconnection (OSI) model. It was built to prevent the problems that arise when data is exchanged through computers over a Local Area Network (LAN).
If 2-3 switches are connected together, they broadcast by default. When a message is broadcasted, it is sent all across the switches back and forth. This could lead to a broadcast storm or the formation of a loop.
This is where the Spanning Tree Protocol (STP) comes in handy.
What Does Spanning Tree Protocol (STP) Do?
The Spanning Tree Protocol (STP) avoids the formation of loops or broadcast storms. It does so by blocking ports where it senses loop formation. In other words, the STP looks after the network to make it loop-free by tracking all the links and stopping the working of useless links.
The STPs are now standardized by the Institute of Electrical and Electronics Engineers (IEEE). It is now referred to as STP (802.1D).
How Does STP Work?
The STP works in the following three steps:
- Selecting the root bridge
- Selecting the root port
- Selecting designated port and non-designated port
Before we dive deep into these steps, here are some terms that you must know about!
A bridge is a very important component of VLAN Trunking Protocol (VTP) that functions to connect to or more LAN segments.
2. Bridge ID:
The bridge ID refers to the MAC address of a particular bridge. It is an 8-byte entity that consists of a bridge priority (2 bytes) and a Base MAC address (6 bytes). The base MAC address is considered in cases where there is a tie on the bridge priority.
3. Root Bridge:
The bridge with the lowest bridge ID is called the root bridge. The root bridge chooses which port has the best path to the root bridge.
4. Bridge Priority Data Unit (BPDU):
An STP network device has to exchange messages to run a loop-free topology smoothly. All the switches exchange BPDU to select the right root bridge. The switch with the lowest Bridge ID is chosen as the root bridge.
5. Bridge Priority:
Every switch is assigned a priority. It is 32768 by default.
Now that you are familiar with all these terms, let’s learn how the STP works.
1. Selecting the root bridge:
The root bridge with the lowest bridge ID is selected. The lower bridge ID is found as follows:
Bridge ID = Priority + MAC Address
By default, the priority of all the switches is the same. If the priority is the same, then we look for the MAC addresses of the switches. The BPDU message is sent and it compares the MAC addresses of all the switches.
The switch that has the lowest MAC Address is then chosen. Therefore, this is our root bridge. This root bridge becomes the focal point of the connection.
Note: No port of the root bridge is ever blocked.
2. Selecting the root port:
Now that we have found our root bridge, other switches will find out the best path to reach the root bridge. They do so by checking the path cost. The path with the lowest cost is selected to connect with the root bridge.
From the above path cost table, you can see that the cost for 100 Mbps is 19.
3. Selecting designated port and non-designated port:
You should remember that there are two types of ports:
1. These are the designated ports.
1. These are the non-designated ports.
2. The root ports are the forwarding ports.
2. The block ports are non-forwarding ports.
The root bridge is the designated port.
In case, if the cost of a path is the same no matter what path is chosen, the switches look for lower Bridge ID using BPDU.
The port with the higher bridge ID (MAC address + Priority) is blocked.
If you want to learn how STP works in a visual way, you can watch this video right here:
What are the Types of Spanning Tree Protocol?
There are over six types of STP protocols that we study. Let’s go over each of them and learn the difference between them!
PVRST+ or R-PVST+
What are the States of STP?
There are five different states of STP. These are as follows:
1. Blocking State:
- It is a non-designated port.
- It does not take part in the forwarding of frames.
- Switch ports are kept in the blocking state for 20 seconds. After that, they change to the listening state.
2. Listening State:
- It is the first state of the Spanning Tree Protocol after the blocking state.
- The STP decides whether to use the port in frame forwarding or not.
- The ports stay in the listening state for 15 seconds and then move on to the next state.
3. Learning State:
- This state helps prepare STP to take part in the frame forwarding state.
- The STP discards frames received on the port during this state.
- It receives BPDUs.
- It learns the addresses.
- The learning state lasts for 15 seconds.
4. Forwarding State:
- The ports forward the frames received to the other ports in this state.
- It receives BPDUs in this state.
- It also learns the addresses.
- The ports remain in the forwarding state until any change occurs.
5. Disabled State:
- When an administrator commands the port to get disabled, the port enters the disabled state.
- it then discards the frames received on the port.
- It stops learning the LAN addresses.
- It does not receive BPDUs.
It’s a Wrap!
That’s all for our STP blog. I have covered everything that you need to know about STP.
Now, you are familiar with what is STP, how it works, the types of STP, and the various states of STP. If you are not familiar with switches very well, I recommend you to read this blog.
Stay tuned for more blogs for the CCNA 200-301 series!