Switch – How is the root bridge determined in spanning tree from BPDU perspective

spanning treeswitch

I understand how root election works, but can someone explain it in terms of BPDUs? Is a configuration BPDU sent, and does the downstream switch forward the BPDU? What if the downstream switch actually has the lower ID, and how long and how many BPDU does the switch send for election process? If there is a loop in the network, and if the switches keep forwarding the BPDUs, when does it actually stop (I understand that after election process, BPDUs are forwarded only in designated port, so there is no looping is this)? After election is the root bridge the only switch that sends a BPDU unless there is a topology change?

Sorry for the long questions, but all i can find is how STP works.

Best Answer

You have basically asked the election process :p

So, here is what happens. All switches that have STP enabled (which is defaut setting in most switches), send out BPDU's.

What the BPDU mainly contains is this : a. the ID of that switch b. The ID of the root according to that switch (At the beginning of the process every switch thinks it is the root).

As Ron pointed out, This is sent on a link local address which means that it will be sent to all the devices that are directly connected to the switch. (Yes even end devices like desktops can receive this message but they will discard the packet as STP is not enabled on them)

Now as a switch when you receive the packet from all your neighboring switches, here is what you do, you compare their ID with your ID. One of the two things can happen - your ID lower than their ID in that case you still think you are the root or you find out that your ID is not the lowest. So in the next BPDU packet you will replace the root ID with the the ID of that device.

Now this process continues till all the devices unanimously agree as to which device is the root.

At this point the election stops and the root is elected.

I dont fully understand by what you mean by upward / downward packets, but after the root is elected all switches send their BPDU hello packets before the dead time to the root (in RSTP not very sure about this) and the root sends its hello packet (STP and RSTP). if any device fails to reeive the hello packets before the dead interval there is a re election which I am not mentioning in detail here

BPDU's are forwarded on the designated ports

After the election, the non root switches can have one of these links:

a. in designated state - the one which is that is used to connect to the root b. Forwarding - literal meaning , not connected to the root, but forwards packets c. blocked - the link that could potentially cause loops and thus is blocked.(cannot send but can receive packets)

Hope it clears your doubts ..