Jump to content
  • entries
    9
  • comments
    3
  • views
    2,861

Basics of STP and the root bridge election

BSpendlove

2,502 views

The 'wonders' of 802.1D... This is just a quick blog to discuss the CCNA level of the process of how switches in an ethernet LAN will elect the root bridge and a few other details.

 

Firstly, Spanning Tree Protocol (STP) is? Simply, a way to create a logical 'loop free' network in our LAN by blocking specific ports that could cause a frame to loop indefinitely in our network. I'm assuming you have a basic understanding of STP because that would be required to understand the basic root bridge election.

 

Getting straight into it, when you connect 2 or more switches together they will begin the process of the 'root bridge election' which can change the way frames are sent in the network or even in different VLAN's. Take a look at the example below:

 
de28d7_c17c0a7dd18045dead4c66ba3bbcbbb9~

 

 

Imaging we had no such thing as STP, the basic example shown is a broadcast has been sent from PC0 to SW1.

 

SW1 with basic switching functionality, will broadcast the frame out of all ports except the one that received the original frame, this seems very normal so far. In short story, the switches will broadcast the frame out of ports the original wasn't received on so it will be going back and fourth until someone literally comes over and literally turns the switch off, it seems extreme but remember that the switch will not broadcast that frame out of the port it was received but SW1 received a broadcast from both SW2 and SW3 (so SW1 will then broadcast the frame from SW2 out fa0/2, and the frame from SW3 to fa0/1)

 

 

So in a short story, STP will block redundant links to stop these frames from looping. You could have the switches daisy chained but that defeats the whole purpose of redundancy and that if we had multiple switches (SW1 -> SW2 -> SW3 -> SW4), if SW3's link were to go down, people connected to SW1 and SW2 wouldn't be able to talk to people on SW3 or SW4.

 

 

So what is this 'Root bridge election' or what is a root bridge?

 

When I first looked at the root bridge, I thought to myself does all the traffic need to go to the root bridge before being forwarded to the destination? Because that seems impractical! Of course, it was the first time I've encountered STP and I wasn't 100% wrong sort of... (but close to it!).

 

The path towards the root bridge from other switches are commonly the fastest (or least cost) which can be changed. The easiest way I would explain why the root bridge is needed would be along the lines of: "The root bridge allows other switches to have a destination to decide which ports to put in forwarding and which ports to block, by default the least cost (fastest path/speed) would be a preferred path to the root unless you manually configure things like costs and priority...."

 

Traffic will not need to travel to the root bridge first, unless it needs to travel in that direction or is the only way to get to the destination. We will talk about the different port roles and types for STP a little bit later.

 

 

Bridge Election Process

 

The bridge election process begins with switches exchanging messages, the Hello BPDU (Bridge protocol data unit) formally known as a configuration BPDU (a lot of people may call it a hello, because it is being sent over and over again like most Hello's in other protocols, excuse me while I refer to it as a hello BPDU for now...).

 

The Hello BPDU will be used to compare on each side of the link and exchange information such as:

 

Root Bridge ID, Sender Bridge ID, Path cost to root, Port ID and Timers (MaxAge, Hello and Forward Delay). The BPDU does contain more fields, but these are the important ones for now.. (Protocol ID will be 0x000 for IEEE 802.1D)

 

 

 

I believe the main focus in the CCNA is firstly focusing on the Bridge ID (BID) and what forms it. The BID is a field in the BPDU which is 8 bytes. Split into 2 parts:

 

  • Priority = 2 bytes (divided into 2 parts: 4bit Priority + 12bit VLAN ID) (interesting fact (2^12 = 4096 VLAN's anyone?)

  • System ID Ext (MAC Address) = 6 bytes

Without no configuration, we have some default values in our BPDU that are generated on switches. Such as:

  1. Each switch will think it is a root since no root has been elected yet...

  2. Each BID priority will be 32768 (VLAN1 = 32769 etc...)

  3. Hello Timer is 2 seconds default

  4. Forward Delay is 15 seconds by default

  5. Max age is 20 seconds by default

 

So upon BPDU messages being exchanged, what will happen since the BID priority is the same? If that ties, then it will move onto comparing the System ID (MAC Address) and will always elect the switch with the lowest MAC address as the root as shown in the example below:

 

 

 
de28d7_9c623d59e9794541a6a023eba9f1ce8f~

 In this example, we see that SW3 actually has a lower BID which then tells us that it will become the root in this election process. Ok so are BPDU's still exchanging after this simple process? Yes of course! BPDU's are actually generated from the root and will be sent down the topology similar to the picture below:

 

 
de28d7_a06c2efcd0e247fca38911be76230a41~

 

You can see that the path cost is added to as the basic 'BPDU' is sent down(logically) from the root but where do these numbers come from? STP (1998) has values which I believe you may need to remember for the CCNA exam such as:

 

10Mbps cost 100, 100Mbps costs 19, 1Gbps cost 4, 10 Gbps cost 2

 

 

Now that the root election process has finished, that is pretty much all done? You'd be wrong in not wanting to learn more! Since the previous examples don't really show STP's capabilities of making sure the network is loop free, let's add a redundant link in our switched LAN from SW1 to SW. The image has been changed slightly to make it easier to talk from the logical topology view (remember SW3 is still the root!).

 

 
de28d7_af8aaf26015e48179cfa77bf66e41e19~

 

So a redundant link has been added and BPDU's have been exchanged but wait... It seems that we understand one of the first values compared in the BPDU is the root bridge ID. SW3 and SW2 will both send a BPDU with the same Root Bridge ID?? Is the switch going to freak out? Is STP going to break? Of course, that would be a poor design if it did but it simply moves onto the next value to compare...

 

Sender Bridge ID - Is the Senders BID lower than mine? No.... Simply move onto the next parameter. Cost....

 

SW1 root path cost using gi0/1 will be 4

SW1 root path cost using fa0/1 will be 23 (because it needs to also add the cost to get to the root from the SW2 gigabit connection)

 

 

Port Roles and States

 

After the switch has completed this new election process with the new redundant link, we can move onto the next stage of the STP process. STP defines port roles and states to be used by root and nonroot switches. The root switch will simply put all ports in the designated role and states will be in forwarding mode (FWD), so lets focus on non-root switches.

 

Every non-root switch must have a root port which essentially is the lowest cost to reach the root switch. SW1 has made g0/1 the root port since it is a STP cost of 4 rather than f0/1 which would be a cost of 23.

(sorry about hostname, this was issued on SW1)

 
de28d7_ff6c5aab54e44ea8a94e153f560cc187~

 Because the Root switch will generate BPDU's that are then sent down from the topology, each switch will add the cost on the BPDU before sending it out.

 

  • The BPDU sent from SW3 to SW2 is 0 then SW2 will add a cost of 4 then will be resent to SW1. SW1 will receive it on port f0/1 and will add a cost of 19 creating a total of 23.

  • The BPDU sent from SW3 to SW1 is 0 then SW1 will add a cost of 4 then will be sent to SW2. SW2 will receive it on port f0/1 and will add a cost of 19 (23) which is a worst path than g0/2 to root.

As you can see in the #show spanning-tree. It also lists on SW1 that interface fa0/1's role is Desg (Designated).

 

The designated role will be the port that advertises the lowest path cost to a LAN segment. Of course, ties will occur which will result in the BID's being compared and the lowest BID will be chosen. All other ports that are not a Root or Designated will be transitioned into the 'Blocking'(BLK) state as shown on SW2:

 

 
de28d7_8d61e0173d0b4d6480b9b7444fa61aa3~

 

 

 

In the next blog on STP, we will talk about STP convergence, 802.1w (RSTP), PVST+, Configuring them all and tweaking STP values such as priority, cost, also I will go into depth on STP port roles and states etc.. I will be replicating this topology with 3 Cisco 2950's instead of using Packet Tracer. (PS, I wrote this on my actual blog but thought I might aswell upload it here, sorry if any formatting issues occur!)

0 Comments

There are no comments to display.

×