STP - Spanning Tree Protocol ============================= .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is STP?** STP (Spanning Tree Protocol) is a network protocol used to prevent loops in Ethernet networks. It ensures a loop-free topology by selectively blocking redundant paths. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is STP useful?** * Automatically detects loops * Disables redundant paths * Re-enables them if the active path fails .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works** * **Root Bridge Election** – Switches elect one switch as the Root Bridge (lowest Bridge ID) * **Path Cost Calculation** – Each switch finds the shortest path to the Root Bridge * **Loop Prevention** – STP blocks extra paths to prevent loops * **Failure Recovery** – If a path fails, STP activates a backup .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is STP used?** * Enterprise LANs with multiple switches * Data centers with redundant links * Campus networks * Any Ethernet-based network with loop potential .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does this protocol belong to?** * Layer 2 – Data Link Layer * Operates using MAC addresses * No dependence on IP addresses * Manages switch-to-switch behavior .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are common types of STP?** * **STP (802.1D)** – Original standard * **RSTP (802.1w)** – Rapid STP for faster convergence * **MSTP (802.1s)** – Supports multiple spanning trees for VLANs .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the port roles in STP?** * **Root Port (RP)** – Best path to the Root Bridge (one per switch) * **Designated Port (DP)** – Forwards frames on a segment * **Blocked Port** – Does not forward traffic (backup path) * **Disabled Port** – Shut down or not participating .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the STP port states?** * **Blocking** – Listens for BPDUs only * **Listening** – Prepares for data forwarding * **Learning** – Learns MACs but does not forward * **Forwarding** – Active traffic forwarding * **Disabled** – Manually turned off .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is a BPDU?** A Bridge Protocol Data Unit (BPDU) is a special message used by STP to share topology information between switches. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What happens during a topology change?** * A switch detects a change (e.g., link down/up) * It sends a Topology Change Notification (TCN) BPDU * The Root Bridge updates the topology * Switches flush MAC tables and reconverge .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the working flow of STP?** * **All Switches Send BPDUs** – Each switch assumes it's the Root and sends its Bridge ID (priority + MAC) with path cost = 0 * **Elect the Root Bridge** – Lowest Bridge ID wins – Other switches become non-root * **Calculate Path Cost to Root** * Cost based on link speed: * 10 Mbps = 100 * 100 Mbps = 19 * 1 Gbps = 4 * 0 Gbps = 2 * **Assign Port Roles** * Based on best paths and BPDUs: * Root Port * Designated Port * Blocked Port * **Block Redundant Links** – Only Root & Designated Ports forward – Blocked ports prevent loops * **Transition Port States (802.1D)** – Blocking → Listening → Learning → Forwarding – Takes 30–50 seconds to converge * **Handle Topology Changes** – Affected switch sends TCN BPDU – MAC tables are flushed – Tree recalculates and stabilizes .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the real-time applications of STP?** * **VoIP (Voice over IP)** * **Video Conferencing** (e.g., Zoom, Microsoft Teams) * **Industrial Automation** * **IPTV / Live Video Streaming** .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`STP Version&IEEE Details ` * :ref:`STP Basic Setup on Ubuntu using IPv4 ` * :ref:`STP Basic Setup on Ubuntu using IPv6 ` * :ref:`STP Protocol Packet Details ` * :ref:`STP Usecases ` * :ref:`STP Basic Features ` * :ref:`STP Feature : Loop Prevention ` * :ref:`STP Feature : Redundancy Support ` * :ref:`STP Feature : Automatic Topology Change Handling ` * :ref:`STP Feature : Bridge Election ` * :ref:`STP Feature : Port Roles Assignment ` * :ref:`STP Feature : Path Cost Calculation ` * :ref:`STP Feature : Timer Based Operation ` * :ref:`STP Feature : Dynamic Reconfiguration ` * :ref:`STP Feature : Standardized Protocol ` * :ref:`STP Feature : Layer 2 Operation ` * :ref:`Reference links ` .. _STP_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _STP_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _STP_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _STP_step5: .. tab-set:: .. tab-item:: STP Version&IEEE Details .. csv-table:: :file: ./STP/STP_IEEEdetails.csv :widths: 10,10,10,30,40 :header-rows: 1 .. _STP_step20: .. tab-set:: .. tab-item:: STP Basic Setup on Ubuntu using IPv4 * setup .. _STP_step21: .. tab-set:: .. tab-item:: STP Basic Setup on Ubuntu using IPv6 * setup .. _STP_step6: .. tab-set:: .. tab-item:: STP Protocol Packet Details **STP CONFIGURATION BPDU Packet** .. csv-table:: :file: ./STP/STP_Configuration_BPDU_Packet.csv :widths: 10,20,30,40 :header-rows: 1 **STP TOPOLOGY CHANGE NOTIFICATION Packet** .. csv-table:: :file: ./STP/STP_Topology_Change_Notification_Packet.csv :widths: 10,20,30,40 :header-rows: 1 .. _STP_step7: .. tab-set:: .. tab-item:: STP Usecases .. csv-table:: :file: ./STP/STP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _STP_step8: .. tab-set:: .. tab-item:: STP Basic Features .. csv-table:: :file: ./STP/STP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _STP_step9: .. tab-set:: .. tab-item:: STP Feature : Loop Prevention **Loop Prevention - Testcases** .. csv-table:: :file: ./STP/STP_Feature1_Loop_Prevention_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step10: .. tab-set:: .. tab-item:: STP Feature : Redundancy Support **Redundancy Support - Testcases** .. csv-table:: :file: ./STP/STP_Feature2_Redundancy_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step11: .. tab-set:: .. tab-item:: STP Feature : Automatic Topology Change Handling **Automatic Topology Change Handling - Testcases** .. csv-table:: :file: ./STP/STP_Feature3_Automatic_Topology_Change_Handling_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step12: .. tab-set:: .. tab-item:: STP Feature : Bridge Election **Bridge Election - Testcases** .. csv-table:: :file: ./STP/STP_Feature4_Bridge_Election_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step13: .. tab-set:: .. tab-item:: STP Feature : Port Roles Assignment **Port Roles Assignment - Testcases** .. csv-table:: :file: ./STP/STP_Feature5_Port_Roles_Assignment_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step14: .. tab-set:: .. tab-item:: STP Feature : Path Cost Calculation **Path Cost Calculation - Testcases** .. csv-table:: :file: ./STP/STP_Feature6_Path_Cost_Calculation_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step15: .. tab-set:: .. tab-item:: STP Feature : Timer Based Operation **Timer Based Operation - Testcases** .. csv-table:: :file: ./STP/STP_Feature7_Timer_Based_Operation_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step16: .. tab-set:: .. tab-item:: STP Feature : Dynamic Reconfiguration **Dynamic Reconfiguration - Testcases** .. csv-table:: :file: ./STP/STP_Feature8_Dynamic_Reconfiguration_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step17: .. tab-set:: .. tab-item:: STP Feature : Standardized Protocol **Standardized Protocol - Testcases** .. csv-table:: :file: ./STP/STP_Feature9_Standardized_Protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step18: .. tab-set:: .. tab-item:: STP Feature : Layer 2 Operation **Layer 2 Operation - Testcases** .. csv-table:: :file: ./STP/STP_Feature10_Layer2_Operation_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _STP_step19: .. tab-set:: .. tab-item:: Reference links * Reference links