In this post, we are going to talk about the spanning tree protocol. Switches have some type of handicap when it comes to having to do prevention. The router always has this interesting value, called time to live (TTL) gives us the ability that every time we go from one router to another whatever this time deliver value is we’re going to take one away from it every time we move it to the next router.
What is Spanning Tree Protocol?
Well, switches have some type of handicap when it comes to having to do prevention. The router always has this interesting value called Time to live and this Time to live gives us the ability that every time we go from one router to another whatever this time deliver value is we are going to take one away from it every time we move it to the next router.
Once the value gets to zero, the interesting thing is the router just drops the packet and says Sorry you have no more Time to live that’s why we call it Time to live.
So, what is a spanning tree?
However, we need a spanning tree because our switches do not have this Time to live mechanism with our time to live with routers we are concerned with how many hops down the road will this packet be able to live. This is a looping mechanism so if there is a routing loop eventually those packets going to die anyway because of Time to Live is going to run out.
Spanning tree is not really concerned with how many hops down the road it is. It’s concerned with how to have a loop-free topology suspended tree is loop prevention.
In the above figure, we can see 2 switches and 2 hosts are connected in one network. Let’s say, data is coming from Host 1 and flows via Switch 1 to Switch 2 and goes to Host 2 but can also come back into Switch 1. Well, why would Switch 1 want the actual packet that is just gone out? What we have created here? simply called a loop.
If we are able to send data from Switch 1 so data can get back then it’s a loop. We don’t want loops because loops can cause very havoc on our switches and on our switch environment.
- So, the solution to the looping problem is to block one port which is done by STP.
- Blocking the port means, the port will only accept the frame and does not process the frame.
- Therefore, the function of STP is to find all the redundant links in the network and to block the port which is causing a loop in the network.
Terminology of Spanning Tree Protocol
- Root Bridge
- Non-Root Bridge
- Root Port
- Designated Port
- Non-Designated Port
Root Bridge
- It is the focal point, reference point, captain on topology.
- Depending on the root bridge, other switches decide which port is to be blocked.
- Initially, all switches claim that it is a root bridge, but there is an election process to elect a root bridge.
Bridge Protocol Data Unit
All the switches want to make a loop-free topology that doesn’t have TTL so the communication will happen between switches by BPDU ( Bridge Protocol Data Unit ). BPDU uses little pieces of messages that we send back and forth, this is just what is in BPDU.
The above diagram shows, what is in BPDU. You can see, it has very interesting information like, this has Root ID, Root path cost, Port ID, and lots of interesting information. As soon as every switches boot. they exchange BPDU and BPDU contains a field bridge ID which is 8 bytes.
Priority (2 bytes ) | MAC Address ( 6 bytes ) |
Root Bridge Election Process
Following are the root bridge election process.
- The first election goes to the priority. By default the priority is “32768” but practically priority is “32769” (32768+1 Vlan ID). Switch with the lowest priority will become a root bridge.
- If priority is untouched, then the tie-breaker will be the MAC address. The lowest MAC address will be preferred.
- We can also make forcefully a switch as a root bridge by decreasing the priority by “4096”.
Non-Root Bridge
The switch with no root bridge is called a non-root bridge.
Root Port
The port which is having the lowest cost to reach the root bridge is called the root port.
Cost = 108/ Bandwitdh
Ethernet-Cost = 108/ 10*10^6 = 10
Fast Ethernet-Cost = 108/ 100*10^6 = 1
Gigabit Ethernet-Cost = 108/ 1000*10^6 = 1/10
- But the cost cannot be infraction so we will have to change reference bandwidth.
- If we are changing reference bandwidth then we have to change it throughout the topology.
- So, the Cost = Reference Bandwidth / Bandwidth
Designated Port
The Port is in forwarding mode called as a designated port.
Non-Designated Port
The Port is in Block mode is called a non-designated port.
Which Port is a Root Port?
- Port Priority : The Port is called a Root Port when the priority of its opposite side port is high.
- Port Cost : The Port that has the lowest cost is the Root Port.
- Port ID : The Port with a smaller ID is the Root Port.
NO PORT OF ROOT BRIDGE IS ROOT PORT
Spanning Tree Protocol States
- Disable
- Listening —–> BPDU listen
- Learning —–> BPDU listen, MAC populate
- Forwarding
- Blocking
Spanning Tree Protocol Timers
- Hello —–> 2 Seconds
- Forward Delay —–> 15 Seconds
- Max Age Timer —–> 20 Seconds
Enhancements of STP
- Portfast
- Uplinkfast
- Backbonefast
Portfast : By portfast command, will skip that port from the timers calculation.
This will directly put that port in forwarding mode.
Uplinkfast : In this topology, we have added a redundancy link so if one link goes down then traffic can be moved from another link. But, it doesn’t happen because the switch will take some that is 50 seconds to up so that can be a loss of data.
For example, If you have a link of 10Mpbs and this will remain blocked for 50 seconds then it will cause loss of data i.e
50 x 10 Mpbs = 500 MB of loss
To avoid this loss, we have to configure uplinkfast command. By this uplinkfast command, the switch can skip its port from STP timers and calculations and directly up the port which is in blocking mode.
Backbonefast : In backbonefast, we have implied to remote switches to put the particular port in forwarding state. Because of that, if any link of any switch goes down, all other switches force that respective switch to put a particular port in a forwarding state. So, communication will not be interrupted.
Check Spanning Tree and Root Bridge Switch
We can simply see the spanning-tree output on cisco switches by the “show spanning-tree” command.
In this post, we have covered what is spanning tree protocol, terminology, root bridge election, root port, and enhancement of STP. Share this post who are looking for STP and comment below if you have any queries or suggestions for TechsBucket.