In a Layer2 network it is critical that a logical loop-free topology is established before data could be switched through the network. The first step within this process is to determine a root bridge – the root of the spanning-tree.

Within a Layer2 network it becomes very important to keep the topology scalable and predictable – it makes sense therefore to ensure the root-bridge election is driven by the administrator. For instance, it is best-practice to host the root-bridge within the distribution layer. If you do not intervene, chances are you will end-up with the root-bridge elsewhere.

The root-bridge will always be the bridge advertising the smallest Bridge-ID. Therefore, all we need to do is tweak the Bridge-ID, right?

 

The BridgeID is a composite 8 Bytes value as below:

Note that later, the bridge priority field was split in two so that the VLAN-ID could be integrated to allow different BRIDGE-IDs per VLAN.

bpdu-priority-id

When determining the Bridge-ID, STP will consider the following, in this exact order of preference:

  1. Smallest Bridge Priority (default priority is set to 32768)
  2. Smallest MAC address

So in order to tweak the BridgeID we are left with two options:

  1. we find out the mac-addresses of all switches and place our root bridge (switch with smallest MAC address) accordingly – this is not very pragmatic and certainly not scalable either. What happens if the switch with the smallest MAC address is the one offering the least performance – do you want that as a root bridge? Or what if at a later stage we introduce a new switch with a smaller MAC address?
  2. another option is to manually set the bridge-priority – we do so with the command spanning-tree vlan <vlan-id> priority <priority>. You could even setup the priority as 0 (zero) so that the switch is always set as root, regardless of the MAC address, unless there is another switch also set with the same priority
  3. at last, we could also use IOS preset macros – spanning-tree vlan <vlan-id> root {primary | secondary}

 

CAVEATS ...
  1. From the diagram above you can see that the priority can only be a value multiple of 4096. The IOS will throw an error should you try to set the priority otherwise
  2. the command/macro spanning-tree vlan <vlanID> root {primary | secondary} doesn’t do miracles! You shouldn’t really run into problems when using the primary keyword; however, when using the secondary keyword, the switch will *try* to set the 2nd best priority!

But how would the switch know the 2nd best priority – remember that at any one time, once the topology has sync’d, each switch would only know of its own and the root’s priorities!

 

Examples …

stp-bridge-id-01

screenshot10

 

 

 

Notice the priority value (32778) which is 32768 (Default Priority) + 10 (VLAN ID).

Also, you can see that the root bridge is the switch with the mac of 000c.8581.1e80, aka. SWITCH3 – since all priorities are equal to the default values, the MAC address determines the root bridge.

Next, still on SWITCH1 and set it to become the secondary root-bridge – now watch this!

screenshot12

Notice that although we’ve used the secondary keyword, what actually happened was that the priority was decremented twice (4096 * 2). This in turn caused this bridge to have the lowest priority value among all other switches – hence it became the root-bridge!

The switch does not check all other priorities and therefore it cannot set the 2nd best priority!

Now we go on SWITCH3 and …

screenshot13

 

 

 

 

 

… SWITCH3 now became the root!

When the primary keyword is used, the switch will know what the best priority is at that time – it is therefore able to set a lower value.

Now let’s try setup the priority to a *non-multiple* of 4096.

screenshot14

You can clearly see that the switch won’t allow you since the value is not valid.

At last …

Whenever you are chaining the L2 topology, you will be triggering STP recalculation – this equates to an outage which could go for as long as 50 seconds!!!

 


Thank you,
Signature
View Rafael A Couto Cabral's profile on LinkedIn



Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>