Spanning Tree Protocol


L2 Loops



Broadcasts and Layer 2 loops can be a dangerous combination.
Ethernet frames have no TTL field
After an Ethernet frame starts to loop, it will probably continue until someone shuts off one of the switches or breaks a link.
Ethernet frame
Ethernet frame

L2 Loops - Flooded unicast frames



Bridge loops can occur any time there is a redundant path or loop in the bridge network.
The switches will flip flop the bridging table entry for Station A (creating extremely high CPU utilization).
Bridge Loops can cause:
Broadcast storms
Multiple copies of Ethernet frames
MAC address table instability in switches


L2 Loops


Unknown Unicast



Switch Moe learns Kahns’ MAC address.



Layer 2 Broadcast



Switch Moe floods the frame.
Switch Larry floods the frames.
Switches continue to flood duplicate frames.
Switches constantly modifying MAC Address Tables


STP Prevents Loops


The purpose of STP is to avoid and eliminate loops in the network by negotiating a loop-free path through a root bridge.
STP determines where the are loops and blocks links that are redundant.
Ensures that there will be only one active path to every destination.


Spanning Tree Algorithm



STP executes an algorithm called Spanning Tree Algorithm.
STA chooses a reference point, called a root bridge, and then determines the available paths to that reference point.
If more than two paths exists, STA picks the best path and blocks the rest

Spanning Tree Algorithm



Two-key STP Concepts


STP calculations make extensive use of two key concepts in creating a loop-free topology:
Bridge ID
Path Cost

Link Speed
Cost (Revised IEEE Spec)
Cost (Previous IEEE Spec)
10 Gbps
2
1
1 Gbps
4
1
100 Mbps
19
10
10 Mbps
100
100



Bridge ID (BID)


Bridge ID (BID) is used to identify each bridge/switch.
The BID is used in determining the center of the network, in respect to STP, known as the root bridge.

Bridge ID (BID)



Consists of two components: 

A 2-byte Bridge Priority: Cisco switch defaults to 32,768 or 0x8000. 

A 6-byte MAC address 

Bridge Priority is usually expressed in decimal format and the MAC address in the BID is usually expressed in hexadecimal format
Bridge ID (BID)




Spanning tree operation requires that each switch have a unique BID.
In the original 802.1D standard, the BID was composed of the Priority Field and the MAC address of the switch, and all VLANs were represented by a CST.
Because PVST requires that a separate instance of spanning tree run for each VLAN, the BID field is required to carry VLAN ID (VID) information.
This is accomplished by reusing a portion of the Priority field as the extended system ID to carry a VID


and 

Used to elect a root bridge (coming)
Lowest Bridge ID is the root.
If all devices have the same priority, the bridge with the lowest MAC address becomes the root bridge. (Yikes)
Note:  For simplicity, in our topologies we will use Bridge Priorities without the Extended System ID.



Elect one Root Bridge



The STP algorithm uses three simple steps to converge on a loop-free topology:
STP Convergence
Step 1   Elect one Root Bridge
Step 2   Elect Root Ports
Step 3   Elect Designated Ports
When the network first starts, all bridges are announcing a chaotic mix of BPDUs.
All bridges immediately begin applying the five-step sequence decision process.
Switches need to elect a single Root Bridge.
Switch with the lowest BID wins!
Note: Many texts refer to the term “highest priority” which is the “lowest” BID value.
This is known as the “Root War.”


Elect one Root Bridge Lowest BID wins

Elect one Root Bridge Lowest BID wins

Root Bridge Selection Criteria


At the beginning, all bridges assume they are the center of the universe and declare themselves as the Root Bridge, by placing its own BID in the Root BID field of the BPDU.



Elect Root Ports

Elect Root Ports




STP Convergence
Step 1   Elect one Root Bridge
Step 2   Elect Root Ports
Step 3   Elect Designated Ports
Now that the Root War has been won, switches move on to selecting Root Ports.
A bridge’s Root Port is the port closest to the Root Bridge.
Bridges use the cost to determine closeness.
Every non-Root Bridge will select one Root Port!
Specifically, bridges track the Root Path Cost, the cumulative cost of all links to the Root Bridge.



Elect Root Ports
Every non-Root bridge must select one Root Port.
A bridge’s Root Port is the port closest to the Root Bridge.
Bridges use the cost to determine closeness.


Elect Designated Ports


STP Convergence
Step 1   Elect one Root Bridge
Step 2   Elect Root Ports
Step 3   Elect Designated Ports
The loop prevention part of STP becomes evident during this step, electing designated ports.
A Designated Port  functions as the single bridge port that both sends and receives traffic to and from that segment and the Root Bridge.
Each segment in a bridged network has one Designated Port, chosen based on cumulative Root Path Cost to the Root Bridge.
The switch containing the Designated Port is referred to as the Designated Bridge for that segment.
To locate Designated Ports, lets take a look at each segment.
Segment’s perspective:  From a device on this segment, “Which switch should I go through to reach the Root Bridge?”
Root Path Cost, the cumulative cost of all links to the Root Bridge.
Obviously, the segment has not ability to make this decision, so the perspective and the decision is that of the switches on that segment.


A Designated Port is elected for every segment.
The Designated Port is the only port that sends and receives traffic to/from that segment to the Root Bridge, the best port towards the root bridge.
Note: The Root Path Cost shows the Sent Root Path Cost
This is the advertised cost in the BPDU, by this switch out that interface, i.e. this is the cost of reaching the Root Bridge through me!


A Designated Port is elected for every segment.
Segment’s perspective:  From a device on this segment, “Which switch should I go through to reach the Root Bridge?”
“I’ll decide using the advertised Root Path Cost from each switch!”


Segment’s perspective:
Access 2 has a Root Path Cost = 0 (after all it is the Root Bridge) and Access 1 has a Root Path Cost = 19.
Because Access 2 has the lower Root Path Cost it becomes the Designated Port for that segment

The same occurs between Access 2 and Distribution 1 and Distribution 2 switches.

Because Access 2 has the lower Root Path Cost it becomes the Designated Port for those segments. .


Segment between Distribution 1 and Access 1 has two equal Root Path Costs of 19.
Using the Lowest Sender ID (first two steps are equal), Access 1 becomes the best path and the Designated Port.
Designated Port


Spanning-Tree Port States

Spanning-Tree Port States




Blocked:
All ports start in blocked mode in order to prevent the bridge from creating a bridging loop.
Port are listening (receiving) BPDUs.
No user data is being passed.
The port stays in a blocked state if Spanning Tree determines that there is a better path to the root bridge.
May take a port up to 20 seconds to transition out of this state (max age). - coming soon.


Listen:
The port transitions from the blocked state to the listen state
Attempts to learn whether there are any other paths to the root bridge
Listens to frames
Port is not sending or receive user data
Listens for a period of time called the forward delay (default 15 seconds).
Ports that lose the Designated Port election become non-Designated Ports and drop back to Blocking state.


Learn:
The learn state is very similar to the listen state, except that the port can add information it has learned to its address table.
Adds addresses to MAC Address Table
Still not allowed to send or receive user data
Learns for a period of time called the forward delay (default 15 seconds)


Forward:
The port can send and receive user data.
A port is placed in the forwarding state if:
There are no redundant links
or
It is determined that it has the best path to the root


Disabled: The port is shutdown.

Spanning-Tree Port States





Rapid Spanning Tree Protocol..


The immediate hindrance of STP is convergence.
Depending on the type of failure, it takes anywhere from 30 to 50 seconds, to converge the network.
RSTP helps with convergence issues that plague legacy STP.

RSTP Port States



No comments:

Post a Comment