Let us look into all important protocol of Layer 2 , which is spanning tree protocol . As we have seen in bridging loops article , it is understood that redundant topology and bridging loops coexist together unless we have some mechanism to avoid loops .
The mechanism is nothing but running a spanning tree protocol which will make sure to avoid loops and switches to redundant path during a failure.
Let us dive into the protocol and analyse how it exactly does this job for us . I have created a following topology for understanding the protocol .
As we can see from the diagram, i have created a topology which has got multiple paths to reach a particular node .
For example to for bridge 1 to reach bridge 4 , it can reach via bridge 1-bridge 3 -bridge 4 (or) bridge 1-bridge 4 (or) bridge 1 -bridge 2- bridge 4
Same is the case with other bridges . So in these type of topologies we must disable/shut down the ports which might causes loops. Thankfully we have spanning tree protocol which takes cares of all such issues for us otherwise life would have been hell for network administrators !
If you observe in the picture, i have mentioned the mac address and priority of each of the bridges which are one of the key factors in spanning tree .
The key steps in spanning tree protocol are .
- Find out the root bridge,
- Find the root ports
- Find the designated ports
To start with , All the nodes think they are the root bridges . Hence all the bridges participating in spanning tree will send STP (bridge protocol Data units) BPDUs out towards connected bridges.
The BPDU format is as below
Protocol Identifier
|
2 (bytes)
|
Version
|
1
|
Message Type
|
1
|
Flags
|
1
|
Root
ID
|
8
|
Path
Cost
|
4
|
Bridge
ID
|
8
|
Port
ID
|
2
|
Message Age
|
2
|
Maximum Time
|
2
|
Hello Time
|
2
|
Forward delay
|
2
|
Considering the complexity of all the parameters , We will limit ourselves to Parameters which are relevant during convergence of a STP . I will present the complete BPDU details in a separate article.
Now coming back to election of root bridge , Since all the bridges are sending BPDUs each of the bridge ports will also receive BPDU from its adjacent bridge ports . The bridge will keep a "best" BPDU and discard the rest of the BPDU , the "best" BPDU is decided on the following criteria .
- Lowest root bridge ID ( bridge priority + MAC address )
- If Root IDs are equal , it will start checking for Lowest path cost ( Cumulative cost of links between switch and root bridge)
- If the Path costs are equal ,Lowest sender bridge ID
- If the Sender bridge IDs are also equal , Lowest sender port ID (Port priority + port number)
Once the root bridge is decided based on the above election criteria , Now its turn for deciding the port roles .
- Root port - Every non root bridge must select the root port , the port which is closest root port (based on path cost )
- Designated port - Ports providing the least path cost from the segment to root bridge , have to be decided . The bridge containing designated ports for a given segment is called designated bridge .
- Ports which are neither root port nor designated ports are put into blocking state ( Non designated ports).
If a bridge receives a better configuration that it would transmit , it would stop sending the configuration messages . Hence once the algorithm stabilizes only one bridge per LAN i.e. designated bridge for that LAN will send configuration messages.
When a failure happens in any of the ports i.e designated bridge stops sending BPDUs for a period about max age time , Non designated bridge will turn the blocking port to forwarding state enabling packet transmission via that port .
After converging , the entire topology might look like below . It is not the only way it could converge , but depends on the selection criteria logic it could change accordingly .
Now we know the STP selection criteria , we will try to come up with state diagram of the STP by considering various stages during election process .
- Blocking - The switch will go into blocking state when it receives a better path to root bridge Or a port is not a root port or designated port . During this state switch will not forward packets and discards frames it receives on its ports . This time is normally 20 seconds.
- Listening - After blocking state the root port or designated port will move into listening state. In this states , switch will not forward packets and discards the frames received from another segment for forwarding .It will accept BPDUs and gives it to switch module for processing. This time period is normally 15 seconds.
- Learning - In this state switch starts learning the mac address from the received frames , but it will not forward frames in this state . This time period is normally 15 seconds.
- Forwarding - In this state, switch will start forwarding frames learns mac addresses of the received frames .
- Disabled - The ports which are not participating in STP will be put into this state.
There are some changes done in the STP to fasten the process and not loose the advantage of STP . We shall look into such things in the next article .



No comments:
Post a Comment