Spanning Tree Protocol
Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) was developed to prevent the broadcast storms caused by switching loops. STP was originally defined in IEEE 802.1D.
Switches running STP will build a map or topology of the entire switching network. STP will identify if there are any loops, and then disable or block as many ports as necessary to eliminate all loops in the topology.
A blocked port can be reactivated if another port goes down. This allows STP to maintain redundancy and fault-tolerance.
Ports are blocked to eliminate loops, STP does not support load balancing unless an EtherChannel is used.
STP switches exchange Bridge Protocol Data Units (BPDU’s) to build the topology database. BPDU’s are forwarded out all ports every two seconds, to a dedicated MAC multicast address of 0180.c200.0000.
NOTE:-STP is enabled by default on all Cisco switches, for all VLANs.
Switching Loops
When a switching loop is introduced into the network, a destructive broadcast storm will develop within seconds. A storm occurs when broadcasts are endlessly forwarded through the loop. Eventually, the storm will choke off all other network traffic.
Building the STP topology is a multistep convergence process:
-A Root Bridge is elected
-Root ports are identified
-Designated ports are identified
-Ports are placed in a blocking state as required, to eliminate loops
Root Bridge
The Root Bridge serves as the central reference point for the STP topology. STP was originally developed when Layer-2 bridges were still prevalent, and the term Root Bridge is still used for nostalgic reasons. It is also acceptable to use the term Root Switch, though this is less common.
Work of Root Bridge
The root bridge serves as a reference point for all spanning-tree calculations to determine which redundant paths to block. An election process determines which switch becomes the root bridge.
Election process STP Root Bridge
The first step in the STP convergence process is electing a Root Bridge, which is the central reference point for the STP topology. The Root Bridge should be the most centralized switch in the STP topology.
A Root Bridge is elected based on its Bridge ID, comprised of two components in the original 802.1D standard:
-16-bit Bridge priority
-48-bit MAC address
The default priority is 32,768, and the lowest priority wins. If there is a tie in priority, the lowest MAC address is used as the tie-breaker.
Switches exchange BPDU’s to perform the election process, and the lowest Bridge ID to determines the Root Bridge:
By default, a switch will always believe it is the Root Bridge, until it receives a BPDU from a switch with a lower Bridge ID. This is referred to as a superior BPDU. The election process is continuous – if a new switch with the lowest Bridge ID is added to the topology, it will be elected as the Root Bridge.
Identifying Root Ports
The second step in the STP convergence process is to identify Root Ports. The Root Port of each switch has the lowest root path cost to get to the Root Bridge.
Each switch can only have one root port. The Root Bridge cannot have a root port, as the purpose of a root port is to point to the Root Bridge.
Path cost is a cumulative cost to the Root Bridge, based on the bandwidth of the links. The higher the bandwidth, the lower the path cost:
Bandwidth Cost
4 Mbps 250
10 Mbps 100
16 Mbps 62
45 Mbps 39
100 Mbps 19
155 Mbps 14
1 Gbps 4
10 Gbps 2 SwitchB has two paths to the Root Bridge:
A direct connection to SwitchA, with a path cost of 4. and Another path through SwitchD, with a path cost of 16.
The lowest cumulative path cost is considered superior, thus the port directly connecting to SwitchA will become the root port. A BPDU advertising a higher path cost is often referred to as an inferior BPDU.
SwitchD also has two paths to the Root Bridge:
-A path through SwitchB, with a path cost of 8.
-A path through SwitchE, with a path cost of 12.
-The port to SwitchB is preferred, and will become the root port.
Path cost can be artificially adjusted on a per-port basis:
SwitchD(config)# int gi2/22
SwitchD(config-if)# spanning-tree vlan 101 cost 42
Identifying Designated Ports
The third step in the STP convergence process is to identify designated ports. A single designated port is identified for each network segment. This port is responsible for forwarding BPDUs and frames to that segment.
If two ports are eligible to become the designated port, then there is a loop. One of the ports will be placed in a blocking state to eliminate the loop.
Similar to a root port, the designated port is determined by the lowest cumulative path cost leading the Root Bridge. A designated port will never be placed in a blocking state, unless there is a change to the switching topology and a more preferred designated port is elected.
Note:- A port can never be both a designated port and a root port.
Ports on the Root Bridge are never placed in a blocking state.
Remember-every network segment must have one designated port, regardless if a root port already exists on that segment.
Port ID
When electing root and designated ports, it is possible to have a tie in both path cost and Bridge ID.
The bandwidth of both links is equal, thus both ports on SwitchB have an equal path cost to the Root Bridge. Which port will become the root port then? Normally, the lowest Bridge ID is used as the tiebreaker, but that is not possible in this circumstance.
Port ID is used as the final tiebreaker, and consists of two components:-4-bit port priority
-12-bit port number, derived from the physical port number
By default, the port priority of an interface is 128, and a lower priority is preferred. If there is a tie in priority, the lowest port number is preferred.
The port number is a fixed value, but port priority can be changed on a perinterface basis:
Switch(config)# int gi2/11
Switch(config-if)# spanning-tree vlan 101 port-priority 32
Note:- Some reference material may state that the Port ID is comprised of an 8-bit priority and 8-bit port number. This was accurate in the original 802.1D specification.
However, IEEE 802.1t revised the original specification to provide the larger 12-bit port number field, to accommodate modular switches with high port density.
Even more confusing – some whitepapers on Cisco’s website will define the Port ID as a combination of port priority and MAC address, instead of port number. This is not accurate in modern STP implementations.
Remember:- Port ID is the last tiebreaker STP will consider. STP determines root and designated ports using the following criteria, in order:
-Lowest path cost to the Root Bridge
-Lowest bridge ID
-Lowest sender port ID
-Lowest Bridge ID is always used to determine the Root Bridge.
Versions of STP
Comments
Post a Comment