Spanning Tree Primer
What is spanning-tree, what is the purpose of this protocol, where does it work?
These questions are easy to answer. Spanning-tree is a layer 2 ethernet loop prevention protocol which operates on Ethernet switches, there that’s it, nothing else stop. That’s all that spanning-tree does.
Why do we need this protocol? Imagine a network with two layer 1 hubs connect together via a pair of Ethernet cables and a P.C connected to each of the hubs. When either of the P.C’s sends any communication onto the wire the connected hub will flood the data out of both interfaces towards the other hub, the receiving hub will then forward the received communications to the P.C and back around to the other interface back to the original hub, this communication will continue around the network until one of the links are removed, this is known as a loop, sometimes also referred to a broadcast storm.
Broadcast storms are fatal your network leading to outages for both voice and data. We no longer use hubs on modern networks, we normally employ switches due to their functionality and features, the one major feature of a layer 2 switch is spanning-tree.
Now imagine the same network as described above with two switches instead of two hubs. Now rather than all four ports being in the forwarding state spanning tree will determine via various elections and weightings to block a single port in our little topology, now when either of the P.C’s connected to the switches send a broadcast onto the wire there will no longer be any looping traffic due to the blocked port.
We have to learn how spanning-tree decides which port or ports it has to block to prevent a loop or loops from occurring on our network.
The first thing to do to understand spanning tree is to imagine this, you leave your house to got to the office, at the junction at the top of the road you stop, do you turn left, right or go straight on?, your decision as to which path to choose is made based on your knowledge of the location of the office.
STP works in the exact same way, spanning-tree will elect a device to act as a reference point, this reference point will be advertised across to other spanning-protocols on other switches, when a switch receives the reference point on more than one port it will decide which port is more preferable based on link values such as link bandwidth, port priority and port number. Once the switches in the network decide which ports to forward and which to block STP has done it’s job.