Spanning Tree Network Protocol – Understanding Spanning Tree Protocol
Latest Technology News: ‘Spanning Tree Protocol (STP)’ or ‘Spanning Tree Network’ resolves the shortest cost path from the root link to other nodes in the ‘Networks’. Learn how do all the operations happen, and what are the chief components of this protocol.
> Understanding Spanning Protocol | How Does it Work?
STP stands for “Spanning Tree Protocol”.
STP is a ‘Network Layer Protocol’ which helps in creating a ‘logical loop-free’ topology for the Ethernet Networks.
Several versions of “STP” kept on coming into the market with time and bringing new improvements to this protocol.
> Some Improvements in Network Tree Protocol Are:
1. STP / 802.1D [Original STP].
2. PVST+ [Cisco Improvements of STP and adding a per VLAN feature].
3. RSTP / 802.1W [Improved STP with much faster merging].
4. Rapid PVST+ [Cisco improvement of RSTP, adding per VLAN feature].
You can see that “Cisco” has made a lot of reforms in this field.
Let’s go back to the basics and look into the reason why ‘STP’ was needed in the first place.
Before we look into the need of STP, let us have a quick look at how ‘layer 2 operates’ when it has to find out the address of a particular host.
When a switch accepts a ‘packet’, but it does not have the ‘MAC Address’ of the ‘Destination Node’ in its table, it transmits the messages on all the nodes, without it receives from.
> Case 1 | Broadcast Storm:
Let’s say there are 3 ‘Switches’ in a network as seen above.
All the ‘switches’ are connected to each other.
‘Switch B’ sends a broadcast and (Switch A and Switch C receive it).
However, They do not find the Address and re-broadcast message.
‘Switch B‘ receives the re-broadcasted message again from (Switch A and Switch C).
Assuming of that broadcast as a fresh broadcast.
‘Switch B’ again broadcasts the same messages, which already been broadcasted before.
In This way, a broadcast storm takes place.
It continues until ‘ports fail or Switch/Switches also fail’.
If you have a look at the definition again and now you will get to know why ‘STP’ was invented at first place.
> Case 2 | Duplicate Packets:
Now, Think the same ‘network architecture’ as given in the scenario above.
There is a little twist here.
This time ‘Switch C’ is connected to the destination host which ‘Switch B’ has been looking for.
So now what?
‘Switch B’ will broadcast again.
The broadcast reaches ‘Switch C’ and ‘Switch A’ as well.
‘Switch C’ looks into the packet and delivers the packet to the destination host.
But, on the other parallel side, ‘Switch A’ also checked its table and could not find the destination host.
So, it also broadcasted the message and ‘Switch C’ again received the same packet.
So, it looks into the packet and delivers to the destination host again.
> Now, What is the obstacle here? Will you suggest without Reading More?
The greatest problem here is ‘duplicate delivery’ and ‘wastage of bandwidth’.
Now, let us find out the solution for ‘scenario 2’.
One of the best and easiest solutions will be to cut ‘Switch B’ with ‘Switch C’ so that there is no packet duplication.
Because ‘Switch A’ will broadcast the packet to ‘Switch C’ if the destination host is not found in the ‘Switch A’s’ list.
> It looks something like this now:
Though we found the solution.
Yet, not sure if preventing the link between ‘B to C’ was more ‘beneficial or blocking’ the same between ‘Switch B’ and ‘A’.
Now, Let’s cover all these in details now.
> Now, Which Port to Block in STP?
‘STP’ follows a series of simple steps which helps in resolving many issues.
One of them is to include which port to block.
But, before that here are some of the ‘terminology’ that might help:
1. Root Bridge:
Just like a ‘Root’ in a tree structure.
‘Root Bridge’ is the main ‘Switch or Bridge in a Graph’ where different nodes represent all other ‘bridges’.
The ‘Root bridge’ controls the ‘spanning tree topology’.
2. Designated Bridge:
The ‘designated bridge’ is the switch ‘closest’ to the ‘Root bridge’.
Through which the ‘frames’ will be rerouted to the ‘Root Bridge’.
3. Alternate Bridge:
It is an ‘Alternate Path’ to the ‘Root Switch’.
But is different than that of the path involving the ‘Root Bridge’.
4. Back up Bridge:
This is a ‘back up path’ to the segment.
Though, there will be a different route which exists.
The ‘Ports’ which are ‘disabled’.
Following are the various states, which ‘switch port’ might be at any given point in time are:
- Forwarding Port:
A port which is ‘full-fledged’ working.
- Learning Port:
A port which is not ‘forwarding the frames’ but it is learning the ‘MAC addresses’.
- Listening Port:
A port which is ‘neither forwarding the frames’ nor ‘learning the MAC addresses’.
- Discarding Port:
A port which does not ‘forward any data’.
> Now, Let’s see how does ‘STP work’ and ‘decides’ which (Switch, Bridge, and Port have to be in what state):
1. In step one, a ‘Root Bridge’ is chosen “How Root Bridge is selected”.
2. Ports at the ‘root bridge’ are placed in the ‘forwarding state’.
3. Ports in the ‘designated Bridges’ connecting the ‘Root Bridge’ are named as ‘Root Port’.
4. Remaining links on a ‘designated Bridge’ choose ‘designated ports’.
5. Rest of the ports are placed in the ‘blocking state’.
6. Here is a very fine example from ‘Wikipedia’.
1. RP: Root Port.
2. DP: Designated Port.
3. BP: Blocked Port.
However, the whole process might look easier.
But the ‘working algorithm’ behind the scene is complex.
The larger the network, the longer it takes for the ‘Algorithm’ to put everything in its place.
> Spanning Tree Protocol Operation:
The following collection of processes takes place.
> Determining the Root Bridge:
Let us think of scenario from the source.
Let us assume, the network is brought up from ‘scratch’.
All the ‘switches’ that are part of the network.
When powered up they all claim to be the ‘root bridge’.
To verify the claim: all the ‘switches’ have to broadcast their ‘Bridge ID (BID)’ using ‘BPDUs (Bridge Protocol Data Units)’.
‘Bridge ID’ has a (total size of 8 Bytes) out of which (2 Bytes are reserved for the Bridge Priority, and rest of the 6 Bytes are reserved for the MAC address).
‘Bridge ID’ is a union of ‘Bridge priority’ and a ‘MAC address’.
The ‘BID’ is a concatenated version of (Bridge priority and the MAC address) of the ‘Switch/ Bridge’.
Each ‘bridge’ will have the ‘bridge ID of 32768’ and each (bridge ID will be in multiples of 4096).
> How is the Root Bridge determined?
After each ‘Bridge’ has their own ‘Bridge ID broadcasted’,
The Bridge with the “minimum BID” becomes the ‘Root bridge’.
In case the ‘Bridge priority is same in both cases’,
then the (lowest Mac address becomes a winner).
> Let us explain with the help of an Example:
Let us say there is a bond between 2 bridges with the ‘BIDs’ as:
1. Bridge A: 32768.df56.6765.7876.
2. Bridge B: 32768.df56.6765.7875.
A question for you: which ‘Bridge’ will become the ‘root bridge here’?
If you picked ‘Bridge B’, then you were accurate.
> Graphical Example:
> Now, observe how these specific switches react to the ‘BPDUs’:
The moment all the ‘switches’ are powered up.
All the switches are the ‘root bridge’ by sending their ‘Bridge ID’ in a hello packet.
> Switch 1:
When ‘Switch 1’ hosts the ‘hello BPDUs’ from (Switch 2 and Switch 3), it compares the ‘Bridge ID’ values.
‘Switch 1’ has the lowest BID.
‘Switch 1’ cuts the hello packets received from the rest of the ‘Switches’.
And keeps on showing itself as the ‘Root Bridge’.
> Switch 2:
Now, ‘Switch 2’ receives ‘Hello BPDUs’ from both of Switches.
Includes Switch 1 and Switch 3.
See how ‘Switch 2’ reacts to both of the BPDUs?
Switch 2 receives the packet from Switch 1 and it compares the BID values for sure, hello packet BPDU from Switch 1 replaces its BID.
Then, Switch 2 changes its BID to that of Switch 1.
When it receives the BPDU from Switch 3, it compares the values and will keep on dropping the BPDUs from Switch 3.
> Switch 3:
Switch three receives the ‘BPDU’ first from Switch two.
So, it changes its BID to that of Switch 2.
But, when it further receives the BPDU from Switch 1, it again changes it to that of Switch 1.
Now, all the switches have received each other’s BPDU and have agreed that Switch 1 has the lowest BID value and is, therefore, the right candidate to be the ‘Root Bridge’ of the network.
Root bridge has been selected, then Switch 2 and Switch 3 start making their respective links into ‘Root Ports’ and ‘Designated Ports’.
Selecting the Root Bridge is not the end of the game.
> This is just the beginning, the game follows on:
Defining the ‘least cost route’ to the Root Bridge.
You are well aware of the ‘spanning tree’ from the graph theory.
If yes, then you can link why we are talking about computing the ‘least cost route’ to the root bridge.
Graph Theory, a ‘spanning tree’ is a subset of Graph.
The Spanning Tree allows including all the points of the graph with least a possible number of edges.
Therefore, a spanning tree does not have a loop and on top of that, it can not be cut.
‘Spanning Tree Protocol’ uses the case just like the (Spanning Tree from the graph theory), this network protocol can determine the ‘least cost path’ from any node to the root bridge.
When the Root Bridge has been chosen, each node starts discovering out the least cost to the Root bridge so that the whole network gets optimized.
As the first step, Root Bridge sends out the BPDUs flow to all the other Switches. The root cost is determined by summing up the costs of the segments on the path on which it took a BPDU packet to traverse from the Root Bridge to the node.
The cost of the segment is also dependent upon the link speed of a particular segment. Here is a chart of the same.
‘Root Bridge’ sends out the BPDUs flow to all the other Switches.
The ‘root cost’ is resolved by summing up the costs of the segments on the path, on which it took a ‘BPDU’ packet to cross from the Root Bridge to node.’
Moreover, cost of the segment is also dependent on link speed of a particular segment.
Sometimes, these link values arise interesting situations.
Regarding the (least cost path link to the Root Bridge).
This might seem that Switch 3 is directly related to the ‘Root Bridge’ and that should be its path.
But if we determine the link cost, it comes out that the following flow is the best flow for Switch 3 to send data to the Root Bridge.
(Root Bridge -> Switch 2 -> Switch 4 -> switch 3).
The ‘Switch 3’ to Root Bridge directly is 100.
Because of its a 10 Mbps link.
But if we calculate the path as told above, it will be as (19+19 +4 = 42).
So, in each of the ‘non-root Bridge’, the port which gets the BPDU with the least cost becomes the root port of that Bridge.
All the links attached opposite to the Root port are marked as the ‘Designated port’.
Also, the ‘blocked ports’ are determined.
Once, everything is marked and fixed, the network will have the entirely optimized version of ‘spanning tree protocol (STP)’.
> There may be some other conditions:
In case of a large network, there will be a tie in the link cost.
In that case, network cost is calculated as a part of Advanced STP.
The Advanced ‘STP’ also talks about what happens in a case of a link failure.