Spanning Tree Protocol (STP) is designed to prevent loops in network topologies by creating a loop-free logical topology, even if the physical network topology contains loops. Here’s a detailed explanation of how Spanning Tree Protocol works to solve loops:
Understanding Network Loops
A network loop is when there are more than one way to link two network devices. And this is the danger of loops:
If you send a broadcast frame, it never stops, it can go round and round and use up all of your data or shut down the network.
If you send the same frame more than once, the network fails here to understand and makes mistakes that then used multiple duplicates of a frame.
Switches’ MAC address tables are continually updated due to the frames they see, and the MAC address table instability we will have when we have a MAC address change in our network. Loops – Loops can make these tables unstable because the same source address may seem to come from multiple ports.
How STP Works to Solve Loops
1) Bridge Protocol Data Units (BPDUs)
STP uses a special type of packet referred to as a BPDU in order to communicate information between switches. The content of BPDUs includes switch ID, port ID and root switch path cost.
2) Electing a Root Bridge
Root Bridge: STP begins as the election of the root bridge. root bridge is used as pivot between all the path calculation. The switch with the lowest bridge ID (a combination of priority and MAC address) becomes the Root Bridge.
Root Port: Each non-root switch will choose one port with the lowest path cost to the Root Bridge. This is called the Root Port, and it is used to get the frames towards the Root Bridge.
3) Designated ports and non-designated ports
Designated Port: On each network segment, the switch with the lowest path cost to Root Bridge will designate one of its ports as Designated Port for that segment. This port forwards frames to and from that segment.
Blocking Ports: All the ports other than Root Ports and Designated Ports will be in blocking state. This configuration will not forward any frames (so no loops) going through the ports you are blocking.
4) State Transitions
Ports have, by default, four states : Blocking, Listening, Learning, and Forwarding.
Bzlocking: The switch will not forward frames but does receive bpdus.
Listening: The port processes BPDUs for Root Bridge and Designated Port election.
Learning: the port at this point starts to learn MAC addresses; it still does not forward frames.
Forwarding: The port forwards frames and learns MAC addresses.
This entire switchover process is performed so that no isolate loops are created at the time of topology change.
5) Topology Changes
STP is constantly looking at the network to verify if any changes are occurring at all times. STP recalculates the spanning tree if a link fails or if a switch is added, and updates the port roles accordingly. It can cause re-elections and state transitions in order to re-create a loop-free topology.
Example Scenario
Example consisting of three triangularly connected switches: A to B, B to C, C to A
Root Bridge Selection: Let’s say Switch A has the lowest bridge ID and becomes the Root Bridge.
Root Ports: If Switch B and Switch C, each identify the port leading to Switch A as their Root Port.
Designated Ports : If Switch B is the Designated Bridge for that segment for the specific VLAN, Switch B’s port towards Switch C is the Designated Port So, the best port in Switch C to reach Switch B is now its port leading to Switch B and it becomes the Designated PortFor the segment (B-C).
Port Blocking: The port to Switch B on Switch C is placed into locked mode to prevent a loop.
With this configuration, despite the physical loops, the logical topology remains loop-free, allowing network operations to take place in a stable and efficient way.
Advantages of Using STP
Stops Network Loops: No More Storm broadcasts or duplicated frames.
Better Network Stability: Maintaining a stable MAC Address Table and ensuring that frames are consistently delivered.
STP Prevents LoopsSTP: does allow redundant links to be used instead of putting them into a loop and causing a broadcast storm.fuji STP Redundancy STP also allows you to have an alternate path for the original 2 parent to get to its child even if 1 core switch failed.
Conclusion
STP prevents network loops by establishing a single, tree-like connection between all network devicesients on the network. Helps also to avoids loops which can lead to problems like broadcast storms, MAC table instability, and provides a loop free network while providing a recovery mechanism to support high availability across the network.