Spanning Tree Protocol

Published by Keyboard Banger on

Please read here for a brief introduction on Spanning Tree Protocol

 STP BID and Root Bridge

Each BPDU contains the Bridge ID (or BID for short). The Bridge ID is composed of:

  • the bridge priority
  • the bridge MAC address

The default bridge priority value is 32768. When there ‘s a tie in the priority, the bridge with the lowest MAC address wins the elections and becomes the Root Bridge.

Once the Root Bridge is elected, all BPDUs are emitted only from the Root Bridge; the non-Root Bridges simply forward copies of the Root Bridge’s BPDUs.

Superior BPDU

The BPDU sent by the Root Bridge is called Superior BPDU.

Port States

A spanning tree port is in one of the following states:

  • Disabled: Spanning tree protocol is disabled
  • Listening
  • Learning
  • Forwarding
  • Blocking

When the port in the Listening or Blocking state, the switch can not learn new MAC addresses from Ethernet frames received on this port.

BID vs RID

The Root ID is the Bridge ID of the root bridge. The Bridge ID is the ID of the switch that generated the BPDU. If, in a BPDU the Root ID is equal to the Bridge ID, then the current switch is the root of the spanning tree. Otherwise, the root bridge is another switch.

Spanning Tree Root Path Cost and Path Cost

The Spanning tree Root Path Cost RPC is the cost from the root of the spanning tree to the current switch. Its value is 0 at the root bridge. It increases as Ethernet BPDU frames go down the path to the non-root bridges.

When a non-root bridge receives the superior BPDU over its Root Port, it increases the Root Path Cost by the Path Cost (aka Port Cost) value.

The table below summarizes the standard Port Cost values:

spanning-tree-protocol-13

Port path cost and root path cost
– Port Path Cost = STP cost of the interface = port cost
– Root Path Cost = cumulative STP costs of interfaces along the way = Sum(port costs)

Spanning Tree Q&A

Why do we use the term “bridge” and not “switch”?

Spanning tree has been there a long time ago, even before the appearance of switches. And the terms have not evolved since then. Some people may use the “switch” term in the Spanning Tree jargon. However, most network engineers still use the old “bridge” term.

What’s the difference between a BPDU frame and a BPDU message?

None. It’s really an Ethernet frame with BPDU information in it. We simply call it a BPDU frame or a BPDU message for simplicity.

What is the purpose of a Designated Port between non-root bridges?

A Designated Port (DP) can be found on root bridges and on non-root bridges.

On root bridges, Designated Ports forwards all frames. On non-root bridges, Designated Ports allow frames to egress the interface towards the next switch, whose port will block and discard the frame, since it’s in the Blocking state.

Spanning Tree Protocol in Wireshark

Wireshark example number 1

Let’s look at a topology that involves three looped switches. In GNS3, I am using vIOS-L2 devices, which are virtual layer 2 IOS images. All switches have the default bridge priority. So it’s the bridge MAC address that will break the tie.

We’ll start all switches and see what happens in the Spanning Tree Root Bridge election. Here is the topology:

spanning-tree-protocol-2015-11-11 05_31_09

Here are the MAC addresses of the switches:

  • vIOS-L2-1 (switch 1): 0000.ab6f.1700
  • vIOS-L2-2 (switch 2): 0000.ab64.1700
  • vIOS-L2-3 (switch 3): 0000.abbd.ce00

According to the spanning tree algorithm, each one of the switches is considered a potential root bridge. We should have at the end the switch vIOS-L2-2 as the root bridge, since it has the lowest MAC address.

In Wireshark, RID is referred to as Root Identifier and BID is referred to as Bridge Identifier.

At bootup, only Switch 1 STP frames are seen on the wire. All switches set Switch 1 as their spanning tree Root Bridge.

spanning-tree-protocol-2015-11-11 05_32_07

Switch 1 is announcing itself as the root bridge, since RID is equal to BID

Switch 2 and Switch 3 receive the Ethernet BPDU frame where Switch 1 is the Root Bridge:

spanning-tree-protocol-2015-11-11 05_34_30

on Switch 2

spanning-tree-protocol-2015-11-11 05_35_21

on Switch 3

Switch 2 too advertises its STP frames. Its Ethernet BPDU frame reaches the other switches. They realize that Switch 2 has sent a superior BPDU. Thus, Switch 2 becomes the root bridge:

spanning-tree-protocol-2015-11-11 05_32_21

Switch 1 is no longer the Root Bridge; it’s switch 2.

spanning-tree-protocol-2015-11-11 05_34_42

on switch 2

spanning-tree-protocol-2015-11-11 05_35_29

on Switch 3

Sometimes you get a Wireshark trace where the root bridge “seems” to flap:

spanning-tree-protocol-2015-11-12 06_04_18 spanning-tree-protocol-2015-11-12 06_05_11

In reality, there is a tiny field that makes the difference: the VLAN ID field. Spanning Tree runs for each VLAN and a separate Root Bridge election occurs on each VLAN. So one switch can be the Root Bridge for VLAN 1 and another switch will be the Root Bridge for VLAN 100.

spanning-tree-protocol-2015-11-12 06_08_22 spanning-tree-protocol-2015-11-12 06_08_44

STP vs RSTP: Topology Change

Topology Change Event Trigger

STP: occurs when a port moves:
– from FWD to BLK
– from BLK to FWD
RSTP: occurs when a nonedge port moves from BLK to FWD
 

Topology Change Detection Time

STP: after MaxAge and no BPDU received (~20sec)–> TCN sent towards Root Bridge.
RSTP: 3 Hellos missed in a row from a neighbor (~6sec)–> Neighbor seen as “down” and MAC addresses learned on that port are flushed.
 

Whenever you need a refresher on your CCNA skills and at the same time review at your own pace, then I would recommend the Lazaro Diaz CCNA course.

Related posts

Switching and Forwarding


Keyboard Banger

Keyboard Banger is a network engineer from Africa. He has been working in network support and administration since 2008. He started writing study notes about certification exams and technology topics a couple of years ago. When he's not writing articles, he can be found wandering on technical forums.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *