Thursday, 7 March 2019

Spanning Tree


Since starting this blog here, I'm going to continue from where I left off with my studies.
I've been looking into Spanning Tree for the last few weeks and there are so many topic areas to cover. I am not accustomed to writing blogs and I've been rereading what I have written multiple times so hopefully not too many mistakes here :)

I'll try and keep information short and sweet.
Click the Read more link to expand the post. 
Let's start!


IEEE 802.1D is the standard for Common STP
It's labelled as common as uses a single STP instance to carry all VLANs.

STP is required to prevent loops/broadcast storms from occurring when you have redundant links between switches. Prevention is done by STP port blocking.

In Spanning Tree, lowest number wins.


Root Bridge:
The one who controls STP on your LAN segment.
Election Process: 2 factors
  • Priority
  • Bridge ID (MAC address)
Device with the lowest priority will become the Root Bridge.
If lowest priorities match, device with the lowest MAC address becomes the Root Bridge.
As MAC addresses are unique, there will be no clashes.
Note: If you are working with a stack of switches (ie. 3750x or 2960x), the MAC address of the Stack Master will be used.
#show switch detail
#show version
Look for the Base Ethernet MAC Address in Show Version


Bridge ID:
Consists of 8 bytes
-2 bytes for Bridge Priority
-6 bytes for MAC Address


Bridge Priority:
This field has undergone changes.
Out of the 16 bits (2 bytes), the last 12 bits have been taken and used as Extended System ID to accommodate newer types of STP. This allows them to differentiate the different VLANs for STP.
Reasoning: Bridge ID must be unique. PVST used a different MAC address for the Bridge ID per VLAN. There are more VLANs available than available MAC addresses per switch. Using the Extended System ID, they were able to incorporate the VLAN ID into this field. This is also known as MAC address reduction, introduced with 802.1D-2004.
Next interesting question is why priorities are in 4096 increments?

Below are 16 bits in the table.
Last 12 bits (Extended System ID) has been highlighted and can be ignored.
Focus on first 4 bits for priority.
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1

Lowest priority:
0000  0000  0000  0000  = 0
Default priority =
1000  0000  0000  0000  = 32768
Highest (value) Priority =
1111  0000  0000  0000  = 61440

0001 = 4096
0010 = 8192
0011 = 12288
1111 = 61440

Output from Switch:
Switch(config)#spanning-tree vlan 1 priority ?
  <0-61440>  bridge priority in increments of 4096
Remember that lowest priority wins.


Communication:
Switches talk to each other using BPDU's.
Bridge Protocol Data Unit - These provide data about the sending switch
Data includes:
  • Root Bridge ID
  • Root Path cost
  • Sender Bridge ID
  • Port ID
  • Message Age
  • Max Age
  • Hello time
  • Forward Delay


Scenario:
4 switches in a square setup.
Connections are as follows:
A-B
A-C
B-D
C-D

D is the root bridge.
A has two paths to get to D
Which path will it block and which path will it take?

Answer: A will choose the path with lowest cost. (can manipulate cost on interface)
If costs are equal, then it will choose the path with lowest bridge ID.

See port costs further down.


Route Manipulation Example:
By default, lowest number wins.
In this example, we have 2 switches with 3 parallel connections to each other.
1 will be active, other 2 will be blocked.

Sw1 (Root)
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg FWD 4         128.1   
Gi0/1               Desg FWD 4         128.2   
Gi0/2               Desg FWD 4         128.3   

Sw2
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Root FWD 4         128.1   
Gi0/1               Altn BLK 4         128.2   
Gi0/2               Altn BLK 4         128.3   

2 methods to manipulating the root port: Priority and Cost.

Priority is configured on the upstream switch (Sw1).
Sw2 will not see any changes but the Root port will be different.
Sw1: #int gi0/1
Sw1: #spanning-tree vlan 1 port-priority 96
  <0-224>  port priority in increments of 32

Sw1 (Root)
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg FWD 4         128.1   
Gi0/1               Desg FWD 4          96.2   
Gi0/2               Desg FWD 4         128.3   

Sw2
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Altn BLK 4         128.1   
Gi0/1               Root FWD 4         128.2   
Gi0/2               Altn BLK 4         128.3   


Cost is configured locally on the switch.
Local cost > upstream port-priority
Sw2: #int gi0/2
Sw2: #spanning-tree vlan 1 cost 3

