0% found this document useful (0 votes)
13 views

Spanning Tree Protocol

Uploaded by

tsuiii2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Spanning Tree Protocol

Uploaded by

tsuiii2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Department of Electrical Engineering City University of Hong Kong

Spanning Tree Protocol


(STP)

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 1


Department of Electrical Engineering City University of Hong Kong

Overview

• Terminology
• Layer 2 loops
• Purpose of STP
• STP Operations
• STP Reacting to a Link Failure

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 2


Department of Electrical Engineering City University of Hong Kong

Terminologies from Graph Theory


• Graph theory is a branch of mathematics
• A graph is collection of links and nodes

• A computer network can be modelled as a


graph

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 3


Department of Electrical Engineering City University of Hong Kong

Complete Graph
• A complete graph is a graph in which each pair
of node is connected by a link

• A fully meshed network is modelled as a


complete graph

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 4


Department of Electrical Engineering City University of Hong Kong

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:

• Features of a spanning tree:


– all nodes are connected but there is no loop
– removing a link will leave some nodes disconnected

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 5


Department of Electrical Engineering City University of Hong Kong

Redundancy in Layer 2 Switched


Networks
• Redundancy is an important part of the hierarchical
design for eliminating single points of failure and
preventing disruption of network services to users.
• Redundant networks require the addition of physical
paths. Having alternate physical paths for data to
traverse the network makes it possible for users to
access network resources, despite path disruption
• However, redundant paths in a switched Ethernet
network may cause Layer 2 loops, which may cause
MAC address table instability and broadcast storm

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 6


Department of Electrical Engineering City University of Hong Kong

Layer 2 Loops (1/2)


• Unknown unicast frames sent onto a looped network can result in:
– duplicate frames arriving at the destination device
– instability of MAC address table on a switch
• Refer to CCNA SRW Chapter 5, slide 5.1.5, for an animation of this problem

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 7


Department of Electrical Engineering City University of Hong Kong

Layer 2 Loops (2/2)


• Similarly, broadcast frames (such as ARP requests) are affected by loops, leading to
a broadcast storm
• A broadcast storm is an abnormally high number of broadcasts, disabling a
network within seconds by overwhelming switches and end devices
• Refer to CCNA SRW Chapter 5, slide 5.1.6, for an animation of this problem

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 8


Department of Electrical Engineering City University of Hong Kong

Spanning Tree Protocol (STP)


• STP is a Layer 2 protocol that runs on switches to build
a loop-free logical topology
• STP is based on an algorithm invented by Radia
Perlman while working for Digital Equipment
Corporation, and published in the 1985 paper "An
Algorithm for Distributed Computation of a Spanning
Tree in an Extended LAN.” Her spanning tree algorithm
(STA) creates a loop-free topology by selecting a single
root bridge where all other switches determine a single
least-cost path.
• There are various flavors of Spanning Tree Protocols,
IEEE 802.1D is the original standard protocol

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 9


Department of Electrical Engineering City University of Hong Kong

Purpose of STP (1/2)


• STP is a loop-prevention network
protocol that allows for
redundancy while creating a loop-
free Layer 2 topology.
• STP logically blocks physical loops
in a Layer 2 network, preventing
frames from circling the network
forever.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 10


Department of Electrical Engineering City University of Hong Kong

Purpose of STP (2/2)

• With STP recalculation, a


blocked link can be activated in
case an active link breaks
• It compensates for a failure in
the network by recalculating
and opening up previously
blocked ports
• Hence, it provides fault
tolerance for a network

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 11


Department of Electrical Engineering City University of Hong Kong

STP Operations
Steps to a Loop-Free Topology
Using the STA, STP builds a loop-free topology in a four-step process:

1. Elect the root bridge.


2. Elect the root ports.
3. Elect designated ports.
4. Elect alternate (blocked) ports.
• During STA and STP functions, switches use Bridge Protocol Data Units (BPDUs) to share information about
themselves and their connections. BPDUs are used to elect the root bridge, root ports, designated ports,
and alternate ports.
• Each BPDU contains a bridge ID (BID) that identifies which switch sent the BPDU. The BID is involved in
making many of the STA decisions including root bridge and port roles.
• The BID contains a priority value, the MAC address of the switch, and an extended system ID. The lowest
BID value is determined by the combination of these three fields.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 12


Department of Electrical Engineering City University of Hong Kong

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

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 13


Department of Electrical Engineering City University of Hong Kong

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

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 14


Department of Electrical Engineering City University of Hong Kong

STP Operations
BPDU Frame Structure

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 15


Department of Electrical Engineering City University of Hong Kong

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.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 16


Department of Electrical Engineering City University of Hong Kong

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.

STP Cost: IEEE RSTP Cost: IEEE


Link Speed
802.1D-1998 802.1w-2004

10 Gbps 2 2,000
1 Gbps 4 20,000

100 Mbps 19 200,000


10 Mbps 100 2,000,000

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 17


Department of Electrical Engineering City University of Hong Kong

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.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 18


Department of Electrical Engineering City University of Hong Kong

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.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 19


Department of Electrical Engineering City University of Hong Kong

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.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 20


Department of Electrical Engineering City University of Hong Kong

STP Reacting to a Link Failure

STP adapts to a new topology

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

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 21


Department of Electrical Engineering City University of Hong Kong

STP Timers
• Recall that a BPDU frame contains several timers

STP convergence requires three timers, as follows:


• Hello Timer -The hello time is the interval between BPDUs. The default is 2 seconds but can be modified to
between 1 and 10 seconds.
• Forward Delay Timer -The forward delay is the time that is spent in the listening and learning state. The
default is 15 seconds but can be modified to between 4 and 30 seconds.
• Max Age Timer -The max age is the maximum length of time that a switch waits before attempting to
change the STP topology. The default is 20 seconds but can be modified to between 6 and 40 seconds.
Note: The default times can be changed on the root bridge, which dictates the value of these timers for the STP
domain.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 22


Department of Electrical Engineering City University of Hong Kong

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.

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 23


Department of Electrical Engineering City University of Hong Kong

Operational Details of Each Port State

The table summarizes the operational details of each port state

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

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 24


Department of Electrical Engineering City University of Hong Kong

STP Reacting to a Link Failure

• Once link AC fails, Switch C stops receiving Hello BPDU. It does


root
nothing but waiting for Maximum Age, which is 20 seconds by
bridge
default A
• After this waiting period, STP starts taking action
dp dp
• First, the blocked port of switch C is changed from the blocking state
to the listening state. During this state, the port will not forward rp rp
frames, but just listening for any change in the network. B
dp bp C
• The port stays in listening state for 15 seconds, which is the default
value of Forward Delay.
• Then, the port changes to the learning state, in which it still does not
forward frames, but learning MAC addresses and updating MAC
address table
• The port stays in learning state for the amount of time specified by
Forward Delay
• Then, the port becomes the root port and moves to the forwarding
state. Also the original root port of switch C becomes a blocked port
• This self-healing process takes totally 50 seconds

EE3009 Data Comm. & Networking Spanning Tree Protocol Slide 25

You might also like