Tuesday, January 04, 2011

CCNA 640-802 Study Note Spanning Tree Protocol

Building redundancy into the network can help to eliminate single point of failure.  However, it also introduce some other problems.  Some of the problems are as follows:

  • Broadcast storms: This occurs when each switch on a redundant network floods broadcast frames endlessly.
  • Multiple frame transmission: This happens when multiple copies of the unicast frames get delivered to the destination device.
  • MAC database instability: When copies of the same frame was received from different ports of a switch, it caused the switch to keep updating its MAC address table.  The switch not able to cope with the MAC database instability can have problem forwarding frames.

To resolve the above problems, some kind of loop avoidance mechanism is needed and Spanning Tree Protocol  (STP) is the answer to it. 

Basically, STP put certain ports in the redundant network into a standby mode so that those ports do not listen to, forward or flood data frames.  This ensures that there is only 1 path to each network segment that is active at any time.  When there is problem with the active path, STP will activate the standby path to re-establish the connectivity.

The basic concept of STP consists of the following:

  • Bridge ID: Make up of Bridge Priority and MAC address.  For Per VLAN STP, it is make up of Bridge Priority, Extend System ID (VLAN) and MAC address.
  • Root bridge: One per broadcast domain.  Switch with the lowest Bridge ID will be the root bridge.  All of its ports are designated ports in forwarding state.
  • Root port on nonroot bridge: Root port is the port with the lowest-cost path from the nonroot bridge to the root bridge. Root ports are normally in the forwarding state.
  • Designated port: Designated port is selected on the bridge that has the lowest cost path to the root bridge and is in the forwarding state.
  • Non-designated port: Non-designated port will be in the blocking state which logically break the loop.  In blocking state, the port still receive traffic but do not forward.

Each port transits through several different states when STP is enabled.  The 5 STP port states are Blocking, Listening, Learning, Forwarding and Disabled.  It typically takes 30s to 50s for a port to transit from blocking state to forwarding state.  However, Rapid STP needs just a few seconds to transit from blocking state to forwarding  state.

STP uses the following Spanning Tree Path Cost to compute the lowest cost path for the selection of root port and designated port.

Link Speed

Cost

10 Gb/s

2

1 Gb/s

4

100 Mb/s

19

10 Mb/s

100

Because it takes time for spanning tree to converge, switch ports that are meant for access (e.g. connecting to end user workstations) should have PortFast enabled.  With PortFast enabled, it will allow the switch ports to transit from blocking state to forwarding state.

The following enable PortFast on interface fa0/2 of SwitchA.

SwitchA(config)#int f0/2
SwitchA(config-if)#spanning-tree portfast

The following command enable PortFast on all non-trunking ports.

SwitchA(config)#spanning-tree portfast default

To verify PortFast has been enabled on an interface, use the following command.

SwitchA#sh run int f0/2

Okay, let’s try out spanning tree on this little setup.

image

Here is how the setup was done.

Interface fa0/2 on both SwitchA and SwitchB have their PortFast enabled to minimize the time for the ports to converge.

VLAN 2 was added on SwitchA, CoreSwitchA and CoreSwitchB.

VLAN 3 was added on SwitchB, CoreSwitchA and CoreSwitchB.

Make the CoreSwitchA as the root bridge for VLAN 2 and 3 by lowering the priority value to 28672.  The default priority value is 32768.

CoreSwitchA(config)#spanning-tree vlan 2 priority 28672
CoreSwitchA(config)#spanning-tree vlan 3 priority 28672

As you can see that we have created multiple links for VLAN 2 and 3 to forward frames.  For example, for VLAN 2, if SwitchA needs to forward a frame to CoreSwitchA, it can go through the following paths.  This creates redundancy so that frames can continue to be forwarded even 1 of the path was down but also the problem of looping.

fa0/11 (SwitchA) –> fa0/1 (CoreSwitchA)
fa0/12 (SwitchA) –> fa0/1 (CoreSwitchB) –>fa0/13 (CoreSwitchB) –> fa0/13 (CoreSwitchA)
fa0/12 (SwitchA) –> fa0/1 (CoreSwitchB) –>fa0/14 (CoreSwitchB) –> fa0/14 (CoreSwitchA)

Now, we will configure rapid spanning tree for VLAN 2 and 3.

SwitchA(config)#spanning-tree mode rapid-pvst
SwitchB(config)#spanning-tree mode rapid-pvst

Okay, done.  The spanning tree will start to converge.

We will just look at how the spanning tree for VLAN 2 workout to be since it is going to be the same for VLAN 3.

We will run the sh spanning-tree command on SiwthcA, CoreSwitchA and CoreSwitchB to find out who is the root bridge, which ports are the designated ports, root ports and non-designated ports.

SwitchA#sh spanning-tree vlan 2
VLAN0002
  Spanning tree enabled protocol rstp
  Root ID    Priority    24578
             Address     0003.E4D0.4862
             Cost        19
             Port        11(FastEthernet0/11)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32770  (priority 32768 sys-id-ext 2)
             Address     00D0.BCEC.E8C3
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/11           Root FWD 19        128.11   P2p
Fa0/12           Altn BLK 19        128.12   P2p

SwitchA is an non-root bridge.  Fa0/2 is a designated port, fa0/11 is a root port and both are in forwarding state.  Fa0/12 is a non-designated port with a blocking state.

CoreSwitchA#sh spanning-tree vlan 2
VLAN0002
  Spanning tree enabled protocol ieee
  Root ID    Priority    24578
             Address     0003.E4D0.4862
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    24578  (priority 24576 sys-id-ext 2)
             Address     0003.E4D0.4862
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/13           Desg FWD 19        128.13   P2p
Fa0/14           Desg FWD 19        128.14   P2p
Fa0/23           Desg FWD 19        128.23   P2p

CoreSwitchA is the root bridge.  Therefore, all its ports are designated ports and all are in forwarding state.

CoreSwitchB#sh spanning-tree vlan 2
VLAN0002
  Spanning tree enabled protocol ieee
  Root ID    Priority    24578
             Address     0003.E4D0.4862
             Cost        19
             Port        13(FastEthernet0/13)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32770  (priority 32768 sys-id-ext 2)
             Address     0001.426D.309B
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/13           Root FWD 19        128.13   P2p
Fa0/14           Altn BLK 19        128.14   P2p

CoreSwitchB is an non-root bridge.  Fa0/1 and fa0/2 are designated ports, fa0/13 is a root port and all are in forwarding state.  Fa0/14 is a non-designated port with a blocking state.

From the information gathered, we can figure out that the active path is the one highlighted in yellow on the diagram below.  The red crosses show that fa0/12 of SwitchA and fa0/14 are in blocking state so no frames will be forwarded through that 2 links.

image

However, if there is connectivity issue, for example, fa0/11 on SwitchA is down.  The spanning tree will re-converge and it will bring up fa0/12 to take the alternate path.

You can also used the following commands to configure a switch to be the root bridge and another switch as a backup root bridge.  The following example, it made CoreSwitchA as the root bridge of VLAN 2 and CoreSwitchB as the standby root bridge.

CoreSwitchA(config)#spanning-tree vlan 2 root primary
CoreSwitchB(config)#spanning-tree vlan 2 root secondary

Okay, onto VLSM next and I can start to see those ones and zeros floating in front of my eyes!!!

No comments: