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.
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.
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:
So as you can see, the next stage is to compare the bridge ID. The bridge ID is comprised of 8 bytes:
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).
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.
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 ?
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.
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?
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