STP- Spanning Tree Protocol Usage and Configuration

Although there are a lot of configurations you can make in network traffic with Spanning Tree Protocol (STP), we will mostly talk about the“Loop Protection” section of STP. Live ends on the network can cause a continuous loop called loop failure as a result of misuse, unauthorized intervention, misuse or malicious use, and after a while, if you have not taken any protection measures, it locks all switches on the network.
Index
STP – Spanning Tree Alghoritm
Spanning Tree Protocol does not only cover switches, it covers modem, firewall, router, converter and all manageable switches in the network. As the name suggests, it perceives the entire network as a tree and the algorithm works according to this tree.
The spanning tree algorithm routes the data from point A to point B and delivers it via the nearest network path. If there is an interruption or high traffic on the nearest path, it uses the backup path.
It calculates the“cost” of the path to reach each Ethernet interface in the network. It determines a cost value for each switch according to the distance of the path, the bandwith value and the number of switches in between. It chooses the least costly path to reach that point. STP can be configured on all network devices that support 802.1 standard.
As shown in the picture, there are two different paths from computer A to computer B. We can compare these roads to the D-100 and Tem roads in Istanbul. Let D-100 be the red lines and Tem be the green lines. Data packets going from A to B will always use the red road unless there is an interruption or high traffic.
Because it is both closer and reaches B by jumping over fewer network switches. This is similar to this, when the traffic is heavy on D-100 or the Bosphorus bridge is closed, you have to use the Tem highway. In this example, the STP algorithm works by considering the quantity and the number of bypassed switches.
STP Distance and Number of Switches
Spanning Tree is not only based on the number of meters or switches. In addition to these, bandwidth, which means traffic speed, is also important. In the picture above, if you consider that the red path is 2 mpbs and the green path is 20 mbps, the algorithm will not work in the same way.
Even if it is far away, it will follow the green road where the traffic speed is high. When traffic speed is added to the cost calculation, the values for both paths will change. Let’s examine the table below to see the effect of bandwith on the cost calculation.
The effect of Bandwith on Cost,
- 2 Mbps –> Cost= 500
- 4 Mbps –> Cost= 250
- 8 Mbps –> Cost= 125
- 10 Mbps –> Cost= 100
- 16 Mbps –> Cost= 60
- 50 Mbps –> Cost= 36
- 100 Mbps –> Cost= 18
- 150 Mbps –> Cost= 15
- 600 Mbps –> Cost= 6
- 1 Gbps –> Cost= 4
- 8 Gbps –> Cost= 2
Spanning Tree Protocol performs the following tasks in the switch.
- Learning (Creating the network topology)
- Listening (continuous listening to the topology)
- Forwarding (when everything is normal)
- Blocking (when Loop detected) – Blocking
- Disable – Disabled.
Switch Learning Mode
To briefly clarify the table above. If STP is activated in the switch, the first 4 events will take place in the following order. First of all, the switch will list the mac-addresses of the connected devices with Learning mode to recognize the network – subnet it is connected to and create the tree.
Network Listening Mode ve Forwarding Mode
Then it will listen to the devices in the list with Listening mode. If the loop event does not occur, it will continue data transfer with Forwarding mode.
Switch Blocking Mode
If a loop occurs on the selected path for any reason, Blocking mode will block the traffic for that path. Modes 1-2-3 work continuously. In the last item, the protocol is in disabled mode, so no STP algorithm will work in this mode.
Extreme Network Loop Protections
Let’s talk about the Loop error, one of the most feared problems of network administrators, that is, the main topic of our article.

As seen in the figure, if there is more than one connection path between 2 manageable network switches, Loop is inevitable. In the case of Loop, CPU Utilization values of both switches reach the maximum level and become unable to operate after a while. As a result, traffic stops first on both switches and then on the whole network.
Therefore, if there is no Loop Protection or Spanning Tree Configuration, you will have to manually detect the port causing the loop one by one manually to recover the network from the loop error. Because the switches are in a locked state, you cannot access the log records. This is one of the rare events that network administrators never want to encounter. In the picture, it is the cable connection attached to port 1 on both switches that needs to be blocked.
In order to avoid this, the“Loop Protect” configuration available on most manageable switches can be used.(Click here to access the article about Loop Protect). However, since Loop Protect only provides control over the interfaces on the same switch, it will not prevent the Loop event in a situation like the picture below. Let’s show the topology where a more complex Loop will occur.
In this topology, thanks to the STP configuration, there is no loop in the network. Because it detected two different paths overlapping with each other. For this reason, it calculated the cost values for both roads and preferred the one with the lowest cost, the green road.
The red path is blocked and traffic flows on the green path. “Loop Protection” configuration is useless in this topology. Because Loop Protect only prevents Loop failure on the same switch.
LACP Link Aggregation Control Protocol
Finally, I would like to talk a little bit about LACP. Because STP and LACP(Link Aggregation Control Protocol) in the Layer-2 layer work in coordination with each other. In this case, Spanning Tree Protocol may not block the conflicting path. The LACP configuration to be written overrides the STP configuration and traffic passes through both paths as shown in the picture below.
The ideal topology is the network above where STP & LACP are configured together. This network is not only protected against Loop but also provides backup and Load Balancing thanks to LACP configuration. On interfaces and switches without LACP configuration, Spanning Tree will block conflicting paths according to their cost values.
In this article, we have presented theoretical and visual content about STP and LACP. In our next articles, we will include configuration on several different brands of manageable switches.