STP(Spanning Tree Protocol)
Overview of STP
Spanning Tree Protocol (STP) is a network protocol designed to prevent Layer 2 loops in Ethernet networks. It ensures a loop-free topology by blocking redundant paths that could cause broadcast storms and MAC table instability. STP is standardized as IEEE 802.1D
.Key Concepts
Bridge Protocol Data Units (BPDUs):
- Purpose: BPDUs are messages exchanged between switches to maintain the spanning tree topology.
- Content: BPDUs contain information about bridge IDs, root path costs, and port roles.
Bridge ID:
- Structure: An 8-byte value consisting of a 2-byte priority and a 6-byte MAC address.
- Role: Used to elect the root bridge.
Root Bridge:
- Selection: The switch with the lowest bridge ID becomes the root bridge.
- Function: Acts as the central point in the spanning tree topology.
Port Roles:
- Root Port: The port on a non-root switch with the lowest path cost to the root bridge.
- Designated Port: The port on each network segment that has the best path to the root bridge.
- Blocked Port: Ports that are not part of the active spanning tree and do not forward frames.
Port States:
- Disabled: The port is administratively shut down.
- Blocking: The port does not forward frames but listens for BPDUs.
- Listening: The port listens for BPDUs and prepares to transition to the learning state.
- Learning: The port learns MAC addresses but does not forward frames.
- Forwarding: The port forwards frames and participates in the active topology.
STP Operation
Root Bridge Election:
- All switches initially consider themselves as the root bridge.
- BPDUs are exchanged, and the switch with the lowest bridge ID is elected as the root bridge.
Path Cost Calculation:
- Each switch calculates the path cost to the root bridge based on the speed of the links.
- The path cost is used to determine the roles of the ports.
Port Role Assignment:
- Root Port: The port with the lowest path cost to the root bridge.
- Designated Port: The port with the best path to the root bridge on each segment.
- Blocked Port: Ports that are not part of the active topology.
Topology Changes:
- When a link fails or a new link is added, STP recalculates the spanning tree to maintain a loop-free topology.
STP Configuration Example
Here is a basic STP configuration for a Cisco switch:
switch# configure terminal
switch(config)# spanning-tree mode stp
switch(config)# spanning-tree vlan 1 priority 4096
switch(config)# interface GigabitEthernet0/1
switch(config-if)# spanning-tree portfast
switch(config-if)# spanning-tree bpduguard enable
Variants of STP
Rapid Spanning Tree Protocol (RSTP):
- Standard: IEEE 802.1w.
- Improvement: Provides faster convergence compared to STP.
- Compatibility: Backward compatible with STP.
Multiple Spanning Tree Protocol (MSTP):
- Standard: IEEE 802.1s.
- Improvement: Allows multiple spanning trees for different VLANs.
- Use Case: Optimizes network performance by reducing the number of spanning tree instances.
Summary Table
Feature | STP | RSTP | MSTP |
---|---|---|---|
Standard | IEEE 802.1D | IEEE 802.1w | IEEE 802.1s |
Convergence Time | Slow | Fast | Fast |
Port Roles | Root, Designated, Blocked | Root, Designated, Alternate, Backup | Root, Designated, Alternate, Backup |
Port States | Disabled, Blocking, Listening, Learning, Forwarding | Discarding, Learning, Forwarding | Discarding, Learning, Forwarding |
VLAN Support | Single instance | Single instance | Multiple instances |
Comments
Post a Comment