Showing posts with label Spanning Tree. Show all posts
Showing posts with label Spanning Tree. Show all posts

Thursday, August 8, 2013

And finally...RSTP

Rapid Spanning Tree, or RSTP, is an IEEE approved protocol designated 802.1w.  It shares some similarities and core function with STP, namely:
  1. Same root bridge election process
  2. Same path cost determination
It is fully backward-compatible, however the benefit of the "rapid" is lost when using RSTP along with STP.

RSTP changed the port states, replacing listening and learning with a single state of "discarding."  It also added some port types, which are "alternate" and "backup."

The alternate port takes the function of the root port should the root become in-operational, and the backup port takes the place of a designated port.  The port types are not "blocking" but "discarding" so they never need to go through the listening and learning states, allowing faster convergence.  The ports also have the ability to assume a different port role based on the condition of their links.  For instance - a port that is acting as a backup port can transition to a root port if its root port fails and the fastest path back to the root is through the other switch to which it is connected.

RSTP considers any port connected to another switch running in full-duplex to be a point-to-point link, while any half-duplex connection is considered to be link type "shared."  A half-duplex connection would typically be to a hub, although these are not in wide use any longer in 2013.  Any end-user devices such as PC or phone are considered to be edge-type links.  RSTP converges differently based on port type.

One major difference between RSTP and STP is that in STP, only the root bridge sends BPDUs, generally.  In RSTP, all switches send BPDUs to all other switches in the topology.  The BPDU is used for link state and root bridge identification, but also is used as a keep-alive.  If an RSTP switch misses 3 BPDUs (compared to STP's 20-second max age) it identifies that switch as dead and sends the TCN to all switches alerting to the change.

Edge type ports in RSTP are similar to using portfast and BPDU guard on that interface, except that by configuring the port with portfast it becomes an edge device and by default will transition to a point-to-point port type if it receives a BPDU.

Point-to-point ports handle convergence rapidly by following a different process than STP.  When a switch is introduced in to a network, and based on initial BPDU that alerts it that one of its local ports will become a designated port, it immediately transitions that port to the forwarding state and sends a proposal to the sending switch to start sending data.

The sending switch, upon receipt of the proposal, sets all other non-edge ports to discarding to deter loops and begins learning MAC addresses of its edge-type ports.  The process of putting nonedge ports into discarding state is called synchronizing the ports.

RSTP design and configuration is beyond the CCNA certification level, but it's good to know how and why it works.

Wednesday, August 7, 2013

Yet more Spanning Tree

Spanning-tree portfastome Cisco enhancements to STP are:

Portfast is a feature that skips the listening and learning states and the interface goes straight to forwarding, reducing the amount of time it takes for a port to come online.  This is useful when plugging in an end user device, such as a PC or phone.  However, if you plug in a switch or hub, you are going to want to enable BPDU Guard.

BPDU guard disables a portfast-enabled port if it receives a BPDU packet on that interface.  This way we avoid loops that would normally be discovered during the listening delay.

Uplinkfast is similar to portfast, but its use is in networks where there is a redundant uplink to from access-layer switches to core.  When a known uplink port goes offline, the second link will skip the listening and learning states and go straight to forwarding.

Backbonefast is similar to uplinkfast, however the access-layer switch does not have direct knowledge of the link failure, rather it exists between distribution switches.  Once the link between distribution switches goes offline, both think they are the root bridge and start advertising as such.  When the access layer switch forwards the distribution layer BPDU to the other distribution switch, it realizes it has a path to replace the link between switches and the topology converges.

These are all features of spanning-tree and their commands are:

R1(config-if)#spanning-tree portfast
R1(config-if)#spanning-tree bpduguard enable
R1(config-if)#spanning-tree uplinkfast
R1(config-if)#spanning-tree backbonefast

Or to enable BPDU guard globally, enter:

R1(config)#spanning-tree portfast bpduguard default

And you can tell if STP is configured on your switch by using:

R1# sho spanning-tree summary

Etherchannel is not necessarily a spanning tree enhancement, but is a means to utilize multiple links between switches.  Etherchannel will take up to 8 links and load balance across them in stead of disabling the extra links to avoid loops.  The ports must all be configured with the same speed and duplex to participate.  If one of the links in an etherchannel goes offline, the switch will still utilize the remaining ports and load balance accordingly.  To create an etherchannel, enter into each interface to participate in the etherchannel and use the channel-group <x> mode on command.  Cisco IOS then creates a logical interface called a port-channel interface so that parameters can be set on the entire port-channel from one location.





STP port transitions - I missed these somehow

Not sure how I missed this info in my last post, but it's important none the less.

Because STP is designed to remove switching loops while providing a redundant topology for the network, it needs a means to adjust port state if a failure occurs.  Spanning Tree goes through some transitional port states to move a port from blocking to forwarding, and each has a timer to keep the network from unnecessary loops during topology update.

The transition process and states of a port in a Spanning-Tree topology:

  1. Disabled - either administratively or due to security violation.  No data sent
  2. Blocking - no user data sent, but listening for BPDUs.  This state will wait 20 seconds before transitioning to the next state.  The 20 second timer is known as the max-age timer.  In essence, the switch needs to miss 10 BPDUs (2 seconds each) before it will transition
  3. Listening - no user data sent, listening for and forwarding BPDUs with topology updates.  This lasts 15 seconds
  4. Learning - no user data sent yet.  Adding MAC addresses it receives to the CAM table and building root path.  A port will take 15 seconds on this state as well.
  5. Forwarding - normal operation, user data sent
Based on this information, STP can take up to 50 seconds for a network to converge.  In small networks, these forward-delay timers can be manually set to quicken convergence.

When a nonroot switch recieves a BPDU indicating a topology change, it sends a special BPDU back to the root bridge called a Topology Change Notification, or TCN.  This is one of the only times a BPDU does not originate from the root bridge.  Once received, the root bridge will alert the other switches to start expiring their MAC address tables 8 times faster than the normal 300 seconds and to rebuild the root paths.

 The max-age and forward-delay timers are configured based on a network diameter of 7 switches.  The network diameter is the number of switches between any two hosts on the network.  If you have a small network diameter, such as 2 switches, these timers can be adjusted to lower values to speed convergence, however, when the network grows (like it always does) you will need to reconfigure these timers on the root bridge and the information will propagate to the rest of the network from there.

Friday, June 21, 2013

Spanning-tree Review

Spanning Tree was standardized in IEEE 802.1d as a layer-2 protocol designed to eliminate switching loops - or rather "bridging" loops since bridges were the prominent device at the time of adoption of the standard.

Root Bridge

The root bridge is the "master" bridge for maintaining all STP information within a network.  When a switch boots up, it immediately believes it is the root bridge and broadcasts a Bridge Protocol Data Unit (or BPDU) to all other switches on the network, at which time an election takes place.  The switch with the lowest bridge ID becomes the root.

The bridge ID is composed of two factors.  First is the root priority, which is a number between 0 and 61440, randomly assignable in increments of 4096 on the switch.  The default priority is 32768 (in hex, 8000), which all Cisco switches are initially configured with.  The second component of the bridge ID is the MAC address.  In the case of an election, the switch with the lowest root ID becomes the root.  First the priority is considered, then the MAC.

It is therefor advisable to configure the priority on a robust core switch when working in a highly complex or robust network to ensure that the switch controlling the STP is capable to handle the workload as well as in a central location.

BPDUs are multicast every two seconds by the root bridge following the initial election.  Contained in this packet is the bridge ID of the root bridge, and as long as that number is lower than the ID of the switch receiving the BPDU no election will be forced.  If a BPDU arrives with a lower ID than is configured on the switch, an election takes place and the STP topology will reconverge.

Root ports

After election of a root bridge, each nonroot switch forms an association back to the root.  The path with the lowest cumulative cost is placed into a forwarding state, and all other paths to the root are placed in a blocking state.  This information is contained in the BPDU, along with the root bridge ID and the sending switch's bridge ID. The cost  is the inverse of the bandwidth on the link between it and the root, so the lowest cost is the fastest path back to the root.  Costs are:

10 Gb:  Cost 2
1 Gb:  Cost 4
100 Mb:  Cost 19
10 Mb:  Cost 100

Each switch that receives a BPDU from the root will have a cost of 0.  It adds the cost of the interface on which it was received to that value and forwards that information to other switches with the new cost.  Each switch in turn performs the same action to determine what is the most efficient path to the root.

When equal cost paths are available, the system determines which port becomes the root port by first looking at the bridge ID and will select the lowest ID as the root.  If both links are to the same switch, it will use the lowest port priority, which is 128 by default but can be administratively set to chooose one link over another.  If port priority is equal, the switch will choose the lowest port number to determine the root port.

Designated Ports

 Designated ports connect to another switch and are a path back to the root bridge.  They are the "input" to the "output" of the root port and are selected based on the same path cost criteria as the root port.

Blocked Ports

When there are two paths from a switch back to the root port, STP will block client traffic from leaving the port with the highest path cost back to the root.  The port will still listen for BPDUs so that the switch can react to topology changes and notifications, but it simply doesn't send any data.

Port State Transitions

STP ports will go through a process of transitioning from a blocked state to a forwarding state.  Those states are:

Blocking - no client data is sent, but still listens for BPDU
Listening - no client data sent, but listens for topolgy updates
Learning - no client data sent, but learning MAC addresses on connected ports
Forwarding - now passing data as well as listening for BPDUs

The timers associated with those states:

Blocking - 20 seconds (max age timeout, or 10 BPDUs missed)
Listening - 15 seconds
Learning - 15 seconds

When a link goes down, a topology change notification BPDU (TCN BPDU) is sent from the switch reporting a link failure.  This is one of the only times a BPDU doesn't originate from the root bridge.   The root will eventually receive the TCN and notify the switches in its topology to start aging out MAC addresses 8 times more quickly than its default of 300 seconds.  The switches then begin rebuilding the topology by assigning ports to either designated, root or blocking states based on the updated condition of the network.

Because of these default timers, a network could take up to 50 seconds to converge and start sending data again.  To modify the default timers, only the root bridge needs to be adjusted and the timer changes will propagate through the topology.