What is STP (Spanning Tree Protocol) and How to Configure STP

What is STP (Spanning Tree Protocol) and How to Configure STP

What is STP

A well-built communications network characteristic is that it is resilient, which means that through redundancy the network needs to be able to handle a link failure or a device. Failure of a single point can be eliminated through a redundant topology by using multiple devices, multiple links, or both. In a redundant switched network the STP (Spanning Tree Protocol) is used to prevent loops.

what is STP
STP Configuration on Old and Latest Switches


In a switched network the redundancy would introduce the following issues without STP:

v MAC database instability: Content instability of the table results in MAC address from the same frame copies being received on different switch ports.
v Broadcast storms: It means endlessly the broadcasts floods by each switch.
v Transmission of multiple frames: Multiple unicast frame copies may be delivered to the destination causing unrecoverable errors.

The standard of STP is 802.1d defined by the committee standard IEEE, and it works on OSI Data-Link Layer. In the locking state, the STP places certain ports so that they don’t listen to flood or forward data frames. A tree is created by the STP to ensure that in each network segment, there is only one path at any one time. Then in connectivity, if any segment experiences a disruption, a new tree the STP builds by activating the inactive previously, but path redundant.

STP Algorithm

The algorithm of the STP is, the interface chosen by the STP that should be placed into a Forwarding state. The interface that is not chosen to be in a Forwarding state, then the STP places the interface in a blocking state. By default, every 2 seconds the STP configuration messages are exchanged by the switches using a multicast frame called the BPDU (Bridge Protocol Data Unit). The BID (Bridge ID) is the piece of information included in the BPDU.

In each switch, the BID is unique and is composed of the bridge MAC address (6 bytes) and the priority value (2 bytes), and 32768 is the default priority. The switch with the lowest BID will be the root bridge, and if the switch default value is not changed the switch with the lowest MAC address will become root.

The interfaces that choose by the STP are placed into a Forwarding state this process is sometimes called the STA (Spanning-Tree Algorithm), and the interfaces that are not chosen by the STP will be in a blocking state, which means STP simply picks which interface should be placed to be in a Forwarding state.

Three criteria are used by the STP to choose whether to put an interface in a forwarding state:

v STP puts the root switch all working interfaces in Forwarding State when the STP elects a root switch.
v The ports of each NonRoot switch consider having the least administrative cost between the root switch and itself.
v In the same Ethernet segment many switches can attach. The lowest administrative cost of the switch from itself to the root bridge, as compared with the other same segment attach switches, is placed in a Forwarding State. The switch’s lowest administrative cost on each Ethernet segment is called the DB (Designated Bridge), and the interface of that bridge attached to that segment is called DP (Designated Port).

Note: To reach the root bridge, the cost is determined by the Port bandwidth. All working interfaces of the root will forward frame because these working interfaces are placed in a Forwarding state by the root, and all other interfaces are placed in a blocking state.

If there are multiple switches in the network, then only one switch will become the Root Bridge and all others will be a NonRoot bridge.

Root Bridge

The Root Bridge is the bridge in the network with the best bridge ID. For example, if there are two switches in the network then the election of Root Bridge depended on two decisions. First, if both switches are from the same company model then the decision will be made on priority numbers, by default VLAN 1 is configured on every switch and the priority number of the switch will be 32768 plus the VLAN by default configured, the priority number will become 32769.

The switch with the lowest priority number will become the Root Bridge in the network and the second switch will become the NonRoot Bridge. If both switches have the same priority numbers then the decisions will be depended on the switch’s MAC addresses. The switch with the lowest MAC address will become the Root Bridge in the network and the second one will be NonRoot Bridge. So, the Root Bridge will decide which port is to be blocked and which port is to be put in a Forwarding State in the network.

It means the Bridge ID is the combination of bridge priority and MAC address in the network for Root Bridge selection.


Identify Root Bridge in STP protocol

The STP protocol selects the root bridge device in the network according to the lowest Bridge ID value.

The Bridge ID consists of two sections which are as follows:

The first section is "Bridge Priority". The second section is the physical address (MAC) of the Switch device.

In the virtual settings of Switch devices, the Bridge Priority value for all devices is equal and it is: - 32768.

Therefore the root bridge will be selected according to the Mac address value; the device with less address will become the root bridge.

In most medium to large networks, the network is designed in a way that we want to place a "Switch" device with high specifications according to the needs of the network to be the main device (Root Bridge) and we do not leave the matter because another device is selected automatically.

To do this, we can change the Bridge ID value of the device we want to become the main device (Root Bridge), making its value the lowest among other devices.

Also, if we want to prevent a device from becoming the main device (Root Bridge), we can change the value of the Bridge ID of the device and make it the largest among the other devices, thus it will not be elected to be the main device (Root Bridge).

We notice here that we can change the value of the "Bridge ID" by changing the "Bridge Priority" part of this ID since the physical address part (Mac) cannot be changed.

To change "Bridge Priority" we can use:-

Spanning-Tree VLAN [VLAN ID] Priority [Value]

Where is the [VLAN ID] FAKE NETWORK ID (VLAN). And [Value] is the value of priority, and this priority value ranges from 0 to 61440 with an increase of 4096 each time.

An example of this:-

Spanning-Tree VLAN 1 Priority 28672

