Thursday, April 30, 2015

Introduction to Spanning Tree Protocol (STP)

The Spanning Tree Protocol (STP) is a protocol that builds a logical loop-free topology for Ethernet networks. The basic function of STP is to prevent bridge loops. Spanning tree also allows a network design to include spare (redundant) links to provide automatic backup paths if an active link fails. This is done without the danger of bridge loops, or the need for manual enabling or disabling of these backup links, leaving a single active path between any two nodes. 

Spanning-Tree Protocol implements the 802.1D IEEE algorithm by exchanging BPDU messages with other switches to detect loops, and then removes the loop by shutting down selected bridge interfaces. This algorithm guarantees that there is one and only one active path between two network devices.

When you plugged in a cable into the switch port the led above the interface will glow in orange and after a while become green. In this moment spanning tree is determining the state of the interface.

Spanning Tree 802.1W – reduced the number of port states from 5 to 3 by replacing Disabled, Blocking & Listening to Discarding which we will look into the upcoming post.

In the below mentioned diagram we have two switches. The communication from "Computer 1" to "Server 1" is interrupted when the cable between the two switches are broken.  

These switches are connected to each other with a single cable so there is a single point of failure. To get rid of this single point of failure we will add another cable as shown in the below mentioned diagram.

With the extra cable we now have redundancy. Unfortunately redundancy also adds loop into our topology. Why do we have a loop in the scenario above? Let me describe it to you:

1. Computer A sends an ARP request because it’s looking for the MAC address of Server 1. An ARP request is a broadcast frame.
2. Switch A will forward this broadcast frame on all it interfaces, except the interface where it received the frame on (Gi 0/24).
3. Switch B will receive both broadcast frames. (i.e. on Gi 0/1 & Gi 0/2 on Switch B) Now what does Switch B do with those broadcast frames?
4. It will forward it out of every interface except the interface where it received the frame on.
5. This means that the frame that was received on interface Gi0/1 will be forwarded on Interface Gi0/2.
6. The frame that was received on Interface Gi 0/2 will be forwarded on Interface Gi 0/1.

Do you see where this is going? We have a loop! Both switches will keep 
forwarding over and over again until the following happens:

You fix the loop by disconnecting one of the cables.
Enable STP on your switches.

Otherwise One of your switches will crash because they are overburdened with traffic as Ethernet frames don’t have a TTL (Time to Live) value so they will loop around forever. Besides ARP requests there are many frames that are broadcasted.

Spanning-tree will help us to create a loop-free topology by blocking certain interfaces. Let’s take a look how spanning-tree works!

In the above mentioned example we have three switches (Switch A, B & C) with redundancy, this also means we have a loop.

Note: I have simplified the MAC addresses for better understanding

Switch A: MAC AAAA
Switch B: MAC BBBB
Switch C: MAC CCCC

When Spanning tree is enabled, all switches will send a BPDU (Bridge Protocol Data Unit) frame to each other. In this BPDU there are two pieces of information that spanning-tree requires:

MAC address

The MAC address and the priority together make up the Bridge ID & The BPDU is sent between switches as shown in the following picture, The Switch with the lowest Bridge ID is elected as a Root Bridge.

Spanning-tree always requires the Bridge ID to elect a Root Bridge & Path Cost to the Root Bridge is required for its calculation to avoid the loop.

Interfaces and their default cost:

•  10 Mbit = Cost 100
•  100 Mbit = Cost 19
•  1000 Mbit = Cost 4

First of all spanning tree will elect a Root Bridge; this Root-Bridge will be the one that has the best “Bridge ID”. The switch with the lowest bridge ID is the best one

By default the priority is 32768 but we can change this value if we want.
In our example switch A will become the root bridge! Since the priority is the same on all switches the tiebreaker will be the MAC address. Switch A has the lowest MAC address thus the best bridge ID and will become the root bridge.

Switch A has been elected as the Root Bridge and the interfaces Gi 0/1 & Gi 0/2 are designated ports & marked with the symbol “D”The ports on our root bridge are always designated which means they are in a forwarding state.

Since we have elected our Root Bridge, next step for all “Non-Root Bridges" Switch B & Switch C will have to find the shortest path cost to the Root Bridge! The shortest path to the Root Bridge is called “Root port” & marked with the symbol "R". 

