1

The spanning tree protocol uses the bridge ID and the MAC address of the switch to elect the root bridge. After the election process, a spanning tree is created, preventing switching loops by assigning port roles like root, blocking, and designated.

However, the root bridge selected may not be the optimum root bridge because it's simply selected based on the MAC and the bridge ID.

From what I know' the root bridge is supposed to be in the center of a network (literally the center where it can reach all other switches with a least cost) and it should have an average of the least number of hop counts to destinations. Are there mathematical algorithms used to find the optimal root bridge of a spanning tree, disregarding the bridge ID and the MAC address of the switches?

4
  • 1
    "The Spanning tree protocol uses the Bridge ID and the MAC address of the switch to elect the root bridge." It uses the configured Priority and MAC address to create the Bridge ID, and it uses the Bridge ID to elect the root bridge. "Each VLAN on the switch has a unique 8-byte bridge ID. The 2 most-significant bytes are used for the switch priority, and the remaining 6 bytes are derived from the switch MAC address."
    – Ron Maupin
    Commented Sep 20, 2017 at 19:11
  • @RonMaupin Thanks,but that doesn't answer my question.Yes the priority+the MAC are used to create the bridge ID. However using them doesn't necessarily give us an optimum root bridge does it?
    – Deepal
    Commented Sep 20, 2017 at 19:14
  • If you notice, I didn't post an answer, only a comment to correct your statement.
    – Ron Maupin
    Commented Sep 20, 2017 at 19:20
  • Under normal circumstances, the switch to use as a root bridge should be obvious. The current best practice is to only connect access switches to the distribution switch(es), and access switches do not connect to other access switches. Also, a VLAN only exists on the distribution and a single access switch. Each access switch could have multiple VLANs, but none of those VLANs are on any other access switches. This prevents STP problems, and STP is only used as a failsafe. Creating a convoluted switch topology where the proper root is not obvious is a poor design.
    – Ron Maupin
    Commented Sep 20, 2017 at 19:26

2 Answers 2

3

Spanning tree itself doesn't have anything like what you are asking. As the network designer, you assign the priorities to ensure that the correct bridge becomes the root bridge. How you select which bridge should be the root depends on how you want the traffic to flow, and that is up to you as the network designer.

If the majority of your traffic is kept within the LAN, then, yes, you should pick the bridge closest to the center of the LAN. If most of your traffic exits the LAN, then you should pick the bridge where your router is connected.

You design the LAN topology to fit how your LAN will be used.


Per your comments:

The LAN diagram to which you linked is something that cannot be reasonably supported. Yes, networks sometimes grow in an unreasonable manner, but that network would need to be redesigned to introduce layer-3. We no longer live in the layer-2 world that existed when STP was developed, where it was, "switch where you can, route where you must." We live in a layer-3 world, and almost nothing requires you to have a large layer-2 LAN.

You can drive just about any protocol to its limits, but that should be avoided. Recent best practices really limit the usefulness of STP to be a failsafe because depending on STP can make your network more fragile, and experiencing an STP problem will render a LAN useless. With a LAN, such as you depict in the drawing, a business can lose millions of dollars per hour/minute/second due to STP problems, which are notoriously hard to correct. No sane business will allow such a LAN.

STP, itself, has some default values for things like diameter, and you change those at your own peril.


Correction:

You question claims, a few times, that the root bridge is selected by bridge ID and MAC address. It is selected only by the bridge ID, of which the MAC address is part. The bridge ID is the bridge priority plus the MAC address, and the MAC address is not considered separately when selecting the root bridge. The most significant part of the bridge ID is the priority, and you need to configure the priority if you want to determine (and you should want to determine) which bridge becomes the root bridge. The MAC address is only significant if there are identical priorities.

11
  • Hi Ron, Thanks a lot anyways I had this idea to select an optimum root bridge automatically by using some math algorithm.Is there any place that I can apply my idea to in a network set up.(seems highly unlikely according to what you say). Also what math algorithm does SPT use to build the tree from the root bridge. I mean it does have these port roles and calculates the least cost paths and block some ports but I want to know what is the underlying math algorithm they used for it.
    – Deepal
    Commented Sep 21, 2017 at 5:34
  • There really is no way to do that, and it would not be a good idea. If my LAN is almost all intra-LAN traffic, with a minimal inter-LAN traffic, then I want the root to be near the center of the LAN on a bridge that primarily serves as a distribution bridge. If most of my traffic is inter-LAN traffic, then I want the root to be on a bridge that connects to the LAN exit point (router), and it should be a distribution bridge for my LAN. Organically grown messes need to be cleaned up. The risk to business simply doesn't allow sloppy practices.
    – Ron Maupin
    Commented Sep 21, 2017 at 5:39
  • ok so say I have a hierarchical network and my LAN is all intra-LAN traffic and I want to select a root bridge in the center(an optimum distribution bridge) without manually configuring one.Can't I select one using a math algorithm.
    – Deepal
    Commented Sep 21, 2017 at 5:53
  • You must manually configure the priority for your root bridge. STP decides the root only by the bridge ID, and if the priorities of all the switches are the same default priority, then the decision is based purely on the lowest MAC address, which is usually the oldest, least-capable switch. There is nothing in STP to select an optimum root. Since you will be configuring the switches anyway (name management address, etc.), there is no reason not to configure the priority for the root.
    – Ron Maupin
    Commented Sep 21, 2017 at 13:12
  • yes I must manually configure I understand but for a research i could for example use some algorithms and automate the task of electing the root bridge couldn't I for such a topology?
    – Deepal
    Commented Sep 21, 2017 at 16:52
3

The root bridge is not selected automatically, it must be assigned by you as the network designer. If you fail to do that the root is selected by the smallest numerical base MAC address of your spanning-tree switches, so pretty much at random - which you likely wouldn't want.

Usually, you build your network in a tree topology. You've got one or more central switches around which you group the access switches around which you group the distribution switches. With a single central switch it's the obvious root bridge. With two for redundancy I make one the root bridge, the other the fall-back root bridge.

http://www.ciscopress.com/articles/article.asp?p=2202410&seqNum=4

9
  • how about for one without a hierarchy like that. Selecting the root bridge simply on the priority and the MAC would be disastrous wouldn't it? So for such a situation is there a way to find the optimum root bridge.(one that is in the center and has a least cost to all directions) ?
    – Deepal
    Commented Sep 20, 2017 at 19:40
  • With an unstructured or 'flat' network the choice of root bridge actually doesn't matter as there's no 'short' way to reconverge the spanning tree.
    – Zac67
    Commented Sep 20, 2017 at 19:50
  • Switches connected like this ?researchgate.net/figure/… maybe this sort of architecture does not exist but lets assume that it does .
    – Deepal
    Commented Sep 20, 2017 at 19:59
  • 2
    Is that serious? Nobody builds a switched, non-hierarchical network like that... However, selecting the "switch" with highest interconnect port count for root would be a start.
    – Zac67
    Commented Sep 20, 2017 at 20:08
  • 1
    I can't imagine anyone building a serious network in this criss-cross fashion. In rare scenarios it might make sense though - e.g. when you have neither central services nor specific workloads and you don't know when which node is up and running. That's when you might want extreme meshing - but you don't switch it, instead you route with a proper routing protocol (OSPF, BGP, ...). If you do need to switch it STP isn't going to cut it, you'd need SPB or something similar.
    – Zac67
    Commented Sep 20, 2017 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.