DCS-Chapter4 v1.2

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 59

Chapter 4

 Spanning Tree Protocol

[Chapter 4: Spanning Tree Protocol]


Version 1.0
Chapter 4
 Spanning Tree Protocol

Overview and Objectives


 By the end of this chapter, you will have learned about:
• Spanning Tree Protocol (IEEE 802.1D)
• Rapid Spanning Tree Protocol (IEEE 802.1w )
 This new knowledge will be consolidated by a hands-on exercise.

2
Chapter 4
 Spanning Tree Protocol

Spanning Tree Protocol


 Reasons for deploying the Spanning Tree Protocol:
• Loop avoidance
• Redundant links
 Protocol Versions:
• IEEE 802.1D Spanning Tree Protocol (STP)
• IEEE 802.1w Rapid Spanning Tree Protocol (RSTP)
• IEEE 802.1s Multiple Spanning Tree Protocol (MSTP)

3
Chapter 4
 Spanning Tree Protocol

Loop Issue without STP


 A loop is not allowed in an L2 Ethernet network. If there is a loop,
it will create a broadcast storm.

4
Chapter 4
 Spanning Tree Protocol

Loop Avoidance
 The Spanning Tree Protocol can resolve loop issues.

5
Chapter 4
 Spanning Tree Protocol

Redundant Links
 If one of the connections fails, the Spanning Tree Protocol will
unblock the port and provide redundancy.

6
Chapter 4
 Spanning Tree Protocol

Bridge Protocol Data Unit (BPDU)


 The Spanning Tree Protocol is defined in IEEE 802.1D.
 All switches/bridges in the network gather information about other
switches through data message exchange. These messages are
called Bridge Protocol Data Units (BPDU).
 A BPDU is transmitted on the LAN connected to the port.
 BPDUs are used to calculate the spanning tree.

7
Chapter 4
 Spanning Tree Protocol

Bridge Protocol Data Unit (BPDU)


 A BPDU is a data frame used by the Spanning Tree Protocol. It is
used to exchange essential information between switches to
derive path information. The exchange is done every two seconds
by default so that the switches can keep track of the network
changes.
• The IEEE 802.1D STP multicast destination address for BPDU is 01-80-
C2-00-00-00.

8
Chapter 4
 Spanning Tree Protocol

BPDU Frame

D-Link
1

9
Chapter 4
 Spanning Tree Protocol

BPDU Frame Format


Field Bits Use
Protocol ID 16 Always 0
Version 8 Always 0
Type of current BPDU
BPDU Type 8
Flag: 00=Configuration BPDU, 01=Topology Change (TC)
LSB=Topology Change (TC) Flag
Flags 8
MSB=Topology Change Acknowledgement (TCA) Flag
Root ID 64 Bridge ID of current Root Bridge
Root Path Cost 32 Cumulative cost of Root Bridge
Bridge ID 64 Bridge ID of current bridge
Port ID 16 Unique ID for port that sent this BPDU
Time since Root Bridge created – BPDU used to derive current
Message Age 16
BPDU
Max. Age 16 Period to save BPDU information
Hello Time 16 Period between BPDUs
Forward Delay 16 Time spent in Listening and Learning states
10
Chapter 4
 Spanning Tree Protocol

802.1D Spanning Tree Protocol (STP)


 Find the Root Switch.
 Find the Root Port for each switch.
 Find the Designated Port for each LAN segment.
 Block the port(s) which is/are not Root Port(s) or Designated
Port(s).

11
Chapter 4
 Spanning Tree Protocol

What is a Root Bridge?


 Electing a Root Bridge:
• Each switch has a unique Bridge ID that identifies it to other switches.
The Bridge ID is an 8-byte value consisting of the following fields:
– Bridge Priority (2 bytes)
– MAC Address (6 bytes)
 Rule for electing the Root Bridge:
• The Root Bridge has the lowest Bridge ID.
• If priority is tied, the lowest MAC address is Root Bridge.

12
Chapter 4
 Spanning Tree Protocol

Bridge ID Content

13
Chapter 4
 Spanning Tree Protocol

An illustration of the STP process


