So in this topology, let’s determine why certain ports are set to forwarding
and why certain points are blocking
so we'll work through the Spanning Tree process.
The first decision that needs to be made is election of root bridge.
So 1 of the switches in the topology
needs to become the root of the Spanning Tree.
So on switch 1 as we saw previously
sh spanning-tree
shows us that this switch or bridge is the root of the Spanning Tree.
Switch 2 is not the root of this Spanning Tree.
So in the output here we can see
that it has a path cost to get to the root switch
it sees that the root bridge or root switch
has the root ID with priority of this
and MAC address of this which is different to the local switch MAC address.
So first decision, how is the root determined?
It's based on lowest bridge ID
which consist of the priority and MAC address.
Switch 1 has the same priority as switch 2, 32769
so that can't be used to determine the Spanning Tree root.
So the tie breaker is based on the MAC address.
so lowest MAC address will win
switch 1 has a lower MAC address when compared to switch 2
once again 0011 is the same on both switches
but notice c6ea is greater and c6ac in hexadecimal
so switch 1 becomes the root of the Spanning Tree.
So that’s the first decision determine who the root bridge is.
Once again priority 32768 is the default.
So we’ve now determined who the root bridge is or root switch is.
The next decision is that every non root switch needs to determine its root port
the root port is at its best port to get to the root bridge.
The root port is chosen based on lowest path cost.
If there’s a tie-breaker on that
then it's based on lowest neighbor bridge ID if path cost are the same.
if that can't be used to determine the root port
then the lowest port priority is used
the port priority is 128 by default
and if that can't be used then the lowest port ID is used as a tie-breaker.
So first decision is based on lowest path cost.
Here’s a table showing you the path cost of Cisco switches
they are either based on a 1998 IEEE cost or 2004 IEEE cost.
In the 1998 cost values, a 10 Meg link has a cost of 100, 100 Meg 19, I gig 4
and 10 gig 2 and the IEEE cost in 2004 and later the cost changed to the following.
So in our topology, we have gig interfaces on the switches
and if we look at the path cost of various ports
notice the value associated is 4
so these gigabit links have a path cost value of 4
which means that the switches are using the old path cost method
to determine the best path to a destination.
now the first decision is to determine the root port based on the path cost
in this topology, we have gigabit 0/0 connected directly to switch 1
gigabit 0/1 is also directly connected to switch 1
gigabit 0/3 is connected to a hub
which inturn connected to switch 1.
So the path cost of gigabit 0/3 would be 8
if there was a switch connected here
but at the moment the path cost is 4 because we have a hub instead of a switch.
So we have 3 ports with the same path cost to get to switch 1.
on switch 2 we can type sh spanning root as an example
and we can see that gigabit 0/0 was chosen as the root port to get to switch 1
but that couldn’t have been determined based on the path cost
it would need to be determined base on something else.
So once again sh spanning-tree
so on switch 2 its chosen gigabit 0/0 as its root port.
Can path cost be used to determined the best path to the root bridge
based on its port numbers and the answer is no
the path cost of this link is 4, the path cost of this link is 4
the path cost of this link is 4
but that can’t be used as the determining factor.
So the next choice is neighbor bridge ID.
Now in this example switch, 2 is connected to switch 1
on 2 ports that are directly connected to switch 1.
so the neighboring bridge ID on both this port is the same
so that cannot be used at as the tie-breaker
the next decision criteria is based on priority
but the priority of the ports are the same
so that can't be used as a tie-breaker.
So the port number is used as the tie-breaker.
1 is a lower number than 2
so hence gigabit 0/0 is chosen as the root port in this topology.
now once the root ports are chosen on a per segment basis
a designated port needs to be chosen.
The easiest way to work this out
is imagine that you have a PC in the middle of this cable
and it needs to get to the root bridge
using either the port on the left or the port on the right.
So if I had a PC in this topology
which port would it used to get to the root bridge
and hopefully, it's fairly obvious
that this port is closer to the root bridge than this port.
and hence on this segment gigabit 0/0 to gigabit 0/0
this port, port 0/0 on switch 1 is the designated port
a designated port is the best port to use
on a per segment basis to get to the root bridge.
So this port is the best port to use on this top segment
to get to the root bridge. What about this segment?
So on this segment imagine once again that you had a PC here
what's it's best port to use to get to the root bridge?
Well it would be this port here on switch 1
and once again on switch 1, we can see that by typing sh spanning-tree
notice gigabit 0/1 on switch 1 is the designated port for this segment.
The same it's true for this segment
which is the best port to use to get to the root bridge?
It's gonna be gigabit 0/3 on switch 1.
And on this segment looking at layer 2 switches running spanning 3
this port is the best port to use to get to the root bridge.
So we've now chosen a designated port for this top link
the 2nd link, these links through the hub as well as this link.
The last remaining link is this link
and the best port to use to get to the root bridge is this port on switch 2.
Any other ports on the network will go blocking.
So this port gigabit 0/1 is put in the blocking state
and so is gigabit 0/3 also put in the blocking state.
Now in Rapid Spanning Tree or Rapid PVST these are known as alternate ports.
In other words, on these hubs as an example, if we have a PC connected to it.
If this link went down
PCs could send traffic into the network using this alternate port
because it would now transition to the forwarding state when this link goes down.