Working of Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) prevents the looping of the frame by putting the interfaces of the switch in either forwarding or blocking state. How Switch is able to decide which interface should be in forwarding or blocking state. We’ll learn the answer to this question in this article. Before we further proceed, we must know some terms.
- BID – It stands for Bridge ID. It is an 8-byte value unique to each switch. The first two bytes are priority bytes and the remaining six bytes contain the built-in MAC addresses of the switch.
- Path Cost – It is a numeric value given to link between two interfaces based on the speed of the interface. The higher the link speed, the lower will be the cost.
- BPDU – Bridge protocol data unit is a message that switches exchange b/w them. Commonly used BPDU is Hello. It contains cost and BID.
Note – We use the word “Bridge” although switches are involved because STP was introduced before switches. Bridges were the first device to use STP. Hence, various terms include the word “Bridge”.
In Order to choose an interface for forwarding and blocking states, STP uses three criteria:
- Selection of root switch. All of its interfaces are in a forwarding state.
- All other non-root switches make a root port. And root port is the port whose path cost to the root switch is minimum. All root ports are placed in a forwarding state.
- The least path cost from each switch to the root switch is called that switch’s root cost. And among all switches, the switch whose root cost is minimum becomes the designated switch. The Port of the designated switch from which root cost is calculated becomes the designated port(DP). DP is placed in a forwarding state.
|Characterization of ports
|All ports of the root switch
|Root port of the non-root switch
|All other working ports
Electing Root Switch :
All switches in a LAN exchange Hello BPDU with each other. Firstly all switches consider themselves root switches but the root switch is selected based on the BID of a switch. A switch having a lower priority bit in BID is a selected root switch. If the priority bit gets tied, then the switch has a lower MAC address in Hello BPDU is the selected root switch. In the diagram shown below, SW1 becomes the Root switch after comparing BID from each switch in LAN.
Choosing Root port on Non-root Switches :
The ports in each switch having minimum path cost to the root switch are chosen as the root port for that switch. In the diagram shown below, the Gi0/1 port of both SW2 and SW3 is chosen as the Root port (RP).
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation
Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation