Why Is Spanning-Tree Required?
Let’s begin with a simple network:
How does this network make a loop? Let’s check out what happens when SW1 gets a broadcast frame:
- Once SW1 gets the frame, it stores the sender’s MAC address in its MAC address table.
- SW1 checks the destination MAC address and sends it to all interfaces in that VLAN except the one that got the frame. So, it sends it to both SW2 and SW3.
- SW2 and SW3 both get the frame and need to do the same thing. In other words:
- SW2 sends the frame to SW3, but not to SW1, since that’s where it came from.
- SW3 sends the frame to SW2, but not to SW1, since that’s where it came from.
- The broadcasts between SW2 and SW3 have now been received. This means that they will also have to forward the broadcasts. In this instance, they should both send the frames to SW1.
- Both SW2 and SW3 broadcast to SW1. So now it’s going to do this:
- Send the broadcast that SW2 has received to SW3.
- Send the broadcast that SW3 has received to SW2.
Until something interrupts the loop, the broadcast messages will continue to propagate over the network. Typically, this occurs when a cable is severed or when a switch crashes due to an excessive amount of traffic. A broadcast storm is the name for this.
Network frames, in contrast to IP packets, do not have a time to live value, which is the reason why broadcast storms occur. Consequently, they will continue to do so indefinitely. It is possible for loops to occur not just with broadcast frames but also with unknown unicast frames. This indicates that you will have a significant number of loops on your network if we do not take action to address the situation. The STP comes into play at this point.
When you have redundant uplinks, you should incorporate link aggregation into your strategy. When it comes to duplicate paths, you may also use layer 3 routing protocols to address this situation, which is the design that is superior in the majority of different scenarios.
How STP Prevents Loops
Switches do not know the topology or each other, unlike in routing. In order to create paths through the network that do not involve any loops, STP allows switches to learn about each other.
In theory, redundant links are blocked to prevent loops from forming and STP finds loops before they happen. The final product is a tree structure that actually spans the network.
A STP BPDU
Data messages are transmitted between switches and are referred to as bridge protocol data units. A BPDU will be transmitted out of an interface via a switch, with the MAC address of that interface serving as the source address of the frame. In addition, they are transmitted using the destination address 01-80-c2-00-00-00, which is the well-known STP multicast address.
A BPDU message can be one of two different types:
- In order to compute STP, configuration BPDU is utilized.
- Notification of changes in the topology is communicated by the topology change notification (TCN) BPDU.
A field that is referred to as the bridge ID can be found in a BPDU. All BPDU messages must include this, which is a value consisting of eight bytes and including the following information:
- Priority –This values from 0-65,535. Set to 32,768 by default
- MAC address –A MAC address is generated by the platform-specific supervisor module or the switch’s internal memory. Nevertheless, it cannot be changed.
Because STP bases its calculations on the bridge ID, it is crucial. These variables are utilized by Spanning-tree to select a root bridge for the network. All of the network’s switches agree on a loop-free topology using the root bridge.
Election for the Root Bridge
In order to select the root bridge, one must first examine the bridge IDs of all of the switches and then select the most suitable bridge. Here, “best” refers to the value that is the lowest.
The following can be said about the election process:
- As soon as the switch is turned on, it presumes that it is the root of the network.
- Both the root bridge ID and the sender bridge ID are part of BPDU’s which are sent by the switch.
- The switch begins to receive BPDU messages and does an analysis on them to determine whether or not a more suitable root is present in those messages.
- It is the switch’s responsibility to send BPDUs that contain the new root bridge ID in the event that a better root is available.
- All switches will continue to go through this procedure until they reach a consensus on the root.
Let’s examine an illustration using our fundamental topology:
At this point, all of the switches have the default priority. That’s why we need to check the MAC Addresses. As the top switch’s MAC address is all a’s which is lowest, so it wins.