Sw1 (Root)
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg FWD 4         128.1   
Gi0/1               Desg FWD 4          96.2   
Gi0/2               Desg FWD 4         128.3   

Sw2
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Altn BLK 4         128.1   
Gi0/1               Altn BLK 4         128.2   
Gi0/2               Root FWD 3         128.3   

See bottom of page for another example of changing the root port with redundancy.


Port Costs:
STP has been around for a long time (Thank you Radia Perlman!)
Over the years, connection speeds have increased dramatically and the values used for STP needed updating.

Bandwidth
Original 802.1D
Old 802.1D-1998 (Short)
New 802.1D-2004 (Long)
10 Mbps
100
100
2,000,000
100 Mbps
10
19
200,000
1Gbps
1
4
20,000
N x 1Gbps
-
3
10,000
10 Gbps
1
2
2,000
100 Gbps
-
-
200
1 Tbps
-
-
20
10 Tbps
-
-
2

By default, switches may still use 16bit (short) costs for STP.
To change this, enter the following:
Sw1(config)#spanning-tree pathcost method ?
  long   Use 32 bit based values for default port path costs
  short  Use 16 bit based values for default port path costs


Port Roles:
Root Port
Port that receives the best BPDU - path towards the root bridge
Designated Port
Designated only if it can send the best BPDU to the connected segment.
Alternate Port
Receives a 'useful' BPDU but doesn't beat 'Best'. Port is blocked.
There will always be a single Root port even if there are multiple links.
The port that receives the lowest BPDU will always win.


802.1D port states:
Blocking
A port that could potentially cause a loop. Nothing is sent but it will receive BPDU's to therefore remain in blocked state.
Listening
Processes BPDU's and awaits possible new information that would cause it to return to blocking state.
Learning
Populates MAC address table with data from frames received.
Forwarding
Is now receiving and sending data in Ethernet frames.
Continues to monitor BPDU to return to Blocking State.
Disabled
Manually disabled a switch port.

-----------------------------------------------------------------------------------------------
Route Manipulation Example 2:
Second example of tweaking Root Port selection.

4 switches in a Square with ports used:
Sw1 - Sw2 (Gi0/0)
Sw2 - Sw3 (Gi0/1)
Sw3 - Sw4 (Gi0/2)
Sw4 - Sw1 (Gi0/3)

Sw1 is the root bridge.
Sw4 root port is Gi0/3

Sw4: #show span vlan 1
Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg FWD 4         128.1   
Gi0/1               Desg FWD 4         128.2   
Gi0/2               Desg FWD 4         128.3   
Gi0/3               Root FWD 4         128.4   

Task:  We want Sw4 to go: Sw4 - Sw3 - Sw2 - Sw1
Current cost to reach the root bridge is 4.
If we shut interface Gi0/3 and #show span vlan 1 we can see the root cost taking the long route.

Sw4:
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    24577
             Address     00a5.cc4a.0f00
             Cost        4
             Port        4 (GigabitEthernet0/3)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Sw4 (Gi0/3 shut)
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    24577
             Address     00a5.cc4a.0f00
             Cost        12
             Port        3 (GigabitEthernet0/2)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

As we can see, cost to reach the root bridge has increased from 4 to 12.
If we want Gi0/3 to be blocked, we can change the cost of the interface for vlan 1 to a higher value.

Sw4: #int gi0/3
Sw4: #spanning-tree vlan 1 cost 13
Sw4: #no shut

Sw4 (Gi0/3 no shut)
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    24577
             Address     00a5.cc4a.0f00
             Cost        12
             Port        3 (GigabitEthernet0/2)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg FWD 4         128.1   
Gi0/1               Desg FWD 4         128.2   
Gi0/2               Root FWD 4         128.3   
Gi0/3               Altn BLK 13        128.4   


Now we will shutdown Gi0/2 to ensure Gi0/3 is used.

Sw4 (Gi0/2 Shut)
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    24577
             Address     00a5.cc4a.0f00
             Cost        13
             Port        4 (GigabitEthernet0/3)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr
------------------- ---- --- --------- --------
Gi0/0               Desg BLK 4         128.1   
Gi0/1               Desg BLK 4         128.2   
Gi0/3               Root FWD 13        128.4   

Interface Gi0/2 is not listed as it has been shut down.
-----------------------------------------------------------------------------------------------


References:




No comments:

Post a Comment