Spanning Tree Protocol (STP) prevent the looping of frame by putting the interfaces of 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 answer of 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. First two bytes are priority bytes and remaining six bytes contain built-in MAC address of switch.
- Path Cost –
It is a numeric value given to link between two interfaces based on speed of the interface. Higher the link speed, 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.
We use word “Bridge” although switches are involved because STP were introduced before switches. Bridges were first device to use STP. Hence, various terms include word “Bridge”.
In Order to choose interface for forwarding and blocking state, STP uses three criteria:
- Selection of root switch. All of its interfaces are in forwarding state.
- All other non-root switches makes a root port. And root port is that port whose path cost to root switch is minimum. All root ports are placed in forwarding state.
- Least path cost from each switch to root switch is called that switch’s root cost. And among all switches, switch whose root cost is minimum becomes designated switch. Port of designated switch from which root cost is calculated becomes designated port(DP). DP is placed in forwarding state.
|S.no||Characterization of ports||STP states|
|1.||All ports of root switch||Forwarding state|
|2.||Root port of non-root switch||Forwarding state|
|3.||Designated ports||Forwarding state|
|4.||All other working ports||Blocking state|
Electing Root Switch :
All switches in a LAN exchange Hello BPDU with each other. Firstly all switch consider themselves as root switch but root switch is selected based on BID of switch. Switch having lower priority bit in BID is selected root switch.
If priority bit get tied, then switch having lower MAC-address in Hello BPDU is selected root switch. In diagram shown below, SW1 becomes 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 root switch is chosen as root port for that switch. In the diagram shown below, Gi0/1 port of both SW2 and SW3 is chosen as Root port (RP).
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Types of Spanning Tree Protocol (STP)
- Introduction of Spanning Tree Protocol (STP)
- Spanning Tree Topology (STP) Convergence
- Root Bridge Election in Spanning Tree Protocol
- What is MSTP(Multiple Spanning Tree Protocol)?
- Difference between Unshielded Twisted Pair (UTP) and Shielded Twisted Pair (STP) cables
- What is STP(Shielded Twisted Pair)?
- Working of Dynamic Host Configuration Protocol
- Hot Standby Router Protocol (HSRP) and Virtual Router Redundancy Protocol (VRRP)
- Difference between Stop and Wait protocol and Sliding Window protocol
- Difference between File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP)
- Difference between Serial Line Internet Protocol (SLIP) and Point-to-Point Protocol (PPP)
- Cisco Discovery Protocol (CDP) and Link Layer Discovery Protocol (LLDP) in Data Link Layer
- Difference between Border Gateway Protocol (BGP) and Routing Information Protocol (RIP)
- Working Of Different layers in Computer Network
- Working and Types of Smart Card
- Working of ISO-OSI Model
- Privacy Enhanced Mail (PEM) and it's Working
- Working of Web Request
- Working of Domain Name System (DNS) Server
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.