Open In App

Spanning Tree Protocol in CCNA

Last Updated : 17 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Spanning Tree Protocol (STP) is a protocol that prevents Layer 2 loops or Bridging loops by computing a tree structure of nodes in a network. It also prevents MAC Flapping  (an event that occurs when a switch receives packets on different interfaces with the same source MAC address)

Spanning Tree Communication:

  • STP exchanges its data messages in the form BPDU’s (Bridge Protocol Data Units).
  • Since the switch is unaware of the other switches around it, so it sends BPDU frames with the source MAC address of its port, and the destination MAC address is the STP Multicast address, i.e., 0180.C200.0000.

Bridge ID is an 8-byte unique identity of each switch in an STP topology. It consists of two things: –

  1. Bridge Priority: ranges from 0 to 65535 (default is 32768) + VLAN-id.
  2. Base MAC Address:  hard coded and unique for every switch.

In a Spanning Tree Topology computed by STP, there exists only one Root Bridge for the entire STP topology and the rest of the switches are Non-Root Bridges.

Root Bridge Election:

  • The switch with the lowest Bridge ID (the least Priority or Lowest MAC address) wins the election and becomes the Root Bridge for the STP topology.
  • Initially, each switch begins its STP logic by creating and sending a Hello BPDU message, in which it claims to be the Root Bridge (because priority is by default the same for every switch, and it is unaware of the other switch’s Base MAC).
  • If a switch receives a superior Hello BPDU message on any of its ports, it stops claiming to be the Root Bridge and stops sending Hello BPDUs. Ultimately, the switch with the lowest Bridge ID stops sending Hello BPDUs and wins the election process.

Manually configuring the priority of a switch: –

R1(config)#spanning-tree vlan <vlan-id> priority <priority-value>

Spanning tree protocol

 

Configuring  STP on CLI

 

Type of Ports in STP:

  1. Root Port (RP): These are the ports that are closest to the Root Bridge in terms of Cost and are responsible for receiving the STP’s control-plane Traffic.
    • Every Non-Root Bridge has only one Root Port and other ports can be either Designated Ports or Alternate Ports (based on the election).
  2. Designated Port (DP): It is responsible for forwarding traffic. 
    • Every port of the Root Bridge is a Designated Port.
  3. Alternate Port (Alt)/Blocked Port: It is a backup port that is in a Blocking State.
    • It comes up only if the current Root Port goes down.

Port Role Election:

After the Root Bridge is elected, the Port Role election takes place on every switch (non-root bridge), based on the following criteria in order: –

  • Cost (to reach the Root Bridge)
        Port Speed             Cost (802.1D – 1998)    
          10 Mbps                 100 
         100 Mbps                  19
          1 Gbps                   4
         10 Gbps                    2
  • Lowest Sender’s Bridge ID 
    • Lowest Priority
    • Lowest Base MAC address 
  • Lowest Sender’s Port ID 
    • Least Port Priority (default – 128)
    • Lowest Port no.
  • Lowest Receiver’s Port ID 
    • Least Receiver Port Priority (default – 128)
    • Least Receiver Port no.

Port Role Election Process:

  • As we have seen that Switch1 has won the Root Bridge election and has become the Root Bridge. Therefore, all its ports become the Designated Ports (DP). Thus, Switch1 starts sending C-BPDUs (Configuration BPDU – generated by Root Bridge) through its DP ports with a cost to reach the root bridge as 0. 
Port Role Election Process

 

  • Switch2 receives the C-BPDU on its e0/0 port (Ethernet port) and this ingress port updates the cost to reach the root bridge from 0 to 100 (The ethernet port’s speed is 10 Mbps). And it will forward this C-BPDU through its e0/1 port with a cost of 100.
  • Similarly, Switch3 also receives the C-BPDU on its e0/0 port and updates the cost from 0 to 100. And it also forwards this C-BPDU through its e0/1 port with a cost of 100.
  • Now, Switch2 receives the C-BPDU on its e0/1 port and this port updates the cost from 100 to 200. And Switch3 also receives the C-BPDU on its e0/1 port and this port updates the cost from 100 to 200.
  • Here, the election will take place and since the cost is different, therefore the least cost will be preferred. 
  • In this case, on Switch2 e0/0 port wins the election (the least cost to reach the root bridge) and it becomes the Root Port (RP). Similarly, on Switch3 e0/0 port wins the election (the least cost to reach the root bridge) and becomes Root Port (RP). 
Port Role Election Process

 

  • Now, the election will take place on the link between Switch2 and Switch3 for the role of DP, i.e., who will forward the C-BPDU?
  • Since, both the switches have sent and received each other’s forwarded C-BPDU, they can decide who is superior among them.
    • Firstly, they check the cost of the C-BPDU after receiving, both the switches have the cost of 200 to reach the root bridge. Therefore, the cost is tied.
    • Secondly, they check the Sender’s Bridge Id (combination of Bridge priority and Base MAC address). Since, both the switches have equal priorities, whoever has the Lower Base MAC address will win the election.
    • Switch2 has a lower Base MAC address than Switch3, therefore Switch2 wins the Election for the role of DP, and its e0/1 port becomes DP.
  • Now looking at Switch3, it has one Root Port (RP) already available and there can be only one RP on a Non-Designated Bridge. Therefore, Switch3’s e0/1 port becomes Alternate (Alt).

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads