cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
12202
Views
9
Helpful
7
Replies

STP question

tinhnho123
Level 2
Level 2

Hello Guys,

I found an article about how STP works from other site below:

STP uses the following criteria to decide whether to place a port in a Forwarding state or Blocking state

  1. STP elects a Root Bridge, and then puts all its working interfaces in a Forwarding state
  2. All other switches are now non–root switches. STP now looks at all the Root Ports from these switches, and finds the one with the Least Cost. Once this is found, STP places that interface in a Forwarding state.
  3. Now STP finds all the Designated ports on the non–root switches, and places them in a Forwarding state.
  4. Then STP places all other ports in a Blocking state.

Let's say I have 2 up-link ports from my access switch to my distribution switch as it's using STP, one port is in forwarding and one port is in blocking state, the author says the least cost port will place in forwarding state. How do I find the cost of these ports? or What command to verify their costs? Thanks.

 

 

 

2 Accepted Solutions

Accepted Solutions

Guru Mysoruu
Level 1
Level 1

STP Path Selection

Spanning tree builds the tree structure attempting to use the fastest links it has available for the active paths. STP uses the following steps to select its paths:

  1. Lowest root bridge ID (BID)
  2. Lowest path cost to the root
  3. Lowest sender bridge ID
  4. Lowest sender port ID (PID)

STP Definitions

Bridge ID – bridge priority + MAC Address

Bridge Priority – 0-65,535

Default Priority – 32,768

Port ID – port priority + port number

Port Priority – 0-240 (default is 128, increments of 16)

Path Cost – The cumulative cost of all links between the switch and the root bridge

 

STP Convergence

1. Root bridge election
Each VLAN elects one root bridge. All ports on the root bridge act as designated ports, which send and receive traffic as well as BPDUs. The bridge with the lowest priority becomes root.

2. Root ports are determined on all non-root bridges
Each non-root bridge is assigned a single root port that sends and receives traffic. The root port is chosen based on the port with the lowest-cost path between the non-root bridge and the root bridge. If two paths are equal cost, the port with the lowest port ID (priority + port number) will win.

3. Designated port selection
Each segment has a single designated port. Designated ports are chosen from non-root ports that have the lowest path cost to the root bridge. In the event of a tie, the bridge ID acts as a tiebreaker (lowest wins). All ports on a root bridge are designated ports.

 

Regards,

Gurudath K S

View solution in original post

paul
Level 1
Level 1

Your step 1 is fine. Step 2 should be "the root bridge (just like any other bridge in the network) checks to see if it has more than one port on any given, single LAN segment, and if it does, makes the port with the highest port priority the designated port for that segment, putting all other ports on that segment into blocking mode."

Step 2.5 should be: "Each non-Root Bridge looks to see if it should have a Root Port. It does so by checking all BPDUs it has received on all ports, and selects among those, the ports that have the best Root Path Cost. Among those ports, the port with the lowest Port ID becomes the Root Port." That is, if it's a bridge. If it's a Cisco switch, instead, step 2.5 should read: "Each non-Root Bridge looks to see if it should have a Root Port. It does so by checking all BPDUs it has received on all ports, and selects among those, the ports having the lowest Root Path Cost. Among those ports with the lowest root path cost, it selects the port that has received the lowest port ID as the Root Port; the other ports on that LAN segment are put into blocking mode."

Step 3 is close enough; good by me. Likewise, step 4.

The answers below are pretty much correct, but the response from Raveesh needs some further explanation. The figures he has enlarged are not the root path cost for that bridge. For that, you have to look further up int the screen dump to see the section that says "Root ID" and under that, "cost." The root path cost to the root bridge, meaning the fastest path to the root bridge is that cost figure, 23. You can ignore all the path costs associated with the various ports and interfaces as the "least-cost-path" has already been factored into the "cost" figure representing the bridge's root path cost. Cost is only calculated on ports incoming in relationship to the root bridge, and the port costs don't tell you which one of those ports is the root port.

All you CAN know is the individual port path costs, and the bridge's total root path cost. The Root path is stated in the output as Fa2/0/27, with a cost of 19, a 100 Mbps port. Likewise, the bridge's designated port has a cost of 4, making it a gigabit port. The cost of port Fa2/0/27 is already factored into the root path cost of 23, so no higher math required. We can also state that if the bridge was directly connected to the Root Bridge, the "cost" for the root bridge would be zero. So, we can conclude that if 19 is the cost of the root port, and 23 is the root path cost for the bridge, then there is another bridge between this bridge and the Root Bridge, and it connects to the Root Bridge (23-19=4) via a 1 Gbps link, or perhaps two 10 Gbps links. I'd bet on the single 1 Gbps link, though.

Paul 

View solution in original post

7 Replies 7

Hi,

Output of below commands will let you know about the cost of ports configured

show spanning-tree