Switch 1 1 Each bridge assumes it is the root bridge, places
Root Bridge its Bridge ID as the root ID and sends Hello
BPDUs out.
Priority: 32768 3
MAC: 00-00-00-00-00-0a 1 <Root Bridge ID, Root Path Cost, Sender Bridge ID>

After a root is chosen, only 1 Switch 3


3 Priority: 32768
root bridge sends Hello
MAC: 00-00-00-00-00-0c
BPDUs, but other switches
2
forward them 2
3
Switch 2
Priority: 32768
MAC: 00-00-00-00-00-0b

2 Each bridge compares its Bridge ID with the


root ID field of the Configuration BPDUs
received. If it is lower, the Bridge replaces its
Bridge ID in the root ID field to become the
root Bridge.

Page is Animated 14
Chapter 4
 Spanning Tree Protocol

Electing Root Ports and Designated Ports


 Electing Root Ports
• The reference point (Root Bridge) has been elected for the entire
switched network, each non-root switch must figure out where it is in
relation to the Root Bridge. This action can be performed by selecting
only one Root Port on each non-root switch.
• Selecting a Root Port involves evaluating the Root Path Cost. This
value is the cumulative cost of all the links leading to the Root Bridge.
Remember that only the Root Path Cost is carried inside the BPDU.
 Electing Designated Ports
• To remove the possibility of bridging loops, STP makes a final
computation to identify one Designated Port on each network
segment.
• The switch chooses a Designated Port based on the lowest cumulative
Root Path Cost to the Root Bridge.

15
Chapter 4
 Spanning Tree Protocol

How does STP select a path?


 Decision List:
1. Root Bridge ID
2. Path Cost to the Root Bridge
3. Sender Bridge ID
4. Port Priority
5. Port ID

16
Chapter 4
 Spanning Tree Protocol

Default STP Path Cost

Link Speed STP Path Cost

4 Mbps 250

10 Mbps 100

16 Mbps 62

100 Mbps 19

1 Gbps 4

10 Gbps 2
Best

17
Chapter 4
 Spanning Tree Protocol

Electing the Root Port and Designated Port


<Root Bridge ID, Root Path Cost, Sender Bridge ID>
Switch A
32768, 00-00-00-00-00-0a

Designated Designated
Port AP1 AP2 Port
Root Bridge

<A,0,A> <A,0,A>
AP1 vs BP1 AP2 vs CP1
AP1 Priority > BP1 Priority AP2 Priority > CP1 Priority
Path Cost: 10
Path Cost: 5 Designated
Port CP2 -> SW A = 4+5 = 9
CP1 -> SW A = 10
Roo <A,0,A>
<B,0,B>
t <A,0,A>
<C,0,C>
Port
BP1 Roo
CP1 t
BP2 Path Cost: 4
CP2 Port
<B,0,B>
<A,5,A> <A,10,A>
<C,0,C>
<A,9,A> Switch C
Switch B
32768, 00-00-00-00-00-0c
32768, 00-00-00-00-00-0b
Designated Roo CP1 vs CP2
BP1 vs BP2 vs CP2 Port
BP1 Priority > BP2 Priority t CP1 Priority > CP2 Priority
BP2 Priority > CP2 Priority Port BP2 Priority > CP2 Priority

Page is Animated 18
Chapter 4
 Spanning Tree Protocol

BPDU Parameter

19
Chapter 4
 Spanning Tree Protocol

State of Ports on Switch


 Blocking
• Just listen to incoming BPDUs
• The port does not learn MAC addresses
of received frames
 Listening
• Have to determine Root Port &
Designated Port, but cannot learn the
MAC addresses and forward the frames
 Learning
• Port starts to learn the MAC addresses
from incoming frame, but cannot
forward the frames
 Forwarding
• Start to forward frames
 Disabled
• Port does not participate in STP, and
does not forward frames
20
Chapter 4
 Spanning Tree Protocol

STP Timers
 Hello Time
• The time interval between Configuration BPDUs sent by the Root
Bridge. The Hello Time value configured in the Root Bridge switch
determines the Hello Time for all non-root switches because they just
relay the Configuration BPDUs when they receive it from the root. The
default Hello Time Value is 2 seconds; the value range is 1-10
seconds.
 Forward Delay
• The time interval that a switch port spends in Listening and Learning
states. The default Forward Delay Value is 15 seconds; the value
range is 4-30 seconds.
 Max. Age
