Ethernet has no TTL and no loop detection, so loops cause:
Broadcast storms
MAC address table instability
Duplicate frames
➡ STP prevents Layer 2 loops by blocking redundant paths
If you connect switches with multiple paths, Ethernet doesn’t know when to stop sending frames → infinite loop → broadcast storm → network down.
Imagine 3 roads in a circle. A car enters and keeps driving forever because there’s no “STOP” sign.
STP:
Detects loops
Blocks some paths
Keeps one safe path
Automatically unblocks if a link fails
Standard
Name
802.1D
STP (Classic)
802.1w
RSTP
802.1s
MST
👉 CCNA focuses mainly on 802.1D and 802.1w
Switch A ---- Switch B
\ /
Switch C
Without STP → 🔥 LOOPWith STP → STP blocks one link to form a tree (no circle).
Elects a Root Switch
Chooses best paths to the root
Blocks extra paths
The boss switch
Chosen by lowest Bridge ID
Bridge ID = Priority + MAC Address
Lower = better
Like a team leader everyone listens to.
Switch priorities:
SW1 → 32768
SW2 → 24576
SW3 → 32768
👉 Which is Root Bridge?
✅ Answer: SW2 (lowest priority)
Port Role
Meaning
Root Port
Best path toward root
Designated Port
Best port on a segment
Blocked Port
Closed to prevent loops
Root Port = fastest road to the city center
Blocked Port = road closed with a barrier 🚧
State
What it does
Blocking
No traffic, no learning
Listening
Checks for loops
Learning
Learns MAC addresses
Forwarding
Normal traffic
Disabled
Admin shut down
Timer
Default
Hello
2 sec
Root sends BPDU
Forward Delay
15 sec
Listening + Learning
Max Age
20 sec
BPDU expiry
⏳ Total convergence time = 50 seconds 😴
A port goes from blocking to forwarding. How long does it take?
✅ Answer: 15s (Listening) + 15s (Learning) = 30 seconds
Bridge ID = Priority (16 bits) + MAC Address (48 bits)
Default = 32768
Increments of 4096
VLAN ID is added internally in PVST+
Lowest priority wins
If tie → lowest MAC address
You never want access switches to become root.
Switches:
SW1 → Priority 32768, MAC 0011.1111.1111
SW2 → Priority 32768, MAC 0001.2222.2222
SW3 → Priority 4096, MAC 0033.3333.3333
👉 Root Bridge?
✅ Answer: SW3 (lowest priority)
Speed
Cost
10 Mbps
100
100 Mbps
19
1 Gbps
4
10 Gbps
2
➡ Sum of costs to reach root
A switch with:
FastEthernet path = cost 19
Gigabit path = cost 4
👉 Gigabit is preferred
Which path is chosen?
Path A: 100 Mbps + 100 Mbps = 38
Path B: 1 Gbps = 4
✅ Answer: Path B
Role
Description
Root Port (RP)
Best path to root
Designated Port (DP)
Best path on segment
Non-Designated
Blocked
Each non-root switch has one Root Port
Each segment has one Designated Port
BPDU
MAC Learning
Traffic
Receive only
❌
Send/receive
✅
20 + 15 + 15 = 50 seconds
How long until traffic flows after a link failure?
✅ Answer: 50 seconds
Root election
Path cost calculation
Topology change detection
Root Bridge ID
Sender Bridge ID
Root Path Cost
Port ID
Timers
Root → every 2 seconds
Others → relay BPDUs
Bypasses Listening & Learning
Goes immediately to forwarding
End-device ports ONLY
spanning-tree portfast
⚠ PortFast does NOT disable STP
PortFast can cause loops if misused.
Shuts port if BPDU is received
Protects PortFast ports from:
Rogue switches
Accidental loops
➡ Port goes to err-disabled
spanning-tree portfast bpduguard default
What happens if a switch is plugged into a BPDU Guard port?
✅ Answer: Port shuts down (err-disabled)
Zuletzt geändertvor 16 Tagen