10 Replies Latest reply: Apr 22, 2012 10:25 PM by Mr. Akshay J RSS

    STP 4 switches explaination

    Mr. Akshay J


      Please look at the above scenerio.

      I have marked switch1 as the root because all switches tie with priority and switch1 has smallest mac.


      2 and 4 find their directed connected paths as RP.


      Can anyone expalin me how 3 end up having fa0/1 as its blocked port.

        • 1. Re: STP 4 switches explaination
          Mohamed Sobair



          The Designated port  in a non root bridge is selected based on the following criteria:


          1- The port with the Lowest path Cost towards the root bridge.


          2- If there is a tie in (1), choose the port with the lowset Sender Bridge ID.


          3- If there is a tie in (2), choose the port with the lowest port ID.



          As you can see from you example, Switch 3 prefers Switch 4 because Switch 4 has the lowest Bridg-id than Switch 2, and would therefore conside the port connects to Switch 4 as the prefered port.



          Switch-3 recieves the information of the root bridge from two different switches (Switch 3 and Switch 4) , and it selects Switch 4 because of its lowest bridge id.






          • 2. Re: STP 4 switches explaination
            Mr. Akshay J

            I understand 4 is better than 2 so it does not block 4.

            In the link between 2 and 3 why switch 3 had its port blocked and not 2 ?

            • 3. Re: STP 4 switches explaination

              Quick answer:

              It's either because you have adjusted your switch priorities, written the mac addresses down incorrectly, or STP is still converging; else its a bug.


              Long answer:



              As SW3 has an equal cost to reach the root bridge via both paths, there is a tie braker decision that is performed on SW3.  The process is as follows:


              1. Lowest root bridge ID
              2. Lowest root path cost to the root bridge (which is where we are currently)
              3. Lowest sender bridge ID
              4. Loewst sender port.


              So as you can see, the next stage is to compare the bridge ID.  The bridge ID is comprised of 8 bytes:


              • The first 2 bytes = Bridge Priority (defaults to 32768)
              • The last 6 bytes = MAC address.


              So when you consider SW2's bridge ID vs SW4's bridge ID, SW4 will have the lower bridge ID because of the lower MAC address.  This is the deciding factor that should now makes SW3 use Fa0/2 to reach the root bridge; and become the root port.  Unless the spanning-tree is still converging, or you're switch priorities have been adjusted, this is a bug (welcome to packet tracer).




              • 4. Re: STP 4 switches explaination

                Sw 4 has lower MAC address than SW2;


                PT has one flawed with STP, it does calculate and blocks ports correctly but it does not show costs correctly in one of sh spann tree outputs.

                • 5. Re: STP 4 switches explaination
                  just plain old Kev

                      Mohamed is correct

                  • 6. Re: STP 4 switches explaination
                    Mr. Akshay J

                    Thank you all people.

                    But you guys have been telling me why 4 is better than 2.

                    I understand it well that, since they both have equal cost to reach the root, its the bridge ID that decides that switch 4 wins.


                    My questions is specifically for the link between switch 3 and switch 2.

                    Why fa 0/1 of switch 3 is blcoked and not of switch 2 ?

                    • 7. Re: STP 4 switches explaination
                      just plain old Kev

                      To the best of my recollection, it is always the upstream facing interface that spanning tree is dealing with (the one facing upstream to the root), for efficiency's sake.


                      Here is what I think happens...we have designated interfaces fa0/1 on S2 and S4.  Before spanning tree converges, from S3's perspective the cost to get to the root is the same either way.  So THAT switch is the one that has to employ the tie breaker and block the appropriate interface.  Thats the first thing.


                      The other thing is this: lets say spanning did it the other way - S3 is where the calculation happens, but spanning tree actually blocks Fa0/1 on S2.  Now assume there is another switch attached to the left of S3, a frame comes in and what does it do?  S3 might say you can get to the root mac address by going out either of my interfaces.  But if it goes out the top route, its wasting a trip, it will just get blocked.  So it is also more efficient to block Fa0/1 on S3 in the first place.


                      But then, this wouldnt happen because this is the whole point of spanning tree - to have only one possible path to the root switch, and certainly not to direct frames up dead-ends.



                      • 8. Re: STP 4 switches explaination

                        This is because Switch 2 has a cost of 19 to the Root and switch 3 has a cost of 38. It already compared mac addresses of 2 and 4 and decided 4 was the lower of the two so it forwards out that port and blocks fa0/1 to switch 2?

                        • 9. Re: STP 4 switches explaination

                          Hi Akshay,


                          I have edited your original pic to help illustrate my answer.




                          One fast rule about stp. The one with the lowest anything always wins.


                          The bridge advertising the lowest bridge-id in its BPDU's wins the election to become  the root.

                          #Assuming a tie in priority,  bridge-1 wins to become the ROOT based on lowest BID(i.e lowest mac-address in the BID).

                          From then on, bridge-1 is responsible for originating all new BPDU's and sending them out it's designated ports. Other bridges do not originate new BPDU's. The role of non-root bridges is only to receive BPDU'S from the root bridge, process them and forward them out to other non-root bridges.

                          Starting the election from the ROOT switch

                          From the switch 1 perspective it cost 0 to reach the root bridge because _it is_ the root bridge.


                          Then switch 2 and 4

                          From switch 2's perspective the lowest path cost to the root bridge is via port fa0/2  0+19=19 --->This is elected RP

                          From switch 4's perspective the lowest path cost to the root bridge is via port fa0/2  0+19=19 --->This is elected RP


                          Then from swich 3

                          From switch 3's perspective there is a tie in the lowest cost path to the root between fa0/2 and fa0/1.  Both are 19+19=38. The tie breaker to elect the root port is the lowest sender bridge- id. 

                          In our case, lowest sender bridgde-id from switch 3's perspective is from the one received from switch 4,  because switch 4 has the lowest mac address. fa0/2 therefore is ----->elected the RP of switch 3.

                          #Election of Designated ports occurs per broadcast  segment.


                          As stated above, from the roots' switch perspective, all it's segments have designated ports because _it is_ the designated bridge.



                          #TO ANSWER YOUR QUESTION.

                          Broacast segment between switch 3 and 2

                          Switch 3 is advertising _in_ the broacasting segment (marked in blue in the illustration) that it's cost to reach the root bridge is 38(19+19) while switch 2 is advertising _in_the segment a cost of 19(19+0) to reach the root bridge. The lowest always wins, so fa0/1 on switch 2 is --->elected Designated Port for the segment. The rest(i.e fa0/1 on switch 3) is non-designated/ blocking.


                          Now just hypothetically, if we assume that  there was tie between the cost which swich 2 and switch 3  was advertising _in_ the broacast segment,  what factor could be chosen to break the tie? Is it the lowest bridge-id or the lowest sending port-number?






                          Message was edited by: chemilio

                          • 10. Re: STP 4 switches explaination
                            Mr. Akshay J

                            Nice explaination, chemilio.

                            Very helpful !