STP is used by switches to avoid loops.
- Q. How loops are formed?
- Ans. When a designer goes for a redundant design then loops are formed.
- Problems that come with loops?
- Broadcast storms
- MAC address table corruption
- Multiple copies of the same frame revolve around the network.
STP Terms and Terminologies.
- Root Bridge:
- Root Bridge is elected with in a switches network.
- Root Bridge is considered as the focal (center) point of the switched network.
- All the other switches find that which of their ports will be blocked and which of their ports will be kept in forwarding state from the perspective of the root bridge.
- Root Bridge Election:
- Root Bridge is elected on the basis of bridge ID.
- Bridge ID is an 8 byte value, and it is made up of two parts:
- Bridge priority (2 Byte) lower preferred.
- Bridge MAC address (6 Byte) lower preferred.
- Non Root Bridge:
- Bridge which are not Root Bridge are Non Root Bridges.
- All the Non Root Bridges find only one best path going towards the Root Bridge, and they keep the path open. But all the other alternate paths going to the Root Bridge from the Non Root Bridge are blocked.
- Port Cost:
- Each port is assigned a cost by Spanning Tree Protocol, and using this cost the Non Root Bridge finds that which path is the best and which is not.
- Ethernet : 100
- Fast Ethernet : 19
- Gigabit Ethernet : 4
- 10 Gigabit Ethernet : 2
- Each port is assigned a cost by Spanning Tree Protocol, and using this cost the Non Root Bridge finds that which path is the best and which is not.
- BPDU (Bridge Protocol Data Unit):
- Switches communicate to each other in STP and perform all the jobs of STP using Bridge Protocol Data Unit Messages.
- BPDUs are sent every 2 seconds out of all ports of a switch.
- BPDU contains many fields within it:
- Sender Bridge ID
- Root Bridge ID
- Root Path Cost: The distance from a Bridge to reach the Root Bridge.
- Initial root bridge election process:
- Initially when we connect switches, then all of them will think they are Root Bridge.
- Once they start receiving each other BPDU’s then they compare their bridge ID’s.
- Lower bridge ID is preferred and finally Root Bridge is elected.
- Only the root bridge originates BPDU messages.
- Non Root Bridge do not originate BPDU messages, they forward those BPDU’s that they receive from Root Bridge.
STP Port Roles:
- Root Port Role
- Root port is not elected on the Root Bridge.
- Root port is only elected on the Non Root Bridge.
- Through the Root Port from a Non Root Bridge it is the shortest to reach the Root Bridge.
- Only one Root Bridge is elected on a Non Root Bridge.
- Designated Port Role
- Designated port is that port through which BPDUs are sent.
- BPDUs cannot be sent via Root Port or Blocked Port.
- Designated port becomes that port on a segment, which provides a better path to reach the Root Bridge.
- In each segment one designated port is elected for sure.
- Blocked Port Role
- Blocked port role is assigned to that port which could neither become a Root port nor designated port.
How the superiority is claimed in STP?
- Superiority is claimed in STP with the help of BPDU messages.
How the superiority of BPDU is claimed?
- Lowest Root Bridge ID (Root Bridge is elected)
- Lowest Root Path cost (used to elect the Root port)
- Lowest Sender Bridge ID
- Lowest Sender Port ID
Note: The moment a BPDU enters a Port, The cost of that port is added to the Root path cost field.
STP Port states:
- When the switches are first connected, they start talking each other in STP using BPDU messages, and it takes some time for them to assign roles to their ports.
- So we have to give some time to the switches to first assign the port roles and make the port go into Forwarding state or blocking state depending on the port roles that they got assigned with.
- Port States:
- Disabled
- Disabled is technically not an STP state.
- Because disabled state means that the port is non-operational.
- Listening
- When the port is first started the port remains in listening state for 15 seconds.
- This state is dedicatedly given to that it can send and receive BPDUs and define the port roles.
- During this state the actual data cannot be forwarded.
- MAC addresses cannot be learnt on ports during this state.
- Learning
- After listening state, the port jumps to learning state and spends another 15 seconds in learning state.
- In learning state the port can start learning MAC addresses, but still data cannot be forwarded.
- Forwarding
- In this state the actual data can be forwarded.
- BPDUs can be sent and received according to the role which the port has got.
- MAC addresses can be learnt.
- Root Port: Forwarding State
- Designated: Forwarding State
- Blocking
- MAC addresses cannot be learnt.
- Actual data cannot be forwarded.
- BPDUs cannot be sent.
- But BPDUs can be received.
- Disabled
Types of Spanning Tree Protocol:
- IEEE 802.1D (Common Spanning Tree)
- Open standard
- For all VLANs there is a single instance of Spanning Tree running.
- There will be a single logical loop free topology.
- Load balance is not possible with IEEE 802.1D.
- Utilizes less CPU.
- Per VLAN Spanning Tree
- Cisco Proprietary
- Each VLAN has its individual instance of Spanning Tree running.
- Load balancing is possible with PVST.
- Utilizes more CPU.
- Rapid Spanning Tree (802.1W) (802.1D-2004)
- Open Standard
- Rapid Per VLAN Spanning Tree
- Cisco proprietary
- Multiple Spanning Tree (802.1S)
- Open standard