Latest

CCNA RnS Article #30: STP: Under the Hood

CCNA RnS Article #30: Under the Hood STP!

In this article, we are going to see under the hood how STP works in a network. We’ll learn about various concepts and the processes to overcome the challenges in a network with redundant links/paths. If you missed our last articles on STP, request you to please go through them to build continuity and rhythm. Why STP and what STP does?   

Let’s do a deep dive into the STP world. I look at STP in a different way. It looks like an inverted tree to me in a sense from Root I can trace any branch on this tree. Same way STP creates a focal point in a network and that focal point has a path to the entire network.

In an Ethernet network STP, elect one of the switches as a Root switch and all the ports on a root switch are in a forwarding state. All other switches that are not root, are called non-root switches. Non-Root switches have one interface towards the root switch in a forwarding state. All other ports on non-root switches are in a blocking state.

Figure 1: Shortest Path to Root is in a Forwarding State

Spanning Tree protocol uses an algorithm that is called Spanning Tree Algorithm (STA) to talk to the network switches and decide which switch should be root and non-root. Also, the port states, like forwarding and blocking ports.

Process 1: Electing a Root Switch

STA starts with the election of a root switch. To better understand this election process let’s understand some of the concepts –

  • Bridge ID – it’s a unique ID to each switch assigned by STP. A bridge ID is a total 8-byte value. 2 bytes are for priority and 6 bytes are for system ID. System ID is the hardware address of the switch. System ID makes the bridge ID universally unique as no switches have the same MAC address.
  • STP Bridge Protocol Data Units (BPDU) – is a data unit switches used to exchange information with each other. There are different BPDUs available but the most common is Hello BPDU. Hello BPDU is used by switches to convey critical information about itself.

Hello BPDU Critical Fields 

  • Root Bridge ID – the bridge ID of the root switch. Initially, when the switch doesn’t have information about the root switch it sends its bridge ID as the root bridge ID. Saying that I am the root bridge
  • Sender’s Bridge ID – it is the bridge ID of the switch that is sending the Hello BPDU
  • Sender’s Root Cost – it the cost (just think as a distance) between the switch and the root switch
  • Timer Values – there are different timers like the Hello timer, Max Age timer, forward delay timer, etc.

Switches elect a root switch based on the Bridge ID in the BPDU. The root switch is the switch that has the lowest Bridge ID. As we already discussed Bridge ID consists of two values, Priority and System MAC address or ID. The switch with the lowest priority is selected as the Root Switch. If there are multiple switches with the same priority, then MAC address/System ID is used as the tiebreaker. One with the lowest MAC address becomes the Root Switch.

As you have noticed above when sending the Hello BPDU, the sending switch announces itself to be a root switch. As soon as a switch gets a lower Bridge ID from another switch, it stops announcing itself to be a root switch and updates the “Root Bridge ID” field and now onwards starts forwarding superior Hello BPDU. At last, every switch agrees on the best Bridge ID (lowest in the network).

Figure 2: Root Bridge Election Process - Hello BPDUs

From Figure 2, we can say Switch-1 is the root switch as it has the lowest System ID. First STA decided the priority which is the same across the network (3268). If there is a tie, the lowest MAC address is used to decide the root Bridge.

In the beginning, all the switches start sending the Hello BPDU with the cost to reach the root, its Bridge ID, and the Root switch ID. Initially, each switch declares itself to be a root switch (this is called the inferior BPDU – where the actual root switch is not decided). For example, Switch-2 is sending the inferior BPDU to Switch-1 and Switch-3 as announcing itself to be a root switch. After some time, when it receives the better root ID compared to its System ID then it will stop sending its system ID as the Root ID.

Once a switch receives the Superior Hello BPDU (where the received BPDUs Root ID is better than the current switch Bridge ID), it stops announcing itself to be a root switch. For example, Switch-3 gets a better root ID from Switch-1 and starts sending Switch-1 Bridge ID as Root ID in the superior Hello BPDU to Switch-2.  

Once every switch is aware of the root switch in the network, the next step STA takes is to decide the root port on non-root switches. This root port is the shortest and the fastest path to reach the Root switch.

 Process 2: Electing a Root Ports

Selecting the root port on a non-root switch is the next step after electing a root switch. A root port on a switch is the interface that has the lowest STP cost to reach the root switch.

Figure 3: Selecting the Root Port

Figure 3 is a conceptual view of calculating the cost to reach the root switch – it is just for making things easier to understand. Root Switch announces the cost to the other switch as 0 [Switch 1 is the root switch and to reach itself the cost is 0].

Switch-2 and Switch-3 both accept the cost received from the root switch and add their interface cost on which Hello BPDU was received. Switch-2 G0/1 interface cost is 5 and Switch-3 G0/1 interface cost is 4. When announcing the superior Hello BPU to each other they are going to announce the cost to reach the root.

As you can see, Switch-3 Hello BPDU to Switch-2 contains a cost of 4 to reach the root switch. Switch-2 adds its interface (G0/0) cost to the received cost (4+4=8). Likewise, the Indirect path cost to reach the Root from Switch-3 through Switch-2 will be 9. Considering, the G0/0 port on Switch-3 has a cost of 4.

So, Switch-3 G0/1 interface cost to root switch is lowest compared to other paths. Therefore, this interface is selected as the root port on Switch-3.

Hope you are with me and can find out which port on Switch-2 will be selected as the root port. Have you also thought about what is going to be with the interface between switch-2 and switch-3? Which side of the interface is going to be in a blocking state?

Selecting the Designated Port

STP’s final task is to select the designated port on each segment. The link segment between Switch-2 and Switch-3 is going to be the point of discussion in this section. What happens to this segment? Either side of the segment is going to the designated port which will be forwarding traffic and ignored by the other side as that will transition to a blocking state.

An interface on a segment that announces the lower cost, will transition to a designated port. Switch-3 announce a cost of 4 to root Switch and Switch-2 announces a cost of 5 to root switch. In this case, the Switch-3 G0/0 interface will be a designated port. Switch-2 G0/0 interface will be a blocking port.

All ports on the Root Switch are designated ports and can forward the user traffic.

Let’s understand the port state and role in our network topology –

Figure 4: Converged state and Port Roles

Finally, let’s do one more activity. Let’s say Switch-2 Cost to reach the Root is 4 (not 5). Now Switch-2 and Switch-3 announce cost 4 on the segment between Switch-2 and Switch-3. Based on this information, could you find out which port is going to be designated and blocking port on this segment?

It’s a tie as both the switches are announcing the same cost on this segment. Switch breaks this tie by selecting the switch with a lower Bridge ID. Switch-2 has the lower BID 3276:0002-0002-0002 vs 3276:0003-0003-0003. So, the interface G0/0 on Switch-2 will be a designated port and the interface G0/0 on Switch-3 will be a blocking port.

With this let’s conclude one of the important topics in switching. I hope you find this informative! See you soon with the configuration example of STP in the next article.

  Continue Reading...