Beruflich Dokumente
Kultur Dokumente
Index:
Page 1 of 20
4. STP
5.1.1 Redundancy
Page 2 of 20
- Broadcast Storms:
This occurs when so many broadcast frames are caught in the layer two loop that the ALL
available bandwidth is consumed.
Another problem with layer two loops is the creation of duplicate unicast frames.
If the access layer switch doesn’t have the entry in the table, it floods the packet out.
This can go to multiple switches that both send the packet on.
One switch sends it to the correct end user; the other switch sends it to the correct switch.
The result is that the end user gets two instances of the same frame.
Many upper-layer protocols can’t handle this double up, and therefore fail.
Cables between access and distribution layer switches are terminated in wiring closets.
This can result in a confusion of cables if not properly labelled.
A problem is if two cables join an access layer switch to the same distribution switch.
It’s OK if they’re EtherChannelled, but not if they are access ports.
A loop occurs, causing broadcast storms.
The same thing occurs if the access layer switch connects to two distribution switches.
These distribution layer switches may complete a loop, resulting in the same problem.
- Loops in Cubicles:
This is more likely, as administrators cannot control access at the workplace cubicle.
Here, a user could plug in two hubs to the switch, and link the hubs together.
Again, this causes a layer two loop.
Page 3 of 20
5.2 Introduction to STP
STP ensures that there is only one path between all destinations in the network.
It intentionally blocks redundant paths that would cause a loop.
A switch port is “blocked” if it has been disabled by STP.
This DOES NOT include BPDU frames used by STP to negotiate the port states.
As required, STP will unblock the port to maintain connectivity.
- STP Topology:
In a loop, one of the switch ports will be set to “blocked”, thus avoiding layer 2 loops.
If the main link fails, the above mentioned port is “unblocked”.
This allows the redundant path to carry the traffic.
When the better link is fixed, STP reverts the network to the original condition.
Page 4 of 20
All switch ports are defined to be one of the following:
- Root Ports:
These ports NEVER occur on the root bridge.
Only ONE port on all other switches will have a root port.
This is the “open” port used to forward traffic towards the root bridge.
This will be a trunk port pointing to the root bridge.
- Designated Ports:
ALL ports on the root bridge are “Designated Ports”
Each segment of wire has exactly one “Designated Port”.
So, on a given segment, one port may be blocked, the other a Designated port.
This port is used to accept traffic and forward it to the root bridge.
The switch with a designated port is the “Designated bridge”.
- Non-Designated Port:
These are ports that are in a “Blocked” state to prevent the loop.
- Root Bridge:
The 8-byte BID consists of either 2 (old method) or 3 (new method) fields.
This consists of the priority + Extended ID + MAC address of the switch.
All switches broadcast this frame into the network every 2 seconds (by default).
Along with this information, they also send who they think in the root bridge.
Initially, every switch thinks they’re the root.
Page 5 of 20
If it receives a frame with a BID lower than their own, they update their role.
The switch with the LOWEST BID becomes the root bridge.
- Best Paths:
Once the root is elected, STA works out the best path for all switches to this root.
This is performed by summing the cost of all egress ports to the root.
Costs are as follows:
This is the default port cost – the value can be changed at the interface:
This provides the following details for each STA instance (perhaps one per VLAN):
- The priority and MAC address of this switch (its “BID”).
- Cost to the root, and which port is the “Root Port”.
- The hello time interval (2 seconds by default).
- Each interface, including:
- The role it’s in (root, designated, non-designated).
- The port priority and number.
- etc.
Page 6 of 20
- The Bridge PDU (BPDU) are frames exchanged between switches.
Each 35 byte BPDU contains a wealth of information, including:
Bytes Field
2 Protocol ID
1 Version
1 Message Type
1 Flags
8 Root ID
4 Cost of Path
8 Bridge ID
2 Port ID
2 Message Age
2 Max Age
2 Hello Time
2 Forward Delay
- BPDU Process:
Upon booting, each switch believes that they are the root.
They send out BPDUs every two seconds announcing that they are the root.
Each switch maintains local information consisting of:
- Its own BID (priority + MAC)
- The Root ID (itself initially)
- Path cost to the root (0 initially).
As BPDUs arrive from neighbours, the switch may revise who is the root.
If a neighbour’s BID is lower, they update their information.
They now believe that the neighbour (with the lower BID) is the root.
They change the local information about the Root ID and local path cost to the root.
All subsequent advertisements (every 2 seconds) advertise the new BID of the root.
Notice that the configurable switch priority takes precedence over switch MAC address.
This allows the administrator to effectively nominate which switch will be the root.
Page 7 of 20
- Bridge ID (BID):
The BID used to be a 2 field frame, but now it consists of three fields.
Note: there are now only 4-bits for the bridge priority.
It maintains its values from 0 to 65535.
However, they must be in increments of 4096.
0000 = 0
0001 = 4096
etc.
Page 8 of 20
The MAC Address:
This is the MAC address of the switch.
This is only used to find the root bridge if the priority values are identical.
The root bridge will be the one with the lowest bridge priority.
If the priorities are tied, the switch with the lowest MAC address wins.
There are two ways to set the bridge priority:
Above, the first command adjusts the priority of the switch to 24576, or the next 4096
increment value less than the lowest priority detected on the network.
Page 9 of 20
5.2.3 Port Roles
- Once the root bridge election finishes, STA calculates the root ports.
This port provides the smallest path cost to the root bridge.
If two ports have the same path cost, it chooses by:
- Port priority (configurable).
- If port priority is the same, then lowest port number wins.
The port priority is a number from 1 to 240 (default of 128) in increments of 16.
The combination is expressed like this: 128:1 (default priority for port 1).
Page 10 of 20
- Configure Port Priority:
To view port roles and priority values, issue the command: show spanning-tree
This provides the role of each port (Root / Designated / Altn).
It also shows the status of each port (FWD / BLK).
It also shows the priority and number of each switch port (E.g.: 128:1).
Page 11 of 20
5.2.4 STP Port States and BPDU Timers
1. Blocking:
The “Non-designated” port is set to this state.
It does not forward frames; it won’t send or receive data frames.
It receives BPDU frames, telling it what to do.
2. Listening:
This port could become either a root port or designated port.
It both sends and receives BPDU frames.
The port will return to a “blocking” state if STP deems it necessary to block a loop.
While in this state, it discards any data frames sent to it.
It is NOT learning any MAC addresses yet.
3. Learning:
This port will end up forwarding frames.
While in this state, it discards any data frames sent to it.
It is populating the MAC address table.
It is also sending and receiving BPDU frames.
4. Forwarding:
The topology is now active.
This port is that topology; it sends and receives data frames.
It is also sending and receiving BPDU frames.
It is learning addresses.
5. Disabled:
The port doesn’t participate in the active topology.
It has been administratively shut down.
Page 12 of 20
- There are several timers used to transition between states. The default values follow:
1. Hello Time:
This is the time between BPDUs being sent out a port.
The default is 2 seconds, but it can be configured from 1 to 10 seconds.
2. Forward Delay:
This is the time spent in the “Listening” and “Learning” states.
The default is 15 seconds, but it can be configured from 4 to 30 seconds.
3. Maximum Age:
This is the time that a switch saves the BPDU information from neighbours.
The default is 20 seconds, but it can be configured from 6 to 40 seconds.
- Cisco PortFast:
Page 13 of 20
5.3 STP Convergence
- Once elected, all switch ports are assigned based upon this assignment.
Upon boot up, all switches have their ports set to “blocked” for 20 seconds.
This prevents loops whilst STP determines which ports to block.
Whilst blocked, the ports still send and receive BPDUs.
Once booted, the switches send out BPDUs, advertising their BID to neighbours.
Initially, all switches believe that they are the root bridge.
These BPDUs are sent out every 2 seconds.
As a switch receives a BPDU, it compares their BID with the one in the packet.
The lowest BID value wins, and the switches agree on which one is the root.
Now, both switches use BPDUs to advertise the switch with the lowest BID.
This process continues until all switches agree on the root bridge.
Even at this stage, all switches still send BPDUs every 2 seconds.
Each switch has a “max age” timer that is reset every time a BPDU is received.
If the switch doesn’t receive a BPDU in this interval (20 seconds), the election process
repeats.
Page 14 of 20
- Verify Root Bridge Election:
To verify which bridge has won the election, issue the command:
Switch# show spanning-tree
The previous command shows the priority and address of both the root and this switch.
It then shows the port role and status of every interface on this switch.
- Now that the root bridge has been decided upon, all switch ports need to be configured.
All root bridge ports are set as “Designated Ports”.
Every other switch needs their ports set to a specific role.
Every one of these non-root bridges has a single “Root port”.
This is the port with the lowest cost to the root bridge.
Typically, path cost is what defines the root port.
It two ports on the same switch have the same cost, then a tie needs to be broken.
This is done by looking at the sender switch’s BID.
The upstream switch with the lowest BID wins.
If the upstream switch is the same for both ports, then the port priority breaks the tie.
This is a combination of port priority + port number.
So, if priority is the same, the link using the lowest port number wins.
The winner becomes the “Root Port” and is set to forwarding.
The loser becomes the “Non-Designated Port”, and is set to blocked.
Port roles for a given switch may change multiple times during convergence.
Page 15 of 20
5.3.3 Step 3 – Elect Designated and Non-designated Ports
- Once the root ports have been set, the remaining ports must be defined.
These will be either “Designated” (DP) or “Non-Designated” (ND).
Each segment (between switches) will have one DP, and one ND.
BPDUs are exchanged, and the switch with the lowest Root Path cost wins.
That switch would set its port to DP (Forwarding).
The losing switch would set its port to ND (Blocking)
The whole process of electing the root bridge and all ports occurs within 20 seconds.
This is based upon the 2 second hello timers (2 x 10 = 20 seconds).
Again, verifiy the configuration of ports with the command: show spanning-tree
This returns:
- The root bridge’s proirity and address.
This bridge’s priority and address.
This bridge’s ports, their role, status, priority and number.
- When a forwarding port goes down, or a port transitions to forwarding, this is a change.
The associated switch sends a message to the root bridge notifying it of the change.
The root bridge then broadcasts this to the whole domain.
Typically, the root bridge sends BPDUs to all other switches every 2 seconds.
The non-root bridges receive the BPDU, but don’t send any BPDUs back.
Upon a change, the non-root bridge sends a “Topology Change Notification” (TCN) BPDU.
When a switch receives the TCN, it replies with an Acknowledgement (a TCA) BPDU.
Page 16 of 20
5.4 PVST+, RSTP, and Rapid PVST+
This was a PVST protocol developed to support IEEE 802.1Q trunking (as opposed to ISL).
It is a proprietary protocol, only supported on Cisco devices.
Cisco developed extensions to the protocol including PortFast BPDU guard and root guard.
Page 17 of 20
5.4.2 Design STP for Trouble Avoidance
- Don’t leave it up to STP to decide the root bridge, choose your own one.
Generally, choose a powerful bridge in the middle of the network.
Being in the centre, it reduces the average distance from clients to servers and routers.
- If you don’t have a hierarchical design, you may need to tune STP cost parameters.
This usually isn’t necessary in hierarchical designs.
- Make a network diagram of root bridge, and the role of each port.
Page 18 of 20
- Keep STP Even if It Is Unnecessary
To fix the network, you need to know what it should look like.
Most troubleshooting involves simple show commands.
Imagine that an upstream interface has accidentally been configured with PortFast.
This can cause switching loops that will not be checked.
Eventually, a BPDU will be received, and the port will be set to blocked.
During that thime though, high throughputs of looped traffic may occur.
This could delay convergence, or actually bring the network down.
Page 19 of 20
- Network Diameter Issues
If you change the default timing values of STP, it may converge faster.
This is a dangerous thing to do thought; it could affect the stability of the network.
Page 20 of 20