Spanning Tree Protocol
You will get Spanning Tree Protocol out of the box! Its there in your switch or router. In the first place, it saves a networking from being overwhelmed with broadcast messages.
Usually, when networks are designed, redundant connections are used. Its because, if a single connection fails, another one can serve the users. However, problem occurs when one device send a broadcast message like a DHCP or ARP request. As, switches forward broadcast messages to every port, same messages are sent over and over. Due to this, soon a network is flooded with broadcast messages. This is sometimes called broadcast loop death.
To solve this issue spanning tree protocol is used. In this article we will see how this protocol works.
How Spanning Tree Protocol Works
To understand how this protocol works, consider the above network diagram. Though it is a very network diagram, but it will serve our purpose perfectly.
There is redundant connections in above network topology. So when one host broadcasts a message it will be sent infinitely. To solve this problem, STP takes three steps.
- Elect the root – First of all STP select a root for a network. Usually it selects the oldest switch of a network as a root.
- Find the best path to root – After selecting the root, then it find the best path to root for every devices. As a matter of fact, STP considers three criteria when select the best path to root.
- Lowest cost – First of all, STP calculates the cost of every path to find the lowest cost. In this case, higher the bandwidth lower the cost for a path.
- Lower bridge id – If costs for two paths are same, then STP considers bridge id. Bridge id is a identification number. This id is given by STP, which consists of MAC of address of a device with some additional number. STP selects lower bridge id path as best path to root.
- Lowest port number – If both cost and bridge id ties, then STP selects the path with lower port number as best path to root.
- Block whatever is left – After selecting best path to root, STP blocks every other path. This is how STP resolves redundant issue.
Normally STP blocks all redundant path to avoid broadcast loop. But in every two seconds it checks if the best path is okay. If for any reason best is not available, then it opens second best path, which was previously blocked.