• The time interval that a switch stores a BPDU before discarding it. The
default maximum age value is 20 seconds; the value range is 6-
40 seconds.

21
Chapter 4
 Spanning Tree Protocol

Topology Change
 In normal STP operation, a bridge keeps receiving Configuration
BPDUs from the Root Bridge on its Root Port.
 In order for this to occur, a special BPDU called the Topology
Change Notification (TCN) BPDU has been introduced. Therefore,
when a bridge needs to signal a topology change, it starts to send
TCNs on its Root Port.
 The designated bridge receives the TCN, acknowledges it and
generates another one for its own Root Port. The process
continues until the TCN hits the Root Bridge.

22
Chapter 4
 Spanning Tree Protocol

STP Topology Changes


 The switch notifies a topology change by sending a TCN on its root
port. The TCN is acknowledged and forwarded up to the root
switch.

TCN-ACK TCN

TC
N
TC
N-
AC
K

Page is animated 23
Chapter 4
 Spanning Tree Protocol

Topology Change Notification (TCN)

24
Chapter 4
 Spanning Tree Protocol

TCA (Topology Change Acknowledgement)


Chapter 4
 Spanning Tree Protocol

Root Switch Sets Flag Due to TCN

Root
Switch Forwarding
TC
F la
g
Delay=15s

TC Flag TC
Fl a
g

Forwarding
Delay=15s TC
F la
g
Forwarding
Delay=15s
TC Flag

Forwarding
Delay=15s

Forwarding
TC Flag Set=35s
(Forward delay timer + Max. age timer)
Delay=15s

Page is animated 26
Chapter 4
 Spanning Tree Protocol

TCN Flag in the Configuration BPDU

27
Chapter 4
 Spanning Tree Protocol

STP Converge Time


 STP (802.1D) generally takes at least 30 to 50 seconds to
converge (from Blocking state to Forwarding state).
• Listening (15s) + Learning (15s) = 30 seconds
• Max. Age (20s) + Listening (15s) + Learning (15s) = 50 seconds

28
Chapter 4
 Spanning Tree Protocol

STP Converge Time

29
Chapter 4
 Spanning Tree Protocol

Example: STP

 Enable STP on both switches. Check that one port on the switch is
