STP (Spanning Tree Protocol)
STP (Spanning Tree Protocol)
Redundancy.
Why do we need STP.
Example to explain Broadcast storm, Multiple frame copies, Mac table inconsistency.
How STP works.
BPDU (Bridge Protocol Data Unit) and Its Types.
STP Election Process and STP Port states.
BPDU Timers.
Interview questions for Network Engineer asked from STP.
STP (Spanning Tree Protocol) – Table of Contents
• Redundancy:
- Protecting the network from single point of failure is called redundancy. Single point of failure means that if one device/port/link goes down the traffic should failover or pass through the other device/port/link.
- Failure of single network link, single device, or a critical port on a switch causes network downtime.
- Redundancy is required in the network design in order to maintain high degree of reliability & eliminate any single point of failure.
- Achieve redundancy in switches by connecting them with multiple links.
- It reduce congestion & support high availability & load balancing.
- Utilizing all the paths & dividing the traffic among the paths simultaneously.
• Why do we need STP:
With redundancy comes multiple complications such as-
1. Broadcast storms → It is basically the unstoppable flooding of switches of any broadcast message & formation of spiral or loop due to updating of MAC or CAM table by the changing of same MAC address with different port numbers.
2. Multiple Frame copies → Receiving of multiple frames with the same information but slight change or unwanted change.
** A switch floods Unknown Unicast, Broadcast & Multicast Traffic.
3. MAC-add table instability problems → When a PC receives info of same MAC add assigned with diff port numbers then there is a MAC add table instability problem.
- - Lets take
an example to explain these better-
1. Initial Event – PC1 Sends ARP Broadcast -
When PC1
(00A) wants to ping PC2
(00B), it first needs the MAC address of PC2.
So PC1 sends an ARP Request (Broadcast).
Frame
Details
·
Source MAC: 00A
·
Destination MAC: FFFF.FFFF.FFFF (Broadcast)
Flow:
1.
PC1 sends the broadcast to Switch1 (e1).
2.
Switch1 learns:
o
MAC
00A → e1
Switch1 then floods the broadcast out all other ports:
·
e0 → Switch2
·
e4 → Switch4
· e5 → Switch4 (second link)
2. Broadcast Propagation Around the Loop -
Now the broadcast frame starts circulating.
Path 1-
Switch1 → Switch2
1.
Switch2 receives frame on e0
2.
Learns:
o 00A → e0
3.
Floods out:
o e1 → Switch3
Path 2 -
Switch1 → Switch4
1.
Switch4 receives frame on e4
2.
Learns:
o 00A → e4
3.
Floods out:
o e3
→ Switch3
o e5 → Switch1 (loop back)
Path 3 -
Switch1 → Switch4 (second link)
Another identical broadcast also reaches Switch4 via e5.
Switch4 now sees the same source MAC from a different port.
MAC table becomes inconsistent:
·
Previously: 00A → e4
·
Now: 00A
→ e5
So Switch4 updates MAC entry.
3. Multiple Frame Copies Reach Switch3 -
Switch3 now receives multiple copies of the same ARP broadcast.
From:
·
Switch2 → e1
·
Switch4 → e2
Switch3 learns MAC inconsistently:
First frame:
·
00A
→ e1
Second frame:
·
00A
→ e2
This causes MAC address flapping.
4. Broadcast Storm Begins -
Switch3 floods both frames again:
·
e3 → PC2
·
e2 → Switch4
·
e1 → Switch2
Now the same frame continues circulating:
Switch1 → Switch2 → Switch3 → Switch4 → Switch1
Because broadcast
frames are never dropped, they keep looping indefinitely.
Result:
·
Bandwidth consumed
·
CPU utilization increases
·
Network congestion
This is the Broadcast Storm.
5. PC2 Sends ARP Reply -
PC2 receives multiple ARP requests and sends
an ARP Reply (Unicast).
Frame:
·
Source MAC: 00B
·
Destination MAC: 00A
PC2 → Switch3
Switch3 learns:
·
00B
→ e3
But because MAC tables are unstable, the reply
may travel multiple paths.
Switch3 forwards toward where it thinks 00A exists:
·
sometimes e1
· sometimes e2
6. Multiple Frame Copies Reach PC1 -
Because of the loop:
The ARP
Reply duplicates through multiple paths.
Example paths:
Path 1 -
Switch3 → Switch2 → Switch1 → PC1
Path 2 -
Switch3 → Switch4 → Switch1 → PC1
So PC1
receives multiple identical frames.
This is the Multiple Frame Copy Problem.
7. MAC Address Table Inconsistency -
Due to continuous looping frames:
Switches keep seeing same MAC from different ports.
Example:
Switch1 MAC table keeps changing:
00A → e100A → e500A → e400A → e1
This is called MAC Address Flapping.
Result:
·
Unicast frames become flooded
· Network instability increases
** To avoid these 3 Issues-
Broadcast Storms, Mac Table inconsistency and Multiple frame copies, STP was
developed.
• How STP works:
- STP algorithm uses 4 simple steps to converge on a loop-free topology.
- STP Convergence:
Step 1 – Election of one Root Bridge.
Step 2 – Election of Root ports.
** Root port is the quickest path to root bridge.
Step 3 – Election of Designated Ports & non-designated port.
Step 4 – Selection of Blocking Port.
- STP is enabled by default on all Cisco Catalyst switches.
- Before moving on to the process lets understand Bridge ID which is contained in BPDUs. Bridge ID plays important role in the election process of Root Bridge.
• BPDU (Bridge Protocol Data Unit):
- It is the language of the switches through which the switches communicate with each other.
- Bridge ID (BID) is contained in the BPDU header and of 8 bytes.
- Bridge Priority is of 2 Bytes and MAC address is of 6 Bytes
- Priority Range: 0 – 65535
- Default Priority is 32768
- After every 2 sec each switch forwards a BPDU to other switches.
• BPDU are of 2 types:
1. CONFIG BPDU – In case of STP, CONFIG BPDU is sent.
2. TCN BPDU – If there is a change in the topology, the TCN BPDU is sent.
** TCN BPDU Generated when there is a change in the topology such as a PC is removed from any switchport then that switch will forward TCN BPDU through its R.P.
** TCN BPDU is always forwarded through the root port as it’s the fastest way to reach the R.B & after that the R.B will inform other switches about the topology change.
Bandwidth |
STP Cost |
|
|
|
4 Mbps |
250 |
10 Mbps |
100 |
16 Mbps |
62 |
45 Mbps |
39 |
100 Mbps |
19 |
155 Mbps |
14 |
622 Mbps |
6 |
1 Gbps |
4 |
10 Gbps |
2 |
• STP Election Process:
1. Election of Root Bridge → Initially all the switches say “I am the root bridge” before election but after the Bridge ID comparison whosoever got the lowest BID will become the R.B.
In the above example considering the mac addresses SW1 will be elected as Root Bridge.
2. Election of Root Port → Root port is elected per switch basis i.e each switch has only one root port. R.P is selected on the basis of cost but in case of tie:
(a) Lowest upstream BID → check for upstream switch.
(b) Lowest Port ID.
Root ports for all switches-
SW1- Itself is root bridge so it won't require a root port.
SW2- E0.
SW3- E1 ( As there is a Tie in cost first tie breaker is considered and upstream switch SW2 has lowest Bridge ID)
SW4- E4 (E3 is eliminated beforehand due to cost and there is tie in cost and upstream Bridge ID for E4 and E5 as SW1 is the only upstream switch, Lowest port ID is considered and E4 is lower than E5. Hence E4 is elected as Root port).
3. Election of Designated Port → This is done per segment/link basis. In case you don't understand a segment in STP check any STP video of google it.
- All ports of R.B will be designated ports.
- Each segment has one DP.
- Designated Port is also decided on the base of RP election criteria if needed.
- Any port that is not D.P or R.P will become Blocking port.
Designated Ports for all switches-
SW1- All ports would be DP.
SW2- E2 is DP (On cost basis as compared to SW3 port E1 also its a RP as well).
SW4- E3 is DP (On cost basis as compared to SW3 port E2).
4. Selection of Blocking Port → Any port that is not D.P or R.P will become Blocking port.
** E2 of SW3 and E5 of SW4 will be Blocking port.
- Port States:
|
State |
Receive BPDU |
Forward Data |
Learn MAC |
|
|
|
|
|
|
Blocking |
Yes |
No |
No |
|
Listening |
Yes |
No |
No |
|
Learning |
Yes |
No |
Yes |
|
Forwarding |
Yes |
Yes |
Yes |
|
Disabled |
No activity |
No |
No |
Blocking port is the key of STP. With its help we are blocking the loop & also achieving our redundancy as well.
If the B.P doesn’t listen BPDUs for 20s or misses 10 BPDUs then automatically it will be changed into forwarding state.
Change in port states:
(a) Change → D → LSN → LRN → FWD (Time taken 15s + 15s = 30s)
(b) Change → B → LSN → LRN → FWD (Time taken 20s + 15s + 15s = 50s)
• BPDU Timers:
1. Hello Time – Time between each BPDU frame sent on port. Equal to 2s by default but can be tuned between 1 & 10 sec.
2. Forward delay – Time spent in listening & learning state. By default 15s but tuned between 4 & 30s.
3. Maximum age – This timer controls the max length of time a switch port saves config BPDU info. By default 20s but tuned between 6 & 40s.
l Interview questions for Network Engineer asked from STP (Spanning Tree Protocol):-
## DISCLAIMER:- The questions asked in the interview are all scenario based and indirect, So you should try to understand the concept instead of cramming. You will be fortunate if you receive a direct question from the interviewer.
1. What is STP ?
2. What is Bridge ID ?
3. How is the Root Bridge Elected ?
4. What is BPDU ?
5. What is TCN BPDU ?
6. When is the TCN BPDU sent ?
7. You might be given a diagram and asked to elect the root bridge and mark the ports as Root port, Designated port, Blocking port ?
8. Explain the BPDU timers and default times for all or range for all ?
9. What are the port states in STP ?
10. How much time does it take for a disabled port to come in forwarding state and also time for a blocking port to come in forwarding state ?
11. In case the root bridge goes down, what will happen ?
Ans- There will be a loop formation initially untill the STP election process happens again and another Root Bridge is elected.
12. If there is a tie in Priority and Mac address of 2 switches. How will the root bridge be elected ?
Ans- Root Bridge election uses lowest Bridge ID (Priority + MAC). Since MAC addresses are always unique for every switch, a tie beyond MAC is not possible in real networks.
13. What is the default priority in a Bridge ID ?
14. What is a Root Port ?
Comments
Post a Comment