13 - STP
13 - STP
Single point of failure network doesn’t provide redundancy. If cable is cut entire network will down.
To resolve this Single point of failure network problem, we need to connect one more cable
between switches. Now we have redundancy in our network, but the problem is loop in our
network. Redundant network brings loops in our switched network.
These problems occur broadcast storm in network. Broadcast can consume bandwidth and block
transmission of other packets. This situation results in a broadcast storm.
The solution to prevent layer 2 loops is STP (Spanning tree protocol).
• STP uses bridge protocol data units (BPDUs) for communication between switches.
• STP forces certain ports into a blocked state so that they do not listen to, forward, or flood
data frames. The overall effect is that only one path to each network segment is active at
any time.
• If there is a connectivity problem with any active network segment, STP activates a
previously inactive path, if one exists (changing the blocked port to the forwarding state).
In redundant topology all switches send BPDU (Bridge protocol data unit) and elect root bridge.
BPDU (Bridge protocol data unit)- BPDU is just type of data send to elect Root bridge between
switches.
Switches compares Priority and MAC address Lowest priority elect Root bridge if priority tie lowest
MAC address elect root bridge.
Root Bridge- The root bridge is the logical centre of the spanning tree topology.
In this topology switch 1 has lowest MAC address won the election and elected as root bridge. Other
switches elected as a non-root bridge.
Root bridge is having Designated port and non-root switches is having root ports or designated port.
To block one port switches does election again between non-root switches if switches cost is equal.
Lowest priority and lowest MAC address win the election and the other switches block the port.
In my example switch B and Switch C is having same interfaces that’s why switch B has won this
battle and put designated port. Switch C block its one port. Block port doesn’t forward frame and
doesn’t manipulate MAC address table. Whenever physical topology changes block (alternate port)
up and forward frame.
The root path cost is used to elect root port. There are by default interfaces cost. Lower cost
becomes the root port.
10 Gbps 2 1
1 Gbps 4 1
100 Mbps 19 10
10 Mbps 100 100
Root port is the port that is closest to the root bridge, which means it is the port that
receiving the lowest-cost BPDU from the root.
Every non-root bridge must have a root port. All root ports are placed in forwarding state.
In the below example, if we suppose the upper link (between two fa0/0 interfaces) are 10Mbps
and the lower link (between two fa0/1 interfaces) is 100Mbps link then fa0/1 of SwA will become
root port as it has lower cost than fa0/0 (cost 19 < cost 100).
STP selects one designated port per segment to forward traffic. Other switch ports on the segment
typically become nondesignated ports and are blocked. Therefore, interface fa0/0 of SwA will
become nondesignated port (blocking state). In blocking state, although switches cannot send
data traffic but can still receive BPDUs.
Root port This port exists on non-root switches, best path to root bridge, forward data
traffic toward root bridge and populate the MAC address table.
Designated This port exists on root bridge, root bridges, all ports are Designated port, data
port traffic receive and forward, populate the MAC address table.
Non- This port is in blocking state doesn’t receive and transmit data frame and
Designated doesn’t populate the MAC address but still receive BPDU.
port
When STP is enabled, every switch in the network goes through the blocking state and the
transitory states of listening and learning. The ports then stabilize to the forwarding or blocking
state.
State Can forward data? Learn MAC? Timer
STP Description
flavours
CST Common spanning tree protocol is legacy protocol that provides loop free network in
802.1D VLAN 1
PVSTP+ Per VLAN spanning tree protocol 802.1D, that provides separate VLANs Root bridge
for each VLAN.
RSTP Rapid fast spanning tree protocol is open standard that provides fast convergence of
802.1w STP
Rapid Rapid PVSTP+ 801.1w, that provides separate VLANs root bridge for each VLANs
PVSTP+
802.1w
MSTP Multiple Spanning tree protocol. MSTP maps multiple VLANs into the same spanning tree
instance.
PortFast-
Switches sends BPDU every 2 seconds and takes 50 seconds. That is not good for real network.
Whenever switches are connected with PCs, servers we don’t need BPDU we need port mode must
be forward mode.
PortFast is a command that set switch port immediately in forward mode and skip listening and
learning mode.
Note- If a switch's port is enabled as a PortFast and it receives BPDU Frame, The BPDU effectively
disable that port PortFast configuration and topology occurs a loop network.