blocked.
 Ping PC-1 and PC-2 continuously.
 Unplug Cable-1, check how long (# pings lost) until the backup
link becomes active.
 Re-plug Cable-1, and check how long it will take for the link to
recover.
30
Chapter 4
 Spanning Tree Protocol

Rapid Spanning Tree Protocol (RSTP)


 A disadvantage of STP is the slow convergence speed.
 Solution:
• IEEE 802.1w Rapid Spanning Tree Protocol (RSTP)
• RSTP provides significant improvements in the speed of convergence
for a switched network by transitioning Root and Designated Ports to
the Forwarding state immediately.
• With RSTP, packets are forwarded using Port States.
• RSTP provides rapid convergence of the spanning tree by port roles
and determining active topology.
• RSTP reconfigures the spanning tree in less than one second
(compared to 50 seconds for STP).
• RSTP takes advantage of point-to-point wiring.

31
Chapter 4
 Spanning Tree Protocol

RSTP Port State


 802.1D STP defines four different port states: Blocking, Listening,
Learning and Forwarding.

 802.1w RSTP defines three different port states: discarding,


learning and forwarding.

32
Chapter 4
 Spanning Tree Protocol

Port State Comparison between 802.1D & 802.1w

STP (802.1D) RSTP (802.1w) Is Port included in Is Port Learning


Port State Port State Active Topology? MAC Addresses?

Disabled Discarding No No

Blocking Discarding No No

Listening Discarding No No

Learning Learning No Yes

Forwarding Forwarding Yes Yes

33
Chapter 4
 Spanning Tree Protocol

Port Roles in RSTP


 RSTP introduces a new concept: the “Port Role”.
• The Root Port and Designated Port roles remain.
• Blocking is now split into two different port roles: backup and
alternate.

Root Port Roles Designated Port Roles


This is the port that is A port is designated if it can send
closest to the Root Bridge the best BPDU on the segment to
according to path cost. which it is connected.

34
Chapter 4
 Spanning Tree Protocol

Alternate Port and Backup Port


 Alternate Port
• The alternate port can take over the original root port if it fails.
 Backup Port
• The backup port becomes the designated port if the existing
designated port fails.

35
Chapter 4
 Spanning Tree Protocol

Fast Convergence RSTP


 RSTP can actively confirm that a port can safely transit into
Forwarding state without relying on any timer configuration.
 In order to achieve fast convergence on a port, the protocol relies
upon two variables:
• Edge Port
• Link Type

36
Chapter 4
 Spanning Tree Protocol

RSTP BPDU Format


STP 802.1D

RSTP 802.1w

2-bit

6-bit

37
Chapter 4
 Spanning Tree Protocol

STP Proposal/Agreement Packet


p1: designated port
p2: new root port

Root Switch A p3: alternate port


p4: designated port
p1 moves to Forwarding state
p1 p5: edge port
3. Agreement
1. Proposal Root Port
p2
Switch B Designated Port
Edge Port
p5 2. In-Sync
p3 p4 (unchanged)

2. Sync (block)
2. In-Sync
(unchanged)
4. Proposal

Page is animated 38
Chapter 4
 Spanning Tree Protocol

STP Proposal/Agreement Packet

39
Chapter 4
 Spanning Tree Protocol

New Topology Change Mechanism


 Topology Change Detection
• RSTP (802.1w)
– Only non-edge ports moving to the Forwarding state will cause a
topology change.
– A port which moves to Discarding state does not cause the
respective bridge to generate a TC BPDU.
• STP (802.1D)
– Loss of the connection generates a topology change.

40
Chapter 4
 Spanning Tree Protocol

RSTP Topology Change Mechanism


 RSTP (802.1w) floods BPDU (with TC bit set) immediately when a
switch detects the non-edge ports changing its state to
Forwarding state. A port changing to Discarding state does not
cause the switch to generate a TC BPDU.
 In RSTP, when a switch receives a topology change notification
message, it will notice the root switch first and the root switch
generates a topology change message to the other switches.

41
Chapter 4
 Spanning Tree Protocol

RSTP Topology Change Mechanism

2. The switch sends a BPDU 1. Start the TC While Timer*


with TC set on all its and flush relative MAC
designated ports and root addresses associated with
ports. all non-edge ports.

*TC While Timer: A time interval for actively noticing a


topology change event to the rest of switches in the network.

Page is animated 42
Chapter 4
 Spanning Tree Protocol

Differences of Topology Changes between STP and RSTP


Detection STP Any port state change between the Blocking and Forwarding states causes a
topology change.
RSTP Only a transition from the Discarding to the Forwarding state causes a
topology change. (Only an increase in connectivity is considered a topology
change.) State changes on an edge port do not cause a topology change.
When an RSTP switch detects a topology change, it flushes the learned
information on all its non-edge ports.
Notification STP STP uses TCN BPDUs to notify the root of the topology change.
RSTP RSTP sends the BPDUs with TC bit set to flood the whole network. For IEEE
802.1D interoperability, an RSTP switch processes and generates TCN BPDUs.
Acknowledge- STP When receiving BPDU with TC bit set, the bridge will send feedback with a
ment TCA BPDU.
RSTP No TCA BPDU. For backward compatibility with 802.1D, when an RSTP switch
receives a TCN message on a designated port from a 802.1D switch, it replies
on an 802.1D configuration BPDU with the topology change acknowledgement
bit set.
Propagation STP When receiving BPDU with TC bit set, the bridge will send feedback with a
TCA BPDU.
RSTP When receiving a BPDU with TC bit set through a designated or root port, the
port floods the topology change message to all its non-edge, edge,
designated and root ports, except the port on which it is received. The switch
starts the TC-While Timer for all such ports and flushes the information
learned on them. 43
Chapter 4
 Spanning Tree Protocol

Compatibility with 802.1D STP


 RSTP is designed to interoperate with legacy STP protocol.
 The compatibility occurs when a RSTP bridge is attached to the
same LAN segment of a STP bridge.
 As RSTP is in STP compatibility mode, the benefit of fast
convergence will be lost.
 Instead of Rapid Spanning Tree BPDU, Configuration BPDU and
TCN BPDU are sent.

44
Chapter 4
 Spanning Tree Protocol

Compatibility with 802.1D STP – cont’d

A B C D Ignore and drop!


(RSTP) (RSTP) (RSTP) (STP)

RSTP BPDU STP BPDU

STP BPDU

Page is animated 45
Chapter 4
 Spanning Tree Protocol

Example: RSTP

 Enable RSTP on both switches. Check that one port on the switch
is blocked.
 Ping PC-1 and PC-2 continuously.
 Unplug the Cable-1 and check how long (# pings lost) before the
backup link becomes active.
 Re-plug Cable-1 and check how long until the link recovers.

46
Chapter 4
 Spanning Tree Protocol

Switch Configuration for STP


 Switch A  Switch B
• To enable STP • To enable STP
enable stp enable stp
config stp version stp config stp version stp
• Set Switch A has lower priority • Configure STP Port
value so that it will be the root config stp ports 1-24 edge true
(default priority=32768)
config stp priority 4096 instance_id 0
• Configure STP Ports
config stp ports 1-24 edge true

Note:
1. By default, rstp is used on D-Link switches. Thus to configure it to STP, the command
config stp version stp must be used.
2. “instance_id 0” will be covered in DCP (D-Link Certified Professional) courses.

47
Chapter 4
 Spanning Tree Protocol

Configuring STP

48
Chapter 4
 Spanning Tree Protocol

To enable or disable stp

DGS-3627:admin#
enable stp
This command is used to enable STP globally.

DGS-3627:admin#
disable stp
This command is used to disable STP globally.

49
Chapter 4
 Spanning Tree Protocol

Config stp version command


 This command is used to enable the STP version globally.

DGS-3627:admin#
config stp version [mstp | rstp | stp]

50
Chapter 4
 Spanning Tree Protocol

Config stp priority command


 This command is used to configure the instance priority.

DGS-3627:admin#
config stp priority <value 0-61440> instance_id
<value 0-15>

51
Chapter 4
 Spanning Tree Protocol

Show stp command


 This command is used to show the global settings of the bridge
parameters.
DGS-3627:admin#
show stp

52
Chapter 4
 Spanning Tree Protocol

Show stp instance command


 This command is used to show each instance parameters settings.

DGS-3627:admin#
show stp instance <value 0-15>

53
Chapter 4
 Spanning Tree Protocol

Show stp ports command


 This command is used to show the port information, including
parameters setting and operational value.
DGS-3627:admin#
show stp ports {<portlist>}

54
Chapter 4
 Spanning Tree Protocol

Config stp ports command


 This command is used to configure the ports management
parameters at the CIST level only.
DGS-3627:admin#
config stp ports <portlist> {externalCost [auto |
<value 1-200000000>] | hellotime <value 1-10> |
migrate [yes | no] | edge [true | false | auto] | p2p
[true | false | auto] | state [enable | disable] |
restricted_role [true |false] | restricted_tcn [true
| false] | lbd [enable | disable] | fbpdu [enable |
disable]}

55
Chapter 4
 Spanning Tree Protocol

config stp ports 3 edge true command

56
Chapter 4
 Spanning Tree Protocol

Config stp command


 This command is used to configure the bridge management
parameters for CIST (instance_id=0).

DGS-3627:admin#
config stp {maxage <value 6-40> | maxhops <value 1-40
| hellotime <value 1-10> | forwarddelay <value 4-30>
| txholdcount <value 1-10> | fbpdu [enable|disable] |
lbd [enable|disable)] | lbd_recover_timer [<value 0>
| <value 60-1000000>] | nni_bpdu_addr [dot1d |
dot1ad]}

57
Chapter 4
 Spanning Tree Protocol

Summary
 This chapter introduces the Spanning Tree Protocol (STP), used on
switches to provide a loop-free redundant topology.
There are two standards used for STP. These are IEEE 802.1D and
IEEE 802.1w, which are respectively STP and RSTP.
 Rapid Spanning Tree Protocol (RSTP) provides for faster spanning
tree convergence when there is a topology change. STP normally
takes 30 to 50 seconds to react to a topology change, and RSTP is
able to react to a topology change between 1 to 6 seconds.
 By default, D-Link switches use the IEEE 802.1w standard.

58
Chapter 4
 Spanning Tree Protocol

Lab Topology

59

You might also like