We notice that instead of selecting a certain priority value for the Switch device and entering this value by changing the priority to make the device the main Root Bridge device in the network, we can use a simpler and clearer thing to do it, which is:-

Spanning-Tree VLAN [VLAN ID] Root Primary

Where is the [VLAN ID] FAKE NETWORK ID (VLAN). This and we can set a device to be a secondary, a backup, or an alternative device to become the main device (Root Bridge) if the main device (root bridge) malfunctions in the network using:-

Spanning-Tree VLAN [VLAN ID] Root Secondary

Where is the [VLAN ID] FAKE NETWORK ID (VLAN).

 

Identify Root Bridge in STP protocol
Identify Root Bridge in STP protocol



NonRoot Bridge

 The NonRoot bridges are not the root bridge and BPDUs are exchanged by the NonRoot bridges with all bridges and update the topology of the STP database on all switches, providing a measure of defense and preventing loops against link failures.

Root Port

It is the port that connects the NonRoot Bridge with the root bridge, and it always exists on NonRoot Bridge. In the above example, one switch is a root bridge and the second is a NonRoot bridge.

Root Port
Root Port Selection

 If there are two links that are connected from the Root Bridge to NonRoot Bridge, which interface will be the root port on the NonRoot Bridge switch, the decision will be made on NonRoot Bridge interfaces through Root Port Selection.

Root Port Selection

It means if the speed of the interface and wire link is fast the cost will be low. The interface with the lowest cost number will become the root port and the other interface will be on standby means a shutdown. For example, if both links are the same means working on 100 Mbps speed then the cost number will be the same as 19. Now, if the cost number of both links is the same then the decision will be on the lowest port number means the lowest interface number. The lowest port number will become the root port and the second will be on standby or shutdown.

Port Cost and Speed
IEEE Port Cost and Speed Table

The shutdown or standby interface will be active if there is a problem in the root port then the standby interface will become the root port. If both interfaces are active the switching loops will be created and the purpose of STP is to prevent switching loops so one interface will be shut down.

Designated Port

Every connected computer in the Root Bridge will be considered a client, and these connected computer ports will be called designated ports. The Root Bridge all ports will be designated ports because the Root Bridge switch has been considering everyone as a client. The designated port with the lowest cost will be marked as a forwarding port.

Designated Port
Root Bridge Designated Port


Non-Designated Port

The port with a higher cost will be marked as a blocking port. For example in the NonRoot Bridge, if the link of the root port fails then the non-designated port will be active from standby, and also it will be considered a root port and the failing link port will be considered non-designated and will remain shut down until the link cannot troubleshoot and error fixed.

Non-Designated Port
Non -Designated Port

Forwarding Port

Frames will be forwarded through the forwarding port.

Blocked Port

The port will not forward the frames in order to prevent the switching loops, but the port will always listen to frames.

The default port costs defined by IEEE are listed in the below tables, which had to be revised with the advent of 10 Gbps ports:

Default Port Cost Table
IEEE Default Port Cost Table

STP best path selection criteria

The STP protocol implements its work in three steps, which are as follows:-

Step 1: Select a main body Root Bridge Election.

Step 2: Choosing the best path for this main device Best Path Selection.

Step 3: Block Additional Redundant Links Blocking.

In the second step when choosing the best Path, every Non-Root Bridge device chooses the best path for the main device Root Bridge according to a value called Path Cost. The least expensive path is the best path. If paths cost the same Path Cost, the device with the least Sender Bridge ID will choose the path told by it.

If the Sender Bridge ID equals more than one path to the same device, the path that connects to the port on the sender device will choose the least Sender Port ID.

If the Sender Port ID is equal to the same sender port using the Hub device, it will choose the path that connects the local port that has the least Local Port ID.

That is, the criteria used by the STP protocol to choose the best Path are:-


v Path Cost
v Sender Bridge ID
v Sender Port ID
v Local Port ID

STP best path selection criteria
STP best path selection criteria

Basic Configurations on Oldest Model Switches

STP Configuration
STP Configuration on Old Switch

How to Configure STP

how to configure STP
How to Configure STP

Switch 1

Switch>enable

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch (config) #hostname SW1

SW1 (config) #end

SW1#show spanning-tree

Spanning-Tree
Show Spanning-Tree

SW1#


Switch 2

Switch>enable

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch (config) #hostname SW2

SW2 (config) #end

SW2#show spanning-tree

Spanning-Tree
Show Spanning-Tree

SW2#

Basic Configurations on latest Switches

STP Configuration
STP Configuration on Latest Switch

How to Configure STP
How to Configure STP on Latest Switches

Switch 1

Switch>enable

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch (config) #hostname SW1

SW1 (config) #end

SW1#show spanning-tree

Spanning-Tree
Show Spanning-Tree

SW1#


Switch 2

Switch>enable

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch (config) #hostname SW2

SW2 (config) #end

SW2#show spanning-tree

Spanning-Tree
Show Spanning-Tree

SW2#

Search Tags

  1. What is STP protocol and how it works?
  2. What is STP Spanning Tree protocol used for?
  3. What is STP and its types?
  4. How long does it take to configure STP?
  5. How to configure STP in Cisco switch

Get Packet Tracer Lab

 

If you want to configure RSTP, PRSTP, AND PVSTP then visit below link: ðŸ‘‡

How to Configure RSTP

How to Configure PRSTP

How to Configure PVSTP

Post a Comment

0 Comments