A
redundant link network topology uses the Spanning Tree Protocol (STP), which is
a network protocol that is used to avoid loops. In order to prevent loops from
forming in the network, it is used to make sure that there is only one active
path between two network devices.
In
order for STP to function, one of the many accessible paths is chosen as the
"root path," and any further redundant links are then turned off. The
root path is chosen based on a number of factors, which include the root's
shortest path, lowest path cost, and lowest bridge ID. Then, the STP algorithm
decides which links may be activated securely and which ones need to be
disabled.
Spanning
Tree Protocol supports the five port states: forwarding, learning, listening,
blocking, and disabled. It contains the two bits from the flag octet.
STP
has some disadvantages such as a slow convergence time and an inability to
adjust to quick changes in the network topology. In order to overcome these
restrictions, the Rapid Spanning Tree Protocol (RSTP) was created
Advantages of STP:
· It is a mature protocol that has been widely used
in networks for many years.
· It can handle complex topologies and prevent
network loops by blocking redundant links.
· It provides a stable network topology by ensuring
that only one path is active at any given time.
· It is supported by most network devices and can be
configured easily.
· It does not require special hardware or software.
Disadvantages of
STP:
· It has slow convergence time, which can cause
network downtime and performance issues.
· It can lead to inefficient use of network resources
by blocking links even when they are not actually causing a network loop.
· It cannot detect changes in the network topology
quickly and may cause network instability.
· It may require manual configuration and management
in large networks.
STP operation:
· All
switches of the STP domain, first elect a root bridge. The root bridge acts as
a point of reference for all other switches in the network. All ports of the
root bridge remain in the forwarding mode.
· Once the
root bridge is elected, all remaining switches select a single port that has
the shortest path cost to reach the root bridge and marked it as the root port.
· After
selecting the root port, switches determine a single designated port for each
connection.
· If multiple
ports are connected with the same switch or LAN segment, the switch select only
one port that has the lowest path cost and marks it as the designated port.
· Once the
root port and designated ports are selected, the switch blocks all remaining
ports to remove any possible or existing loop from the network.
What is the STP?
STP is a
protocol. It actively monitors all links of the network. To finds a redundant
link, it uses an algorithm, known as the STA (spanning-tree algorithm). The STA
algorithm first creates a topology database then it finds and disables the
redundant links. Once redundant links are disabled, only the STP-chosen links
remain active. If a new link is added or an existing link is removed, the STP
re-runs the STA algorithm and re-adjusts all links to reflect the change.
Root Bridge
A Root
Bridge is the starting point of the STP network topology. To elect a Root
Bridge from all switches of the network, STP uses two parameters; a variable
known as bridge priority and the MAC addresses of participating switches. A
switch that has the lowest bridge priority value, is elected as the root
bridge. If the bridge priority value is the same in all switches, the switch
which has the lowest MAC address is elected as the Root Bridge.
By default,
the bridge priority value is set to 32768 in all Cisco switches. Unless you
change this value, a switch that has the lowest MAC address is elected as the
Root Bridge. If you want a specific switch to be elected as the Root Bridge,
you can set the bridge priority value of that switch to less than 32768.
The
selection process of the Root Bridge happens each time when a network change
occurs like a new switch is added in the network topology, or an existing
switch is removed or the current Root Bridge is failed. If other switches of
the network do not receive BPDUs from the Root Bridge within 20 seconds, they
assume that the Root Bridge has failed. If the current Root Bridge fails,
remaining switches automatically start the election process to choose a new
Root Bridge again.
Non-Root Bridge
Except the
Root Bridge, all remaining switches of the network are considered as the
Non-Root Bridges. Non-Root Bridges receive updates from the Root Bridge and
update their STP databases relatively.
Port Cost
Based on
the connected media link, STP assigns a value to each port of the network. This
value is known as the port cost value. STP uses this value to choose the single
best path when multiple links are available between two switches. It selects
the port which has the lowest port cost value.
Path Cost
Path cost
is an accumulated value of the port costs from the Root Bridge to other
switches in the network. It is always calculated from the Root Bridge. Default
path cost at the Root Bridge is 0. BPDU contains the path cost information.
When the
Root Bridge advertises BPDU out from its interfaces, it sets the path cost to
0. The switch which receives this BPDU increments the path cost by adding the
port cost value of the port on which the BPDU arrived. For example, if the
switch receives the BPDU on the Gigabit interface then the accumulated path
cost will be 4.
0 (Value
which it received from the Root Bridge) + 4 (Port cost value of the interface
on which it received the BPDU) = 4
Now, this
switch sets the accumulated path cost (4) in the BPDU and forwards it. The next
switch which is connected with this switch follows the same rule. For example,
if the next switch receives this BPDU on the Fast Ethernet port, for that
switch, the accumulated path cost will be 23.
4 (Value
which is received) + 19 (Port cost value of the incoming port) = 23.
Root Port
The Root
port is the port that directly connects to the Root Bridge, or has the shortest
path to the Root Bridge. The shortest path is the path that has the lowest path
cost value. Remember that, a switch can go through many other switches to get
the root bridge. So it’s not always the shortest path but it is the fastest path.
Designated Ports
A
designated port is the port that has the lowest port cost value to get on a
given network, compared to other ports on that segment. STP marks the
designated ports as the forwarding ports. Forwarding ports are used to forward
the frames.
Non-Designated
Ports
A
non-designated port is a port that has the higher port cost than the designated
port. STP marks the non-designated port as the blocking port. Blocking ports
are used to remove loops.
STP port states
All ports
on a STP running switch, go through the four different states; blocking,
listening, learning, and forwarding. Through these states, the switch not only
understands the network topology but also calculates the path cost value and
based on that value elects the designated and non-designated ports. After these
states, the switch is considered as the STP convergent switch. Let’s understand
each state in detail.
STP Blocking
state
When we
power on a switch, the switch puts all of its ports in this state. In this
state, the switch only listens and processes the BPDUs. Except the BPDUs, it
drops all other frames. From the incoming BPDUs, it learns the network topology
and determines the ports which will work as the root ports, as the designated
ports, and as the blocked ports.
All ports
remain in this state for twenty seconds. After twenty seconds, only the root
port and designated ports move into the next state. Remaining ports stay in
this state.
STP Listening
state
In this
state, ports still listen and process only BPDUs. All other frames except BPDUs
are dropped. The switch double checks the layer 2 topology to make sure that no
loops occur in the network before processing the data frames. Ports remain in
this state for fifteen seconds.
STP Learning
state
Only the
root port and designated ports enter into the learning state from the listening
state. In this state, ports still listen and process BPDUs. However, in this
state, ports start processing user frames. Switch examines the source address
of user frames and updates its CAM table but it does not forward any user frame
to the destination port. Ports stay in this state for fifteen seconds.
STP Forwarding
state
In this
state, the switch listens and processes both BPDUs and user frames. It uses
BPDUs to monitor the network topology. By reading the source address field of
users’ frames it also builds and updates CAM table entries. This state is also
referred as the convergence.
STP Disable
state
This state
applies to all ports which are either manually shut down or removed from the
STP by an administrator. All unplugged ports also remain in this state. Any
port which belongs to this state does not participate in the STP operation.