show spanning-tree blockedports

show spanning-tree detail

 

However for brief understanding refer to the below link.

http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2950/software/release/12-1_9_ea1/configuration/guide/scg/swstp.html#wp1105354

 

Regards,

Venkatesh.

ALIAOF_
Level 6
Level 6

More bandwidth interface has lower the cost.

So on a Gig interface it is 4, on Fast Ethernet it is 19.

Now if you have two interfaces connected and they are both Gig Interfaces then the tie gets broken by the Port Priority + Port Number.

 

So 128.11 will be preferred over 128.12 if you do "show spanning-tree interface gigabitEthernet x/x" or "show spanning-tree" you can find out.

Rajeev Sharma
Cisco Employee
Cisco Employee

Hey,

Use the show spanning-tree command to verify the cost associated with ports. I am adding a snippet from my switch:

WS_C3750V2-48PS#sh span vlan 165

VLAN0165
  Spanning tree enabled protocol ieee
  Root ID    Priority    32933
             Address     0024.98ec.dc80
             Cost        23
             Port        85 (FastEthernet2/0/27)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32933  (priority 32768 sys-id-ext 165)
             Address     a40c.c3ee.1500
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  15  sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa2/0/26            Altn BLK 19        128.84   P2p
Fa2/0/27            Root LIS 19        128.85   P2p
St2                 Desg FWD         128.873  P2p

HTH.

Regards,
RS

Guru Mysoruu
Level 1
Level 1

STP Path Selection

Spanning tree builds the tree structure attempting to use the fastest links it has available for the active paths. STP uses the following steps to select its paths:

  1. Lowest root bridge ID (BID)
  2. Lowest path cost to the root
  3. Lowest sender bridge ID
  4. Lowest sender port ID (PID)

STP Definitions

Bridge ID – bridge priority + MAC Address

Bridge Priority – 0-65,535

Default Priority – 32,768

Port ID – port priority + port number

Port Priority – 0-240 (default is 128, increments of 16)

Path Cost – The cumulative cost of all links between the switch and the root bridge

 

STP Convergence

1. Root bridge election
Each VLAN elects one root bridge. All ports on the root bridge act as designated ports, which send and receive traffic as well as BPDUs. The bridge with the lowest priority becomes root.

2. Root ports are determined on all non-root bridges
Each non-root bridge is assigned a single root port that sends and receives traffic. The root port is chosen based on the port with the lowest-cost path between the non-root bridge and the root bridge. If two paths are equal cost, the port with the lowest port ID (priority + port number) will win.

3. Designated port selection
Each segment has a single designated port. Designated ports are chosen from non-root ports that have the lowest path cost to the root bridge. In the event of a tie, the bridge ID acts as a tiebreaker (lowest wins). All ports on a root bridge are designated ports.

 

Regards,

Gurudath K S

Very interesting, but I have one question for you. Let's supposes that we're not talking about switches here, but real bridges, and let's further suppose that the root bridge has more than one port on a single LAN segment, as does another bridge; both have two ports each, total 4. Speaking from the perspective of the Root Bridge: Aren't you missing a step in between steps 3 and 4, that is, "How do I decide which of my ports should be a designated port, in forwarding mode, and which port(s) should be in blocking mode?"

Now taking that one step further, connecting two switches together, with each switch having two ports (why not 10, even?) plugged into a hub that is common to the two of them. Once again, once the Root Bridge is decided, how does the root bridge decide on which of its designated ports should be in forwarding mode, and which should be in blocking mode? The decision of designated ports in forwarding or blocking mode has nothing to do with any other bridge on the segment; it's exclusively internal to the Root Bridge. Again, you need a step between 3 and 4 to answer that question.

Now taking the process to its logical end, two switches interconnected, each with two ports connected to the other. That step between 3 and 4 becomes moot because each switch port is a separate and distinct "bridge" sharing a common broadcast network, but separate collision domains.

Here's where I get heartburn. Since each port on the so-called Root Bridge is actually a separate collision domain, while sharing a common broadcast domain, it isn't possible for the Root Bridge to "see" both ports as "sharing a common LAN segment," because even though logically, they do, and physically, they don't. So the step between 3 and 4 normally taken by bridges is ignored by switches. So the Root Bridge ignores the issue, makes both ports designated, and leaves it up to the next group of bridges outwards from the Root Bridge to sort it out as they struggle with the question of "which port should be the Root Port?"

This is where the implementation of 802.1d gets lost. The Root Bridge (switch) is not taking responsibility for determining whether or not two of its ports reside on the same physical LAN segment, or not, something it could easily do by simply noting that a frame sent out one port comes in on another. A bpdu, for example for port a would come in port b, and the bpdu for port b would come in port a.

