Spanning Tree Protocol
Spanning Tree Protocol
Overview
• Terminology
• Layer 2 loops
• Purpose of STP
• STP Operations
• STP Reacting to a Link Failure
Complete Graph
• A complete graph is a graph in which each pair
of node is connected by a link
Spanning Tree
• A spanning tree is a graph in which all nodes are
connected by a minimum number of links
• For a 3-node graph, three different spanning
trees can be formed:
STP Operations
Steps to a Loop-Free Topology
Using the STA, STP builds a loop-free topology in a four-step process:
STP Operations
Bridge ID(1/2)
• Originally, Bridge ID comprises of two parts: bridge priority and MAC address
• With the introduction of VLAN, it is necessary to run multiple instances of STP in order to accommodate
each network. To accommodate the additional VLAN information, the Extended System ID field was
introduced, borrowing 12 bits from the original Bridge Priority
• then necessary to run multiple instances of STP in order to accommodate each network
source: www.firewall.cx
STP Operations
Bridge ID (2/2)
• Bridge Priority: The default priority value for all Cisco switches is the decimal value 32768. The range is 0 to
61440 in increments of 4096. A lower bridge priority is preferable. A bridge priority of 0 takes precedence
over all other bridge priorities.
• Extended System ID: The extended system ID value is a decimal value added to the bridge priority value to
make up the BID used to elect the root bridge
• MAC address: When two switches are configured with the same priority and have the same extended
system ID, the switch having the MAC address with the lowest value, expressed in hexadecimal, will have
the lower BID.
source: www.firewall.cx
STP Operations
BPDU Frame Structure
STP Operations
1. Elect the Root Bridge
• The STA designates a single switch as the root
bridge and uses it as the reference point for all path
calculations. Switches exchange BPDUs to build the
loop-free topology beginning with selecting the
root bridge.
• All switches in the broadcast domain participate in
the election process. After a switch boots, it begins
to send out Hello BPDU frames every two seconds.
These BPDU frames contain the BID of the sending
switch and the BID of the root bridge, known as the
Root ID.
• The switch with the lowest BID will become the
root bridge. At first, all switches declare themselves
as the root bridge with their own BID set as the
Root ID. Eventually, the switches learn through the
exchange of BPDUs which switch has the lowest
BID and will agree on one root bridge.
• Note: In case the priorities of all switches are the
same, the switch with the lowest MAC address will
become the root bridge.
STP Operations
Determine the Root Path Cost
• When the root bridge has been elected for a given spanning tree instance, the STA starts determining the best paths to the root
bridge from all destinations in the broadcast domain. The path information, known as the internal root path cost, is determined by
the sum of all the individual port costs along the path from the switch to the root bridge.
• When a switch receives the BPDU, it adds the ingress port cost of the segment to determine its internal root path cost.
• The default port costs are defined by the speed at which the port operates. The table shows the default port costs suggested by
IEEE. Cisco switches by default use the values as defined by the IEEE 802.1D standard for both STP and RSTP.
• Although switch ports have a default port cost associated with them, the port cost is configurable. The ability to configure
individual port costs gives the administrator the flexibility to manually control the spanning tree paths to the root bridge.
10 Gbps 2 2,000
1 Gbps 4 20,000
STP Operations
2. Elect the Root Ports
• After the root bridge has been determined, the STA
algorithm is used to select the root port. Every non-
root switch will select one root port. The root port is
the port closest to the root bridge in terms of overall
cost to the root bridge. This overall cost is known as
the internal root path cost.
• The internal root path cost is equal to the sum of all
the port costs along the path to the root bridge, as
shown in the figure. Paths with the lowest cost
become preferred, and all other redundant paths are
blocked. In the example, the internal root path cost
from S2 to the root bridge S1 over path 1 is 19 while
the internal root path cost over path 2 is 38. Because
path 1 has a lower overall path cost to the root
bridge, it is the preferred path and F0/1 becomes the
root port on S2.
STP Operations
3. Elect Designated Ports
• Every segment between two switches will have one
designated port.
• All ports on the root bridge are designated ports.
• If one end of a segment is a root port, the other end is a
designated port.
• All ports attached to end devices are designated ports.
• On segments between two switches where neither of the
switches is the root bridge, the port on the switch with
the least-cost path to the root bridge is a designated port.
• Since S2 and S3 have the same path cost to the root
bridge, STP will use the bridge ID as a tie breaker.
Assuming S2 has a lower BID, its F0/2 port will thus be
chosen as the designated port
• Note that a designated ports are in forwarding state ports
are in forwarding state
• S2 has a lower BID. Therefore, the F0/2 port of S2 will be
chosen as the designated port.S2 andS3 have the same
path cost to the root bridge. The spanning tree algorithm
will use the bridge ID as a tie breaker. and S3 have the
same path cost to the root bridge. The spanning tree
algorithm will use the bridge ID as a tie breaker.
STP Operations
4. Elect Alternate (Blocked) Ports
• If a port is not a root port or a
designated port, then it becomes
an alternate (or backup) port.
Alternate ports are in discarding or
blocking state to prevent loops.
• Blocked port can still receive
frames, but it will not forward nor
send frames. It simply drops them.
• In the figure, the STA has configured
port F0/2 on S3 in the alternate
role. Port F0/2 on S3 is in the
blocking state and will not forward
Ethernet frames. All other inter-
switch ports are in forwarding state.
This is the loop-prevention part of
STP.
root root
bridge If link AC suddenly fails bridge
A A
dp dp dp
dp
rp rp bp
rp
B B C
dp bp C dp rp
STP Timers
• Recall that a BPDU frame contains several timers
Port States
STP facilitates the logical loop-free path throughout the broadcast domain. The spanning tree is determined through the
information learned by the exchange of the BPDU frames between the interconnected switches. If a switch port transitions directly
from the blocking state to the forwarding state without information about the full topology during the transition, the port can
temporarily create a data loop. For this reason, STP has five ports states, four of which are operational port states as shown in the
figure. The disabled state is considered non-operational.
Forwarding Data
Port State BPDU MAC Address Table
Frames
Blocking Receive only No update No
Listening Receive and send No update No
Learning Receive and send Updating table No
Forwarding Receive and send Updating table Yes
None sent or
Disabled No update No
received