The Port Gi 0/1 on Switch B & Gi 0/2 on Switch C is marked as the Root Port "R" as it has the shortest path cost "4" to reach the Root Bridge. 

At this stage we still have a loop, we need to shut down a port between switch B and C to break the loop. So which port STP going to shut down? The one on switch B or the one on switch C?

Since both switches have the same priority but the MAC address of switch B is lower, this means that switch B will “Win this Battle”. Switch C is our loser here. Which means it will have to block its port, effectively breaking our loop!

If you look at the link between switch B and switch C you can see the interface Gi 0/3 of switch C says “ND” (Non Designated). An Non Designated port is blocked! . By shutting down this interface we have solved our loop problem.

Leave your comment below


  1. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!. Jupiter tree company in florida

  2. It is a fantastic post – immense clear and easy to understand. I am also holding out for the sharks too that made me laugh
    Best digital wallet for bitcoin | Digital wallet bitcoin

  3. It is a fantastic post – immense clear and easy to understand. I am also holding out for the sharks too that made me laugh
    Digital asset exchange | cryptocurrency exchange | Best cryptocurrency exchange website

  4. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them
    Blockchain token | Blockchain token exchange

  5. The essayist, through this blog, has earned regard from numerous for all the correct reasons.
    Hobby Plants

  6. Super-Duper site! I am Loving it!! Will come back again, Im taking your feed also, Thanks. buy gradual instagram likes paypal

  7. Such massive archives of actionable instructions also operate within the banyan trees of your nervous system. biodiversity

  8. Thank you for this blog. I have read this and it gives more useful info to me.
    statistics for data science tutorial
    hacking tutorial tips and tricks

  9. Hey there! Nice stuff, please keep me posted when you post something like this! Spice Token

  10. Bonsai tree pots are generally small and shallow to help the tree remain small.
    Tree Trimming El Dorado Hills

  11. This definitely seems to be similar to without doubt amazing. Every one of these minimal things are created by making use of amount of groundwork recognition. I quite like these people noticeably. Tree Cutting Rancho Cucamonga

  12. These sorts of trees have tightened trunks that are straight up. When there are bends in the upstanding trunk, this is viewed as casual in style. Skewed is another tree style.Tree Cutting Oceanside

  13. Judicious trimming can also be good for a tree's own health. Timely trimming prevents breakages before they happen, keeping your home and your trees healthy and happy. Riverside tree removal team

  14. I truly appreciate this article post. Really looking forward to read more. Awesome.
    Tree Trimming services Irvine

  15. To exploit your neighborhood garbage expulsion administration, just examination into their whereabouts either through your nearby registry or the web, and ask with regards to their charge and when they can eliminate your undesirable with van east London

  16. There are many professional tree removal companies that specialize in tree services and tree maintenance to preserve the natural beauty of the landscape and property. tree company

  17. Never pay a tree administration front and center for a task, not so much as a store.
    tree services Columbia MO

  18. • A tree is making primary harm your home tree removal

  19. These things are extremely instructive and critical to know while acquiring gauges for tree work.
    tree trimming

  20. Tree the board all alone may make any injury you or some other individual.
    Tree Company Sandy Springs

  21. Having a bodyguard provides an extra layer of protection in potentially dangerous situations.

  22. They are planned and produced in such a way with the goal that ideal degree of security can be offered.

  23. I'm impressed by the depth of research evident in your posts. It's clear you're dedicated to providing accurate information. Sunshine Concrete Contractor Tampa

  24. ree services encompass a range of professional arboricultural practices aimed at the care, maintenance, and management of trees. These services typically include tree trimming, pruning, removal, stump grinding, and emergency tree care. Arborists and tree care professionals utilize specialized equipment and techniques to ensure the health, safety, and aesthetics of trees in various environments, such as residential properties, parks, and urban landscapes. Effective tree services not only enhance the visual appeal of landscapes but also contribute to environmental sustainability and public safety. more information

  25. Behind the scenes, it diligently prevents loops and ensures seamless data transmission, safeguarding the integrity of our interconnected digital realms. In a world where connectivity is king, STP reigns supreme, orchestrating the symphony of switches and bridges with precision and efficiency. Here's to the unsung hero of networking, Spanning Tree Protocol, keeping our data flowing smoothly and our networks standing tall.

    Panhandle Coatings & Painting Pros