17: Spanning Tree Protocol

To avoid any loops in a switched network, we use the STP (Spanning Tree Protocol). This is done by blocking the traffic on all the redundant links.

Loops in a switched network will cause a ‘broadcast storm’, which will destroy the network performance by consuming the entire network bandwidth.

Broadcast storm

In the following network, suppose that ‘computer A’ sent a broadcast,

Image2465.JPG Figure 17.1: a broadcast storm

When ‘computer A’ sends a broadcast frame, the switch will forward it through all of its ports. Therefore, it will reach SW2 through the two links that connects SW2 with SW1. Then, SW2 will flood the broadcast frame out of all its ports. Therefore, it will reach SW1 through the two links that connects it with SW2…we have a broadcast storm.

STP will simply block traffic on one of the two links that connect between the SW1 and the SW2, which will prevent the broadcast storm.

STP terms

We have to understand the following terms in order to be able to understand the operation of the STP.

Image2473.JPG Figure 17.2: a switched network

BPDU (Bridge Protocol Data Unit): switches running the STP send the BPDU frames every regular interval. This is done to exchange the information with other switches.

Bridge ID (BID): the BID is a combination of the switch priority and the switch MAC address.

‘BID = SW priority.SW MAC address’

The default switch priority = 32768 (which equals to the hexadecimal number 0x8000).

The administrator can manually configure the switch priority using the following command,

Switch(config)#spanning-tree vlan 1 priority SW priority

Port ID: every switch port has a port ID.

The port ID is a combination of the port priority and the port number.

‘Port ID = port priority.port number’

The port priority can be a number in the range ‘0:255’.

The default port priority = 128

Link cost: It is a value given to every link depending on its bandwidth (BW).

BW

Cost

10 Gbps

2

1 Gbps

4

100 Mbps

19

10 Mbps

100

Table 17.1: the link cost

Root Bridge: the root Bridge is the switch that has the lowest bridge ID (BID) in the switched network.

Root port: the root port is the port that has the shortest path (least cost path) to the root bridge.

Designated port: the designated port is the port that has the shortest path (least cost path) to the root bridge in every network segment.

17.1 STP operation

To learn the operation of the STP, suppose that we have the network in figure(17.3).

Image2508.JPG Figure 17.3: STP operation

In figure (17.3), every switch has its BID written on it, and every link has its BW in Mbps written on it.

The following is the operation of the STP to remove all redundant links,

  1. 1. The switch with the lowest BID is elected as the ‘Root Bridge’, and all ports in this switch are considered ‘designated ports’, as seen in figure (17.4).

Image2517.JPG Figure 17.4: STP operation

  1. 2. Every switch elects its ‘root port’ by finding the port that has the least cost to the root bridge, as seen in figure (17.5).

Image2531.JPG Figure 17.5: STP operation

  1. 3. Port with the least cost path to the root bridge in every network segment is elected as a ‘Designated port’, as seen In figure (17.6).

5835.jpgFigure 17.6: STP operation

  1. 4. All non-root and non-designated ports are put in the ‘blocking state’, where it does not forward any frames, as seen in figure (17.7).

Image2544.JPG Figure 17.7: STP operation

Now, the STP has removed all the redundant links that exist in the switched network.

Election criteria for the ‘root ports’ and the ‘designated ports’

The election criteria are the port that has the lowest cost path to the root bridge.

If the costs are equal, the port that exists in the switch that has lowest BID.

If the BIDs are equal, the port that has the lowest PID.

You can view the STP statistics using the following command,

Switch#show spanning-tree

17.2 STP port states

The ports in the STP protocol may exist in one of the following states; the blocking state, the listening state, the learning state, and the forwarding state.

17.2.1 ‘Blocking’ state

In this state, the port does not forward any frames; it only receives BPDUs.

If the port that is in the ‘blocking state’ did not receive any BPDU during the ‘maximum age time’, which by default equals to 20 sec., the port will enter to the ‘listening state’.

17.2.2 ‘Listening’ state

In this state, the port does not forward any frames; it only receives BPDUs to determine the port role in the STP.

The port will remain in the ‘listening state’ for a ‘forward delay time’, which by default equals to 15 sec., and then the port will enter to the ‘learning state’.

17.2.3 ‘Learning’ state

In this state, the port does not forward any frames; it receives BPDUs to learn all the network paths.

The port will remain in the ‘learning state’ for a ‘forward delay time’, which by default equals to 15 sec., and then it will enter to the ‘forwarding state.

17.2.4 ‘Forwarding’ state

In this state, the port forwards and receives all the frames.

Generally, in the STP, the port may stay only in the ‘blocking state’ or in the ‘forwarding state’.

The ‘listening state’ and the ‘forwarding state’ are transient states between the ‘blocking state’ and the ‘forwarding state’.

STP convergence time

It is the time consumed until all of the ports are either in a ‘blocking state’ or in a ‘forwarding state’.

As you can observe, the time consumed for a port to transit from the ‘blocking state’ to the ‘forwarding state’ is a long time, (max age time ‘20sec.’ + forward delay time ‘15 sec.’ + forward delay time ‘15 sec.’). Therefore, the port may need about 50 sec. to transit from the ‘blocking state’ to the ‘forwarding state’, which is a very long time. This problem may affect the network stability.

The solutions for this long time problem are developed. Those solutions will be discussed in the following points (‘port fast’ and ‘rapid STP’).

17.3 STP port fast

The ‘STP port fast’ is used to speed up the convergence time on certain ports. This is used when the network administrator is sure that this port will not form any switching loop, as an example, the ports that are connected to an end device.

The ‘STP port fast’ allows the port to transit directly from the ‘blocking state’ to the ‘forwarding state’ without passing through the ‘listening state’ and the ‘learning state’, which reduces the transit time.

17.3.1 Port fast configuration

Suppose that we have the network in figure (17.8),

Image2551.JPG Figure 17.8: STP port fast

The network administrator may configure the ‘STP port fast’ on ‘fa0/2’ on ‘SW2’. This is because that, this port is connected to an end device.

To configure the port fast, we use the following commands,

Switch(config)#interface interface number

Switch(config-if)#spanning-tree portfast

17.3.2 Features recommended to be used on ports that have ‘STP port fast’ enabled

BPDU guard

If a BPDU is received on the port that has the ‘STP port fast’ enabled, the ‘BPDU guard’ puts this port in the ‘error disabled’ state.

This is because of that, if there is any BPDU received on a port, this means that this port is connected to another switch; hence, this port may form a loop.

BPDU filter

If a BPDU is received on the port that has the ‘STP port fast’ enabled, the ‘BPDU filter’ takes the port out of the ‘STP port fast’ and forces it to be a part of the STP topology.

This is because of that, if there is any BPDU received on a port, this means that this port is connected to another switch and this port may form a loop.

17.4 ‘RSTP’, ‘PVSTP+’ and ‘PVRST+’

17.4.1 ‘RSTP’ (Rapid STP)

The RSTP, which is the ‘IEEE802.1w’ protocol, speeds up the convergence time. This means that a switch that is running RSTP has a faster convergence time than a switch that is running STP.

RSTP do the following,

It designates an ‘alternative port’, which is considered an alternative to the ‘root port’ on every switch. This is done in order to use this alternative port when the ‘root port’ is unavailable.

Designating a ‘backup port’ for the ‘designated port’ in order that when the ‘designated port’ is down for any reason, this ‘backup port’ becomes the ‘designated port’.

The switches that are running the RSTP can work with the switches that are running the STP. This is because of that, the RSTP is compatible with the STP.

RSTP port states

The ports that exist in a switch that is running the RSTP may be in one of the following states,

Discarding: all incoming frames are dropped.

Learning: do not forward any frames. Only receive BPDUs to learn the network paths.

Forwarding: forward and receive all the frames.

RSTP configuration

To configure the RSTP on a switch, we use the following command,

Switch(config)#spanning-tree mode rapid-pvst

17.4.2 ‘PVSTP+’ (Per-VLAN STP+)

In the ordinary STP, the entire switched network has only one STP instance.

In the PVSTP+, every VLAN in a switched network has its own STP instance.

Suppose that we have the network in figure (17.9),

Image2559.JPG Figure 17.9: Per-VLAN STP+

Using the PVSTP+, VLAN1 will have its own STP instance, and VLAN2 will have its own STP instance.

• PVSTP+ is enabled by default on the switches that are running the STP.

• PVSTP+ uses the ‘Extended BID’ instead of the ‘BID’, which was in the STP.

‘Extended BID = Switch priority.VLAN ID (VID).MAC address’

17.4.3 ‘PVRST+’ (Per-VLAN RSTP+)

In the PVRST+, every VLAN in a switched network has its own RSTP instance.

Suppose that we have the network in figure (17.10),

Image2566.JPG Figure 17.10: Per-VLAN RSTP+

Using the PVRST+, VLAN1 will have its own RSTP instance, and VLAN2 will have its own RSTP instance.