Root port election: how does it really work?

daan5000daan5000 Member Posts: 34 ■■■□□□□□□□
Hi there,

I'm studying for my CCNA-certification but I'm really stuck at the STP-topic. I'm using multiple sources to study (Cisco press books, CBTNuggets, Google,...) but they all give different explanations on how the root port is elected. To be specific: how port priority and port number influences the election process.

3 different explanations:

CBTNuggets:
  • If a switch has 2 ports to the root bridge each with different path costs: port with the lowest path cost is root port.
  • If a switch has 2 ports to the root bridge with equal path costs: the port connected to the switch with the lowest Bridge ID, is the root port.
  • If a switch has 2 ports to the root bridge with equal path cost AND both ports are directly connected to the same switch: port with the lowest Port Number, is the root port.
Cisco Press books (LAN Switching and Wireless by Wayne Lewis):
  • If a switch has 2 ports to the root bridge each with different path costs: port with the lowest path cost is root port.
  • If a switch has 2 ports to the root bridge with equal path costs: the port with the lowest port priority is the root port.
  • If a switch has 2 ports to the root bridge with equal path costs AND PORT PRIORITY are the same: port with the lowest Port Number, is the root port.
Omnisecu.com
  • If a switch has 2 ports to the root bridge each with different path costs: port with the lowest path cost is root port.
  • If a switch has 2 ports to the root bridge with equal path costs: the port connected to the switch with the lowest Bridge ID, is the root port.
  • If a switch has 2 ports to the root bridge with equal path costs AND both ports are directly connected to the SAME SWITCH: port with the lowest port priority is the root port.
  • If a switch has 2 ports to the root bridge with equal path costs AND both ports are directly connected to the SAME SWITCH and have the SAME PORT PRIORITY: port with the lowest port number is the root port.
There are some subtle but important differences between each of these explanation. I'd like to know which or if any of these explanations is the correct one.

Thanks

Greetings

Daan