Because the Root Bridge doesn't shut down one port (which it should), the other bridge (switch) on that segment has to decide which of its two ports should become the Root Port while the other is blocked. I can't find in 802.1d-1998 anywhere it describes this situation, or proposes that the "solution" is for the non-Root Bridge to decide to keep up the port "connected to the lowest port id on the other guy" and make it the Root Port, and put into blocking mode "any other ports on that LAN segment." It can't, because according to 802.1d-1998, the Root Bridge should, after selecting the Designated Port, put into blocking mode any "inferior ports" on the same segment.

I just want to know where the authority for making the non-Root Bridge responsible for which, among the many possible, redundant Designated Ports on the Root Bridge which share the same physical and logical LAN segment, comes from, and why wasn't the simple expedient of allowing the Non-Root Bridge (switch) look at the ports IT has on the same LAN segment, then shutting down all but the lowest port ID port?

You have no idea how convoluted this all becomes in the eyes of students trying to figure out why 802.1d and the Cisco implementation of STP - even up to and including the 802.1t changing of the number of bits in the bridge priority - are so different. And, why, wherever they turn for answers, they get opinions, and not facts. And yes, I did follow the link noted above, and, thankfully, it did use bridges to illustrate its points, but totally passed over the question of port priority altogether except to note that it was in there, but not how it influenced any decision(s).

RSTP seems to have seen this situation, and cringed. The designate "edge Ports" as either being point-to-point, or, wisely, finally, as "possibly interconnected with other ports on the same bridge, sharing a common LAN segment, broadcast, and collision domain through a hub (god forbid!), so let's call them a "shared mode port" and put the rest of this mess to bed for the last time." Ah, relief, finally. And recognition that the earlier implementation of STP was flawed, and jury-rigged to work by inventing steps not specified in 802.1d, in fact, ignoring steps that should have been incorporated, but seemingly weren't, necessitating the invention of new ones.

Which raises the far more important question: why is Cisco still testing on STP when its been deprecated since 2004, and RSTP is up and running? Not to mention the inconsistencies between 802.1d-1998 and Cisco's use of it?

Thank you for listening to my rant...

addition and clarification to the above,

 

Regarding Root Port election:

1- Elected based on lowest root path cost (cumulative cost of all links to get to the root bridge)

2- If tie in cost then:

a- Choose lowest upstream Bridge ID. 

b- If the Bridge is the same ( two links connected to the same Bridge) then choose lowest upstream port ID (Be very carful here, the port ID of the "UPSTREAM Bridge",  do not use port ID of the port you electing but the port id of the port that facing it). I wanted to clarify this point as it's widely miss understood.

 

paul
Level 1
Level 1

Your step 1 is fine. Step 2 should be "the root bridge (just like any other bridge in the network) checks to see if it has more than one port on any given, single LAN segment, and if it does, makes the port with the highest port priority the designated port for that segment, putting all other ports on that segment into blocking mode."

Step 2.5 should be: "Each non-Root Bridge looks to see if it should have a Root Port. It does so by checking all BPDUs it has received on all ports, and selects among those, the ports that have the best Root Path Cost. Among those ports, the port with the lowest Port ID becomes the Root Port." That is, if it's a bridge. If it's a Cisco switch, instead, step 2.5 should read: "Each non-Root Bridge looks to see if it should have a Root Port. It does so by checking all BPDUs it has received on all ports, and selects among those, the ports having the lowest Root Path Cost. Among those ports with the lowest root path cost, it selects the port that has received the lowest port ID as the Root Port; the other ports on that LAN segment are put into blocking mode."

Step 3 is close enough; good by me. Likewise, step 4.

The answers below are pretty much correct, but the response from Raveesh needs some further explanation. The figures he has enlarged are not the root path cost for that bridge. For that, you have to look further up int the screen dump to see the section that says "Root ID" and under that, "cost." The root path cost to the root bridge, meaning the fastest path to the root bridge is that cost figure, 23. You can ignore all the path costs associated with the various ports and interfaces as the "least-cost-path" has already been factored into the "cost" figure representing the bridge's root path cost. Cost is only calculated on ports incoming in relationship to the root bridge, and the port costs don't tell you which one of those ports is the root port.

All you CAN know is the individual port path costs, and the bridge's total root path cost. The Root path is stated in the output as Fa2/0/27, with a cost of 19, a 100 Mbps port. Likewise, the bridge's designated port has a cost of 4, making it a gigabit port. The cost of port Fa2/0/27 is already factored into the root path cost of 23, so no higher math required. We can also state that if the bridge was directly connected to the Root Bridge, the "cost" for the root bridge would be zero. So, we can conclude that if 19 is the cost of the root port, and 23 is the root path cost for the bridge, then there is another bridge between this bridge and the Root Bridge, and it connects to the Root Bridge (23-19=4) via a 1 Gbps link, or perhaps two 10 Gbps links. I'd bet on the single 1 Gbps link, though.

Paul 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco