Spanning Tree Protocol

STP, which stands for Spanning Tree Protocol, is a network layer protocol that helps in building a logical loop-free topology for the Ethernet networks. Spanning Tree Protocol uses clever mechanisms to prevent switching loops by virtually disconnecting redundant links. In this article, we will cover some of the basic concepts around the spanning tree protocol and how it works.

How Spanning Tree Protocol works

Basically, each switch port on a network detects the MAC address of a host that is directly connected. It then sends messages to other switches on the network to inform them of the information required on how to get the PC on that switch port. The problem starts when another switch discovers the same host or PC with the same MAC address. Over time all switches on the network will start flooding messages on the network of their discovery and how to get to the same PC and a loop has formed. When too many computers try to send at the same time, overall network performance is affected and can bring all traffic to a near halt.

STP ensures that there is only one logical path between all destinations on the network by intentionally blocking redundant paths that could cause a loop.

When a switch port detects a loop in the network, it blocks (A port is considered blocked when network traffic is prevented from entering or leaving that port) one or more redundant paths to prevent a loop from forming.

To stop a loop from forming, STP chooses one switch to be ‘Root Bridge’ on the network. Then other switches select one of its ports as ‘Root Port’ then, a ‘designated port’ is chosen on each segment and all other ports are closed down.

The spanning tree uses a special algorithm that finds and disables any redundant links and builds a topology database. All redundant links are disabled and only the STP-chosen links remain active. If a new link is added or an existing link is removed, the STP re-runs the algorithm and re-adjusts all links to reflect the change.

It is broken down into two steps:

Step 1: The algorithm determines from the best received BPDU message, which link is chosen as the best option to use.

Step 2: Once it selects the best link to send, it compares its choice with possible configuration messages from the non-root-connections it has. If the best option from step 1 isn’t better than what it receives from the non-root-connections, it will prune that port.

Root Bridge Election procedure

All the switches in the network will initially declare themselves as the root bridge and will send out a BPDU to all other switches on the network. The switch that has the BPDU with the lowest bridge ID will be considered superior. Now the switch receiving the superior BPDU will make changes in its own BPDU and carry forward to its neighbour switches. This process goes on until all the switches are satisfied with which bridge have the lowest bridge I’d and hence that switch will be declared as the root bridge.

Port Statuses in STP?

Disabled

Ports which are disabled.

Following are the different states that a switch port might be at any given point in time:

Forwarding port

A port that is full-fledged working.

Learning port

A port that is not forwarding the frames but it is learning the MAC addresses.

Listening Port

A port that is neither forwarding the frames nor learning the MAC addresses.

Discarding port

A port that does not forward any data.

How are these ports determined

The root bridge of the spanning tree is the bridge with the smallest (lowest) bridge ID. The bridge ID contains both numbers combined together – Bridge priority + MAC (32768.0200.0000.1111). When comparing two bridge ids the Bridge priority is compared first and then the MAC address. To allow for the admin control over which bridge is honoured the root bridge title you can manually change the default bridge priority of 32768 to lower number as a multiple of 4096.

Once the root bridge is determined, the next task is to determine the best path or least cost paths to the root bridge.

Determine the least cost paths to the root bridge. The cost of traversing a path to the root bridge is calculated by the the sum of each cost of the segments on the path. Different technologies have different default costs for network segments. Each bridge determines the cost of each possible path from itself to the root. From these, it picks one with the smallest cost (a least-cost path). The port connecting to that path becomes the root port (RP) of the bridge. To ensure the path is used all other root paths are disabled. Any active port that is not a root port or a designated port is a blocked port (BP).

Configuration

Cisco switches runs STP by default, no configuration needed. If you would like to change the configuration you can do so by typing spanning-tree mode <selected mode> in global configuration mode. The network administrator then adjusts spanning tree operation to control its behaviour by first electing a root bridge, which becomes the central reference point for STP. Next, the administrator will identify root ports and designated ports.

STP advantages/disadvantages

Advantages

  • Easy to use.
  • Proven technology.
  • Offers wide support for bridges and switches.
  • Provides link redundancy while simultaneously preventing undesirable loops.
  • Offers various backups that become active if the main connection experiences hiccups.

Disadvantages

  • As data centers increase use of virtualization technology, STP may not be able to handle increased input/output (I/O) demands.
  • Full network capacity is not realized when using STP. Even when there are equal-cost multiple paths on a network, all traffic flows along a single path as defined by a spanning tree. This restriction of traffic means alternative, and perhaps more direct, paths are blocked.

Summary

Spanning Tree Protocol is one of those protocols that are used by most people without them even knowing that it exists, but without it modern switched networks could not operate. Hopefully the contents of this article have been able to introduce some basic concepts used by STP to eliminate switch loops.

SuperTechman – Network Security – Best Practices

Leave a Reply

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