π³ Spanning Tree Protocol (STP)
Hub -> Bridge -> Switch
Bridge is same as Hub ( 4 ports ) with few extra ports..
Switch has CPU..
Targeted Packet Forwarding: Unlike hubs that broadcast data to all devices, intelligent switches learn device MAC addresses and send data only to the intended recipient.
Hub and Bridge - Creates one collision domain ( domain where collisions can occur ) and one broadcast domain..
Switch breaks collision domain.
Switch creates one Broadcast domain.
Router breaks collision domain and broadcast domain..
255.255.255.255 - Broadcast address to send Broadcast message..
----------------------------------------------------------------------------------------------------
Spanning tree is created by removing redundant paths
High bandwidth = low cost = Best path to Root e node.
π³ Spanning Tree Protocol (STP)
π§ Top 9 Key Points
-
Prevents Switching Loops:
STP detects and blocks redundant links in a network to prevent broadcast storms and MAC table instability. -
Selects a Root Bridge:
The switch with the lowest Bridge ID (Priority + MAC address) becomes the Root Bridge for the network. -
Blocks Redundant Links:
Redundant paths are put into a blocking state, ensuring a single active path between any two switches. -
Uses Bridge Protocol Data Units (BPDUs):
Switches exchange BPDUs to share information about the network topology and root bridge. -
Automatically Reconfigures:
If an active link fails, STP recalculates and unblocks a redundant link to restore connectivity — ensuring fault tolerance. Five STP States
Listening state : Process BPDU and Determines network topology. (15 seconds )
Learning state : Learns MAC address and loads MAC table ( 15 seconds )
Forwarding state : Forwards user traffic.
Disabled state : Does not forward traffic. STP stopped working and loop occurs..
when faulty switch is added to the network the Bridge id is changed and STP is disabled..
Blocking state : Redundant links to blocked, Prevents network loopsBroadcast IP address : 255.255.255.255
Types :
Rapid Spanning Tree Protocol - Fastest
Per VLAN Spanning Tree Protocol
Multiple Spanning Tree ProtocolWhen a link fails, the switch waits out the Max Age timer (20s) before transitioning to the Listening (15s) and Learning (15s) stages, resulting in a total convergence delay of 50 seconds
- DP (Designated Port): Active, forwards traffic
RP (Root Port): Best path toward the Root Bridge.
AP (Alternate Port): Backup path, does not forward traffic unless the Root Port fails. - In the Spanning Tree Protocol (STP), the cost to reach the Root Bridge is calculated based on link bandwidth. Faster interfaces are assigned lower path costs. A switch determines the best path by cumulatively adding the port costs of all incoming links along the route to the Root Bridge.
Old devices cost value..
Link Speed Port Cost 10 Mbps 100 100 Mbps 19 1 Gbps 4 10 Gbps 2 Modern Cisco devices can also use a "long" cost method that provides more granularity for very high-speed links.
Link Speed Long Cost 10 Mbps 2,000,000 100 Mbps 200,000 1 Gbps 20,000 10 Gbps 2,000 100 Gbps 200
⚙️ Technical Summary
| Feature | Description |
|---|---|
| Layer | 2 (Data Link Layer) |
| Standard | IEEE 802.1D (Classic STP) |
| Types | STP, RSTP (802.1w), MSTP (802.1s) |
| Convergence Time | 50 seconds (STP), faster in RSTP |
| BPDU Transmission | Every 2 seconds |
π§° Packet Tracer Lab: STP in Action
π― Goal:
Demonstrate how STP prevents loops when multiple switches are interconnected.
π₯️ Network Topology
Lab Description
-
All switches connected in a triangle (loop).
-
STP ensures one redundant link is blocked automatically to prevent loops.
πͺ Step-by-Step Configuration
πΉ On All Switches (S1, S2, S3)
This enables STP for VLAN 1 (default VLAN).
(It’s enabled by default on Cisco switches, but this reinforces the concept.)
πΉ Check Root Bridge
Run the command:
Example output:
-
The switch with the lowest Bridge ID (Priority + MAC) is the Root Bridge.
-
Other switches will have some ports in forwarding state and one port in blocking state.
πΉ Force a Specific Root Bridge
Let’s make Switch1 the Root Bridge (for demonstration).
π‘ Lower priority = higher chance of becoming Root Bridge.
(Default is 32768, so 4096 makes this switch root.)
Now verify again:
Switch1 will now show:
πΉ Observe Port Roles
-
Root Port (RP): Best path to Root Bridge.
-
Designated Port (DP): other than Root port other forwarding ports are called Designated Ports.
-
Blocked Port (BP): Prevents loops (in “Blocking” or “Discarding” state).
You can see port roles using:
πΉ Test STP in Action
-
From the topology, disconnect one active link between Switch1 and Switch2.
-
Watch STP automatically unblock a previously blocked link between Switch2 and Switch3 — restoring full connectivity.
✅ This demonstrates STP convergence and loop prevention dynamically.
π§ Key Learning Summary
| Concept | Description |
|---|---|
| STP Purpose | Prevents loops in Layer 2 networks |
| Root Bridge | Central switch selected by lowest Bridge ID ( Priority+ MAC) |
| BPDU | Control messages exchanged between switches |
| Blocked Ports | Avoid loops by disabling redundant links |
| Failover | Automatically unblocks redundant link on failure |
π¬ Teaching Tip
“STP is like a traffic controller — it lets only one car (frame) pass on a given path and keeps the others waiting, but if the main road closes, it quickly opens an alternate route.”
Comments
Post a Comment