Spanning Tree Protocol
© 2004 - iPMAC Informatics Technology J.S.C
Objectives
Describe the problem of looping data
frame in a switched network
Operation of STP to solve the problem
Operation of RSTP to solve the problem
IPMAC
Networking Academy
Spanning Tree Protocol
Broadcast
Storm !!!
Without the Spanning Tree Protocol (STP), frames would loop
for an indefinite period of time in networks with physically
redundant links.
To prevent looping frames, STP blocks some ports from
forwarding frames so that only one active path exists between
any pair of LAN segments (collision domains).
IPMAC
Networking Academy
The Good, the Bad, and the Happy
The Good: the frames do not loop infinitely, which makes
the LAN usable.
The Bad: some traffics travel a longer path through the
network, because a shorter physical path is blocked.
The Happy: the net result is good.
IPMAC
Networking Academy
How Spanning Tree Works
The Spanning Tree Algorithm places each bridge or switch port int
either a forwarding state or a blocking state.
Forwarding means that the interface CAN forward or receive data
frames.
Blocking means that the interface CAN NOT forward or receive
data frames.
The collective set of forwarding ports creates a single path over
which frames are sent between Ethernet segments.
IPMAC
Networking Academy
Spanning Tree Operation
STP’s job is to figure out how to put the correct interfaces into
blocking and forwarding states to prevent loops but allow
frames to be sent between every segment.
1. STP select a root brigde, STP put all interfaces on it in
forwarding state.
2. On each nonroot brigde, STP places the port receiving
lowest-cost BPDU from the root, called root port, in
forwarding state.
3. The bridge forwarding the lowest-cost BPDU onto
segment is the designated bridge for that segment. And
the port attached to segment, designated port, is placed
in forwarding state.
4. All other interfaces are placed in blocking state.
IPMAC
Networking Academy
Electing the Root …
STP begins with each bridge claiming to be the root bridge
by sending STP messages, which are called hello bridge
protocol data units (BPDUs).
The BPDUs contain the following:
The root bridge’s bridge ID – The bridge ID consists of the
bridge’s priority and a MAC address on that bridge. At the
beginning of the root-election process, each bridge claims to be
root, so each bridge advertises itself as root using its own bridge
ID. The lower the priority, the better chance of being root.
The cost to reach the root from this bridge – each bridge
claims to be root, so the value is set to 0, which is this bridge’s
cost to reach itself. The lower the cost, the better the path.
The bridge ID of the sender of this BPDU – regardless of
whether the bridge sending the BPDU is the root.
IPMAC
Networking Academy
… and Discovering Root Ports …
The bridges elect a root bridge based on the bridge IDs in
the BPDUs.
If a bridge hears of a better candidate, it stops advertising
itself as root and starts forwarding the hello sent by the
better candidate.
Eventually someone wins.
The root bridge is the bridge with the lowest numeric value
for the bridge ID.
Each switch has one root port, which is the port receiving the
least-cost BPDU from the root.
STP places the root port int forwarding state.
IPMAC
Networking Academy
… and Discovering Designated Ports
If an interface advertises the lowest-cost hello onto a LAN
segment, STP places it in forwarding state.
That interface is called designated port.
The cost is calculated by adding the cost in the received hello
to the cost of the interface on which the hello was received.
If the cost were the same, the lower bridge ID of the switch
sending the BPDUs to the segment would become the
designated bridge.
The bridge has the designated port becomes the designated
bridge.
All other port are in blocking state.
IPMAC
Networking Academy
Spanning Tree Operation (The result)
One root bridge per network (Forwarding)
One root port per nonroot bridge (Forwarding)
One designated port per segment (Forwarding)
Nondesignated ports are unused (Blocking)
IPMAC
Networking Academy
Default Port Costs
Port costs can be configured, or you can use the default
values.
The IEEE revised the cost values because the original
values did not anticipate the growth of Ethernet to
support 10-Gigabit Ethernet.
Ethernet Speed Original IEEE Cost Revised IEEE Cost
10 Mbps 100 100
100 Mbps 10 19
1 Gbps 1 4
10 Gbps 1 2
IPMAC
Networking Academy
Reacting to Changes in the Network
The STP topology does not change unless the network topology
changes.
The root bridge sends a new hello
BPDU every 2 seconds by default.
Each bridge uses this repetitive hearing
of hello as a way to know that its path
to the root is still working.
IPMAC
Networking Academy
Topology Change Notification (TCN)
Each bridge uses the repetitive hearing of hello BPDU as a way
to know that its path to the root is still working.
When a bridge ceases to receive the hellos for an entire
MaxAge time, something has failed, so it reacts and starts the
process of changing the spanning tree.
This bridge flushes its address table because the location of
MAC addresses might have changed.
When a bridge needs to signal a topology change, it starts to
send TCN BPDUs on its root port.
The designated bridge receives the TCN, acknowledges it,
remove the MAC table entries, and generates another one for
its own root port.
IPMAC
Networking Academy
Optional STP Features
EtherChannel combines from two to eight parallel Ethernet
trunks between the same pair of switches, bundled into an
EtherChannel.
STP treats an EtherChannel as a single link, so if at least one of
the links is up, STP convergence does not have to occur.
Without EtherChannel, if you have multiple parallel links
between two switches, STP blocks all the links except one.
With EtherChannel, all the parallel links can be up and working
at the same time, while reducing the number of times STP must
converge, which in turn makes the network more available.
IPMAC
Networking Academy
Optional STP Features (cont)
PortFast allows a switch to place a port in forwarding state
immediately when the port active physically.
The only ports on which you can safely enable PortFast are
ports on which you know that no bridges, switches, or other
STP-speaking devices are connected.
PortFast is most appropriate for connections to end-user
devices.
If you turn on PortFast for end-user devices, when an end-user
PC boots, as soon as the Ethernet card is active, the switch port
can forward traffic.
Without PortFast, each port must wait MaxAge plus twice
Forwarding Delay, which is 50 seconds by default.
Coming up ... RSTP >>
IPMAC
Networking Academy
Rapid Spanning Tree
RSTP (802.1w) works just like STP (802.1d) in several
ways:
It elects the root switch using the same parameters
and tiebreakers.
It elects the root port on nonroot switches with the
same rules.
It elects designated ports on each LAN segment with
the same rules.
It places each port in either forwarding or blocking
state – although RSTP calls blocking state “discarding”.
RSTP can be deployed alongside traditional 802.1d STP
bridges and switches.
IPMAC
Networking Academy
RSTP Link and Edge Types
Link-type point-to-point
Link-type shared
Edge-type
RSTP reduces convergence time for link-type point-to-point and
edge-type connections.
It does not improve convergence over link-type shared
connections.
IPMAC
Networking Academy
RSTP Port Roles
RSTP designates ports that receive suboptimal BPDUs as
alternate ports.
If a switch has two links to the same segment, it places one of
two ports in forwarding state and the other, backup port, in
discarding state.
IPMAC
Networking Academy
RSTP Convergence
Edge-Type Behavior and PortFast
RSTP improves convergence for edge-type connections
by immediately placing the port in forwarding state
when the link is physically active.
Link-Type Shared
RSTP doesn’t do anything differently from STP on link-
type shared links.
Link-Type Point-to-Point
RSTP improves convergence over full-duplex links
between switches – the links that RSTP calls “link-type
point-to-point.”
IPMAC
Networking Academy
RSTP Convergence
RSTP recognizes the loss of the path to the root bridge in
3 times the hello timer – 6 seconds.
RSTP removes the need for listening state and reduces
the time required for learning state by actively discovering
the network’s new state.
STP passively waits on new BPDUs, and reacts to them,
during the listening and learning states.
With RSTP, the switches negotiate with neighboring
switches.
When ports that can be transitioned immediately to
forwarding state are discovered, they are transitioned
immediately.
IPMAC
Networking Academy
RSTP Convergence Example
Step 1: the network has no redundancy.
Step 2: SW4 realizes that it is receiving a better BPDU than the one
that entered from SW3.
IPMAC
Networking Academy
RSTP Convergence Example
Step 3: RSTP on SW4
temporarily blocks all other link-
type ports to prevent the
possibility of introducing loops.
Then SW4 negotiates with its
neighbor on the new root port
using RSTP Proposal and
Agreement message.
SW4 and SW1 agree that
they can each place their
respective ends of the
new link into forwarding
state immediately.
IPMAC
Networking Academy
RSTP Convergence Example
Step 4: SW4 and SW3 repeat
the same process that SW1 and
SW3 just performed. SW4 still
blocks, preventing loops. SW4
forwards the new root BPDU to
SW3.
Assume that SW3 thinks that
BPDU from SW4 is better
than the one received from
SW2 – which makes SW3
repeat the same process that
SW4 just performed.
IPMAC
Networking Academy
RSTP Convergence Example
Step 6
Old BPDU
Step 5: SW3 repeat the same SW1
is better
than One
process that SW4 just performed. from SW3
Step 6: SW3 stills blocks on its
upper interface at this point. SW2 is
now receiving two BPDUs, but the SW2 Not as
same old BPDU it had been receiving good as
BPDU
all along is still the better BPDU. from SW3
So SW2 takes no action.
SW3
RSTP is finished converging.
SW4
IPMAC
Networking Academy
Summary
The key elements of a redundant networking topology
The benefits and risks of a redundant topology
The role of spanning tree in a redundant-path switched
network
The key elements of spanning-tree operation
The process for root bridge election
Spanning-tree states
Rapid Spanning-Tree Protocol
IPMAC
Networking Academy
Stop here!
It’s time for questioning.
IPMAC
Networking Academy