Comments

  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    Even though I know all three should have an identical explanation (Cisco press rarely ever has errors), the third is the most accurate. Port priority is only relevant to the switch calculating the root port if the UPSTREAM switch advertises a lower port priority. If you try configuring port priority on the native switch, it will not work.

    Obviously, port priority and port number are only relevant if the native switch is connected to an upstream switch with two links without logically aggregating them (Etherchannel).

    Here's the list:
    1. Lowest root path cost
    2. Lowest upstream BID
    3. Lowest port priority (Default 128\)
    4. Lowest port identifier (Or port index. They're synonymous)
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • daan5000daan5000 Member Posts: 34 ■■■□□□□□□□
    So this is just plain wrong?



    Thanks for your help.
  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    The problem with this example is that they completed overlooked the neighbor's bridge ID. In this situation, if the bridge IDs were identical on SW3 and SW4, you would assume SW4's MAC address was lower because that's the port SW2 chose as the root port.
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • tomtom1tomtom1 Member Posts: 375
    if the bridge IDs were identical on SW3 and SW4, you would assume SW4's MAC address was lower because that's the port SW2 chose as the root port.

    The bridge ID is seldom identical on 2 different switches, since the STP Bridge ID consists of the priority coupled with the base mac address, which should be unique for each platform. And yes, in your photograph the sending bridge ID is completely overlooked.
  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    tomtom1 wrote: »
    The bridge ID is seldom identical on 2 different switches, since the STP Bridge ID consists of the priority coupled with the base mac address, which should be unique for each platform. And yes, in your photograph the sending bridge ID is completely overlooked.
    Sorry, I meant bridge priority
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • daan5000daan5000 Member Posts: 34 ■■■□□□□□□□
    The problem with this example is that they completed overlooked the neighbor's bridge ID. In this situation, if the bridge IDs were identical on SW3 and SW4, you would assume SW4's MAC address was lower because that's the port SW2 chose as the root port.

    Right but they're saying f0/1 is preferred because that port has the lowest port number. However according to your explanation above, port number is only relevant if the switch is directly connected to another switch using 2 links (without aggregating them). Shouldn't the decision be based on the bridge ID's of S3 and S4? Port numbers should never be considered in this topology.
  • Params7Params7 Member Posts: 254
    I think the example on that book in innacurate. Jeremy does not go that deep in his CDP nugget videos about this, in fact he skips the port priority explanation completely. I just read through the Odom's Cisco Press books chapters 1-2 (STP) like 3 times over and understood this:

    In summary for RP and DP election:
    1. Least Cost path to the Root switch
    2. Bridge ID
    3. Port Priority
    4. Port Number.

    When you're calculating Root Port, Switch looks at all the BPDU it receives. The port on which the frame arrived, Switch calculates the interface cost of that port and adds it to the cost in the BPDU. The interface with the lowest sum cost is elected to be the Switch's root port.

    Now, if two interfaces have the same sum cost, then the factors for tiebreakers are considered on the neighboring switches. Whereas for Designation port, the factors are considered locally.

    For ex. if a Switch has the same root costs on two interfaces, it will check the BIDs of the switch's connected on those interface and from those two neighbor BIDs, the one with the lowest BID - it will pick the interface going to that switch as its Root Port. Now, if two interfaces are going to the same switch, then it will hear the same BID too even down to the same mac address, requiring the Port Priority tiebreaker. In this case, it will consider the port priority value configured on NOT its own interface, but the neighbor's port priority value. If those are the same too, it will consider the port numbers of the neighbor switch again.

    If the fight is for Designated Ports, i.e. two switch's say on a segment that they have a Root Port with the same value, they will check their own bridge IDs as the tiebreaker. The one with the lowest Bridge ID will get to have its interface as DP on that segment. If its comes to Port Priority and Port Number tiebreakers, in this case again local interface values are considered.


    Correct me if I'm wrong, at least that's what I've understood from Cisco Press's book.
  • Params7Params7 Member Posts: 254
    Well, nothing like verifying it on real switches right? This post is long but it served as good revision of STP for me and maybe it will for you. I don't have real hardware, but I do have GNS3 with linux layer 2 switch emulation.

    IOU1 = Switch 1, OU2 = Switch 2 and so on... also mac address numbers scale up with the switch number, so to begin with SW1 has the lowest mac address value.

    Given these 4 L2 Switches:

    image.jpg

    Which switch will become the Root Switch? Switch 1 as it does have the lowest MAC. As soon as I bring up the trunk lines, SW1 does become the root.

    Now focus on SW3. It will need to elect a root port out of two interfaces on which it will receive BPDUs - Et0/0 and Et0/1. And the costs in those BPDUs will be exactly the same (value of 100, I checked). So predict what tiebreaker will SW3 then use to elect its own Root Port? Bridge IDs. The NEIGHBOR BID to be exact. So it will compare the BIDs it receives from its Et0/0 (going to SW2) and Et0/1 (going to SW4).

    image.jpg

    SW2 has the lower BID. It selects Et0/0 as its RP.


    On the link between SW3 and SW4; SW4 says that it has a Root Port with cost 100, SW3 says that it has selected Et0/0 as its Root Port with cost 200. SW4 having the lower Root Port value, wins the Designated Port election. SW3s Et0/1 is neither RP or DP, so it will go in block mode.


    Now I wanted to further verify DP election by adding a 5th Switch to the mix. I haven't connected it yet, but it thinks it is the root switch. Its going to get a dose of reality as soon as I connected it to SW4 and SW3. The red lines show how I will be connecting it to the LAN:

    image.jpg

    Now every Switch MUST have have Root Port. That is one of the commandments of STP. So, which port do you think SW5 will elect as its Root Port? Well SW4 will send a BPDU to it with a cost of 100, SW3 will send a BPDU with a cost of 200. So, it will select the interface going to SW4 as its Root Port.

    Which it does.

    Another commandment of STP says on every segment there must also be a Designated Port (DP). So on the segment between SW3 and SW5, there must be one DP. Well, SW5, when accepted the link going to SW4 as its Root Port, comes up with a Root cost of 200. SW3 has a Root Cost of 200 as well. Makes sense because both have to hop across 1 more switch to get to the Root (and links are of the same speed throughout).

    So both, on the link between SW3 and SW5 try to become the DP by saying I have a Root Port cost of 200. But they both tie. So the BID tiebreaker will come in. The BID values considered here will be LOCAL/NATIVE. SW3 has the lower BID (lower MAC address). So SW3's interface will become the DP and SW5 will have to put its interface in that segment into Blocking mode.

    That it does, as you can see:
    image.jpg




    Now what if both of them had the same BIDs? what if some noob intern with an A+ connects SW5 to SW3 on two different interfaces, which are not etherchannel. Like this:

    image.jpg


    SW5 will have to pick a Root Port, but it will receive the same cost BPDUs on both its interface as it is coming from the same switch. Tiebreaker will go down to the Bridge ID of the switch connected to its interfaces, but it will receive the same exact BIDs. Tiebreaker will then go down to the Port Priority of the neighbor (SW3) interfaces again, which is 128 (default), so that will tie yet again. So final tiebreaker will go down to the interface numbers of SW3. In other words, SW5 says: I will pick the interface to be my Root Port which connects to the lowest interface number on SW3.

    So, Et0/2 is lower than Et0/3. SW5 will pick Et0/1 as its Root Port.


    image.jpg


    Coming to DP election on the other link, SW3 has the lower Root Port cost compared to SW5 now, so it wins the DP election on that link.

    I wanted to verify how RP/DP is elected. Basically as I was able to gather from the Cisco Press book, RP/DP use the same tiebreakers. From BID to Interface number - the values are looked at on the neighboring switch while for electing the DP the values are considered from the local switch.


    edit: apologize for the choice of image host there. Hopefully learning about STP will be more distracting.
  • OfWolfAndManOfWolfAndMan Member Posts: 923 ■■■■□□□□□□
    daan5000 wrote: »
    Right but they're saying f0/1 is preferred because that port has the lowest port number. However according to your explanation above, port number is only relevant if the switch is directly connected to another switch using 2 links (without aggregating them). Shouldn't the decision be based on the bridge ID's of S3 and S4? Port numbers should never be considered in this topology.

    You are correct. This topology makes the PID trivial in this case
    :study:Reading: Lab Books, Ansible Documentation, Python Cookbook 2018 Goals: More Ansible/Python work for Automation, IPSpace Automation Course [X], Build Jenkins Framework for Network Automation []
  • davenulldavenull Member Posts: 173 ■■■□□□□□□□
    A switch makes this decision based on information in BPDUs it receives. To sum up what Params7 said above:

    For root port election
    1. Prefer an upstream switch with a lower cost to root bridge. If multiple ports receive BPDUs with the same cost:
    2. Prefer the neighbor with the lower bridge ID. If the bridge ID is the same (i.e. ports are connected to the same upstream switch not in etherchannel):
    3. Prefer the port that received a BPDU with a lower Port ID where Port ID is a combination of Port Priority and interface number.

    This last part is what was confusing for me because it was not emphasized in either cbt nuggets videos or books.

    Designated port election follows exact same process except it shouldn't get to the 3rd tiebreaker.
  • Jon_CiscoJon_Cisco Member Posts: 1,772 ■■■■■■■■□□
    Sorry I did not have time to read this thread so this might not be relevant. However I found this post to be most useful in understanding STP.

    http://www.techexams.net/forums/ccna-ccent/97465-stp-question.html
Sign In or Register to comment.