1-R&S/Virtual LAN (VLAN) and Spanning Tree Protocol (STP).

In this post i will talk about Virtual LAN (VLAN) and Spanning Tree Protocol (STP) and its main purpose and why we use them in our switched network.

Virtual LAN (VLAN):

All of us know what is the Local Area Network LAN, simply as the name implies, the LAN is considered as a group of devices that can communicate with each others by sending and receiving data using the well-known networking protocols that are responsible for handling the data exchange between these devices based on certain well-known models (TCP/IP, OSI , …) because as we know each of these protocols work on different layer of these models to be able to make every part in the data exchange process to be organized and easy to be implemented and managed. The large networks such as Internet or large Service providers or even small enterprises simply are just collection of many LANs that interconnect with each others that requires certain more intelligent device that can forward the data based on more additional information seen on the data itself, so it is placed in between those LANs to interconnect with each others, but let’s focus on the communication within the same LAN, simply the devices that are connected with each others on the same LAN can communicate directly once they are connected to the LAN (as long as the IP addresses of the devices are on the same IP subnet), and this connection happens by connecting the devices either to an interconnecting device such as Hub, bridge or Switch, so this interconnecting device forwards the data either based on sensing the electrical signal (using CSMA/CD) which is done when you use Hub for your LAN or based on the information seen on the Layer 2 (which is the physical/MAC address) which is done when you use bridge or switch for your LAN, but let’s ignore the Hub from this discussion. When the devices are connected to the same LAN we can say that these devices belong to the same broadcast domain, this means that when one  device send broadcast frame (i.e frame with all ones as its destination MAC address ff:ff:ff:ff:ff:ff) toward the LAN, the switch receives this broadcast frame and send/forward it out all its ports except the port received this frame from, then all the other devices receive and process this frame as they are part of this broadcast domain so they process it and see what is inside this frame. But if we want to limit this behavior, specially when most of the devices connected to that switch don’t need to communicate with each others so no need to send such broadcast frames out all the ports because this utilize BW, processing and memory from the point of view of both the switch and the devices, so what can we do ? simply we can partition this huge broadcast domain into sub-broadcast domains or multiple broadcast domains and this happen by isolating some ports from each others, so that some ports are in the same sub-broadcast domain and still can exchange broadcast frames with each others, while the other ports can’t see their broadcast frames as they don’t need such frames, hence we can make this by using the VLAN technology, this means that we partition the LAN into multiple VLANs, at which each VLAN represents separate broadcast domain and each device member in this VLAN still can exchange unicast, multicast or broadcast frames  normally without the need of intermediate more intelligent device that is needed to interconnect the VLANs. The below figure shows LAN and VLAN topology:

lan  vlanLet’s see how to configure VLAN on Cisco switches:

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#name TEST2
Switch(config-vlan)#exi
Switch(config)#^Z
Switch#

Let’s see how to assign switchport to certain VLAN or to make it member in certain VLAN:

Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. 
Switch(config)#interface Ethernet0/0
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#end
Switch#

The command “switchport mode access” is used to define this switchport as access mode, this means that this switchport should be member in only one VLAN, or this switchport will carry traffic only for one VLAN.

The command “switchport access vlan 2” is used to make this switchport member in VLAN 2.

Let’s see how to show the VLAN configured on the switch:

Switch#show vlan brief

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Et0/1, Et0/2, Et0/3, Et1/0
 Et1/1, Et1/2, Et1/3
2 TEST2 active Et0/0
1002 fddi-default act/unsup 
1003 token-ring-default act/unsup 
1004 fddinet-default act/unsup 
1005 trnet-default act/unsup 
Switch#
Switch#show vlan id 2

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
2 TEST2 active Et0/0

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
2 enet 100002 1500 - - - - - 0 0

Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------

Switch#

The command “show vlan brief” is used to show the defined VLAN (default and user defined VLANs) and at the same time tell you which switchports are assigned to which VLAN.

The command “show vlan id 2” is used to provide more information about the VLAN 2, to know the type of this VLAN and it shows here it is Ethernet VLAN, has system MTU of 1500 and the switchport Ethernet0/0 is assigned to this VLAN.

Assume that our network consists of multiple switches and we need to divide our network/LAN into multiple VLANs (Server, Users, …..) this means that we need all the servers to be member on the same VLAN, all the users to be member on the same VLAN, an so on…. as well assume that the servers are not connected to only one switch, while they span on multiple switches (i.e two servers connected to switch 1, two servers connected to switch2, and so on…), so how can we handle the inter-switch links ?

The answer is simple, if we have two VLANs, so we connect two links between each switch, so that one link is member in the Servers VLAN  while the other link is member in the Users VLAN, is this correct ? for sure yes and will work, but what happens if we have 20 VLANs ? 🙂 🙂  i think connecting 20 links between each switch will not save us, for this reason we need more reliable, less cost and easy to implement and manage solutions, do you know it ? yes, it is a technology we can use to make the inter-switch link to be member on multiple VLANs at the same time and this is what we know by the “Trunking protocol”, so what is the meaning of the trunking protocol ? it is a protocol that allow switch to make the inter-switch link to be member on multiple VLANs at the same time, hence it can carry traffic of multiple VLANs at the same time.

There are two trunking protocols that we can use, Inter-Switch Link (ISL) which is Cisco proprietary (i.e it is used only on Cisco devices) or IEEE 802.1Q which is standard and can be used by all the vendors, so let’s talk about IEEE 802.1Q:

IEEE 802.1Q is a trunking protocol and we call it tagging mechanism that use tagging to distinguish between the different VLANs, this means that it add tag along with the Ethernet frame to identify which VLAN this Ethernet frame belongs to, when we have multiple VLANS configured on the VLAN database, we configure the links between the switches to be configured as “Trunk” not “access” as mentioned at the previous section, so that the link between the switches can carry Ethernet frames belong to multiple VLANs, hence we don’t need to connect multiple links between the switches equal to the number of VLANs we have as this is wasting resources, requires high cost, not easy at all to implement, manage and not logical as well. The following figure shows simple topology consists of two switches:

tag

We can see here that there are two defined VLANs (Users and Servers VLANs) so we need to use the trunking protocol (IEEE 802.1Q at our case) which is used to add certain tag along with the Ethernet header so that it can know which VLAN this Ethernet frame belongs to in order to forward the frame out the correct switchports, so let’ see the configurations needed to configure the IEEE 802.1Q tagging on the inter-switch links:

Switch1 configurations:

Switch1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch1(config)#interface Ethernet0/1
Switch1(config-if)#switchport trunk encapsulation dot1q 
Switch1(config-if)#switchport mode trunk 
Switch1(config-if)#end
Switch1#

Switch2 configurations:

Switch2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch2(config)#interface Ethernet0/1
Switch2(config-if)#switchport trunk encapsulation dot1q
Switch2(config-if)#switchport mode trunk 
Switch2(config-if)#end
Switch2#

The command “switchport trunk encapsulation dot1q ” is used to define the encapsulation/trunking method to be used on this inter-switch link.

The command “switchport mode trunk” is used to configure this inter-switch link as trunk port, hence it can carry multiple VLANs at the same time.

Let’s see how to verify the status of the trunk ports:

Switch1#show interface Ethernet0/1 trunk

Port Mode Encapsulation Status Native vlan
Et0/1 on 802.1q trunking 1

Port Vlans allowed on trunk
Et0/1 1-4094

Port Vlans allowed and active in management domain
Et0/1 1-2

Port Vlans in spanning tree forwarding state and not pruned
Et0/1 1-2
Switch1#

 

Switch2#show interface Ethernet0/1 trunk

Port Mode Encapsulation Status Native vlan
Et0/1 on 802.1q trunking 1

Port Vlans allowed on trunk
Et0/1 1-4094

Port Vlans allowed and active in management domain
Et0/1 1-2

Port Vlans in spanning tree forwarding state and not pruned
Et0/1 1-2
Switch2#

 

The previous figure shows that switchport Ethernet0/1 is configured as Trunk port, using 802.1Q as an encapsulation protocol and the native vlan here is 1, as well the VLANs allowed on this trunk are from 1 – 4094, but only the active VLANs are 1 and 2.

Switch1#show interface Ethernet0/1 switchport
Name: Et0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
 --More-- 

 

Switch2#show interface Ethernet0/1 switchport
Name: Et0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
 --More-- 

Switchport: Enabled, this indicates that this port is working as Layer 2 port.

Administrative Mode: trunk, this indicates that you configured the switchport as Trunk.

Operational Mode: trunk, this indicates that the switchport is operational as Trunk.

Administrative Trunking Encapsulation: dot1q, this indicates that you configured the trunking encapsulation protocol to be dot1q.

Operational Trunking Encapsulation: dot1, this indicates that the operational trunking encapsulation protocol is dot1q.

Negotiation of Trunking: On, this indicates that you enabled the negotiation of trunking protocol (i.e you enabled the Dynamic Trunking Protocol (DTP) on this switchport).

Trunking native Mode VLAN: 1 (default), this indicates that the native VLAN is 1 and it is the default configuration.

The following figure shows the 802.1Q tag that is added along with the Ethernet header by the switch when it forward the Ethernet frame out the inter-switch links:

5

Let’s see the complete Ethernet frame (including Ethernet header, 802.1q tag, IPv4 packet header and ICMP payload) using Wireshark when i ping from one PC to the other:

6

In the previous figure we can see that there are three important fields:

  1. Priority field: Which is used to mark the Ethernet frame to perform some QoS.
  2. VLAN ID: Which is used to define the VLAN number this Ethernet frame belongs to.
  3. Ether Type: Which is used to indicates the type of payload carried inside this Ethernet frame.

 

Spanning Tree Protocol (STP):

Why we need STP ?, we need the STP for multiple reasons, so assume the topology in the following figure to explain the need for STP in our Layer 2 switched network:

8

In the previous topology we see that most of the switches are connected with each others in a ring topology, assume that PC1 need to send traffic to PC2, so let’s check what happen in sequence:

  1. PC1 generated the data/payload needed to be sent to PC2, so the data pass over each Layer of the TCP/IP model so that each model add the required header as we already know, once it reaches Layer 2 it needs the MAC address of PC2 to add it at the destination address field at the Ethernet header.
  2. PC1 send ARP request to know the MAC address of PC2, and you already know that the ARP request is sent with destination MAC address (ff:ff:ff:ff:ff:ff) to sent as a broadcast frame so that all the devices within the same VLAN receive and process it and the requested PC (PC2) replies with proper ARP reply.
  3. Switch1 received the ARP request, and it found it is a broadcast so it send it out all the ports Eth0/1, Eth0/2 and Eth0/3.
  4. Switch2, Switch3 and Switch4 do the same thing by switching this broadcast frame out Eth0/0 and Eth0/2 by Switch2, Eth0/1 by Switch3 and Eth0/0 and Eth0/1 by Switch4.
  5. Then each switch received the ARP request from the other switches and the same thing is repeated infinitely and this caused infinite Loop that caused 100% BW, memory and processing utilization, hence the network is not operational anymore.

So at this situation we need to use certain method that prevent this infinite loop from happening, we should use the STP for that purpose. The STP is used for multiple reasons, one of them mentioned at this example, as well it should be used if we need to connect multiple uplinks from the Access switch to its Distribution switch(es), because when connecting multiple uplinks this can result in infinite loop, as well we should use STP in case there is a human mistake/error that can results in ring topology and finally results in infinite loop, simply we need the STP to be implemented by default as a plug and play feature in every network to avoid any possible loops and results in logical loop-free layer 2 switched network.

Now let’s talk about the different STP protocols and their modes. There are different protocols for spanning tree such as: STP (IEEE 802.1d) and RSTP (IEEE 802.1w) and different modes such as:  PVST, PVST+, RPVST, RPVST+ and MST.

1-STP(802.1d): The STP is the first spanning tree protocol to be implemented in the switched network, the STP is the same as Common Spanning Tree (CST), at which is used in the switched network to implement spanning tree for all the VLANs, i mean it runs single instance of spanning tree for all the VLANs configured on the switch, but before we talk about what is the meaning of single or multiple instances of STP, we should talk about how the STP works to understand what happens when the switch implement single instance and what happens when implementing multiple instances, so let’s see first how the STP works.

How STP works ?

As we have seen before in the previous topology, there are 4 switches connected in this switched network and they form ring topology and to prevent the infinite loop we need the STP to be operational, simply the STP works by cutting this ring topology, this means that it should block the traffic from being exchanged on one of the links, so by this action the switched network no longer form ring topology, but the good question here, how the STP performs this action ? all the switches participate in this STP domain should co-operate with each others to determine which link should be cut/blocked  (we use “block” terminology from STP point of view) and this happens by choosing one of the switches to control the STP operation/behavior in this STP domain and this switch is called by “Root switch/bridge”, this means that they need to join election to determine which switch will be elected as “Root switch/bridge”, once this happens the switched network starts to synchronize and select which link should be blocked, so let’s see what happen in sequence regarding the STP operation:

  1. Every switch in this STP domain send certain message called by “Configuration BPDU ” and BPDU stands for “Bridge Protocol Data Unit” which is used by the switches to determine which switch will be elected as Root Switch/Bridge, but which switch will be elected as Root switch/bridge ? the answer is the switch with the best switch/bridge ID (the best means the lowest in numerical value). The bridge ID consists of two parts (bridge priority + bridge MAC address) as the following figure: bridge id   As we can see, the bridge priority is 2 bytes length, while the bridge MAC address is 6 bytes length as already known, this means that the switch that has the lowest numerical bridge ID should be elected as the Root Switch/Bridge.
  2. Switch1, Switch2, Switch3 and Switch4 send their configuration BPDUs out all their interfaces (Eth0/0, Eth0/1, Eth0/2 and Eth0/3 but no need to mention Eth0/2 as it is connected to PC so the STP election will not be affected if we exclude this port from our explanation). It is not required that all the switches send their configuration BPDU at the same time as not all the switches become online in the network at the same time, but i will mention this worst case (i.e all the switches send their configuration BPDU at the same time) just to make everything to be clear.
  3. Let’s see first the configuration BPDU format and explain its fields/components: bpdu1-Protocol Identifier: This field indicates the identity of the STP protocol and has value of 0x0000.
    2-Protocol Version: This fields indicates the version of the STP protocol, and at this case it indicates that the version of the STP is 00.
    3-BPDU Type: This field indicates the type of this BPDU, either configuration or Topology change BPDU.
    4-Flags: This field indicates certain option related to this BPDU and it has length of 8 bits, but at STP 802.1d only the first and last bits are used, and used only when this BPDU is related to change happened in this switched network (i.e for topology change BPDU and its Acknowledge).
    5-Root Bridge ID: This field is used to carry the Root bridge ID.
    6-Root Path Cost: This field indicates the cost of the path used to reach the Root Bridge by the sender of this message.
    7-Sending Bridge ID: This field indicates the Bridge ID of the sender of this message.
    8-Sending Port ID: This filed indicates the Port ID of the exit port that this sender send this message out, the Port ID consists of two parts (Port priority + Port number), the Port number is H/W value and can’t be changed.
    9-Message Age: This filed indicates the age of the BPDU message in the STP domain starting from its generation from the Root bridge till this sender switch.
    10-Max Age: This filed indicates the maximum age the switch can wait before it consider that the superior BPDU that is generated by the Root Bridge expired. (Superior BPDU means the best BPDU the switch see, which indicates the BPDU generated by the Root Bridge), its default value is 20 seconds.
    11-Hello time: This field indicates the periodic interval for sending the BPDU message, this means that the Root Bridge send the BPDU message every this hello interval, its default value is 2 seconds.
    12-Forward Delay: This field indicates certain transition timer that it use to transit from one state to another, there are 5 states for the STP 802.1d (Disabled, Blocked, Listen, Learn and Forward), the Disabled state indicates that the port is not participating in the STP process or shutdown,  the Blocked state indicates that the switch can’t switch traffic on this port, as well it can’t learn MAC addresses on this port, the Listen state indicates that the switch decides that it should transit from the Blocking state to the Forwarding state but this should happen through transition states to avoid Loop during this transition and during this state the switch still doesn’t forward or accept frames on this port and the switch stays 15 seconds in this state, the Learning state indicates that the switch learns the MAC addresses on this port to be ready to finally transit to the Forwarding state and can switch and receive frames on this port after 15 seconds, so it stays 15 seconds in this state, the Forwarding state indicates that the switch finally can send or receive frames on this port normally, so the Forward Delay timer is the timer used by the switch to transit from Listen state to Learn, and from Learn to Forward and it is default value is 15 seconds.
  4. Let’s see the important info including Bridge ID, Port ID on the topology:
    8As mentioned here, we can see that every switch (Switch1, Switch2, Switch3 and Switch4) send the configuration BPDU out every port (again i excluded the ports connected to the PCs for simplicity), as well we can see both Bridge ID and ID of each port so that we can explain the criteria used by STP to determine which switch will be the Root Bridge and which port will be blocked, so let’s continue the steps.
  5. The STP use the following criteria to choose which switch will be the Root bridge:
    1-When the switch receive two configuration BPDUs, it compares the two Root Bridge ID, then it  chooses the best ID (again the best is the lowest numerical value) seen in the Root Bridge ID field, if the two Root bridge IDs of the two BPDUs are the same, so it check the next step.
    2-The switch then check the Root Path Cost field in the two BPDUs and choose the lowest root path cost, if the two Root Path Cost of the two BPDUs are the same, so it check the next step.
    3-The switch then check the Sender Bridge ID field in the two BPDUs and chooses the lowest Sender Bridge ID, if the two Sender bridge IDs of the two BPDU are the same, so it check the next step.
    4-The switch then check Sender Port ID field in the two BPDUs and choose the lowers Sender Bridge ID.
  6. Switch1 and Switch2 exchange the configuration BPDU wit each others, and as seen here we can find the Bridge ID of Switch1 (32769.aabb.cc00.0100) is better than of Switch2 (32769.aabb.cc00.0300), so Switch2 will not send its BPDU anymore as it knows that Switch1 has better BPDU. The below figure shows the configuration BPDU of the two switches as seen on Wireshark:Switch1 BPDU:1-2
    Switch2 BPDU:2-1
  7. Switch1 and Switch3 exchange the configuration BPDU with each others, and as seen here we can find the Bridge ID of Switch1 (32769.aabb.cc00.0100) is better than of Switch3 (32769.aabb.cc00.0200), so Switch3 will not send its BPDU anymore as it knows that Switch1 has better BPDU. The below figure shows the configuration BPDU of the two switches as seen on Wireshark:Switch1:1-2Switch3:3-1
  8. Switch1 and Switch4 exchange the configuration BPDU with each others, and as seen here we can find the Bridge ID of Switch1 (32769.aabb.cc00.0100) is better than of Switch3 (32769.aabb.cc00.0700), so Switch4 will not send its BPDU anymore as it knows that Switch1 has better BPDU. The below figure shows the configuration BPDU of the two switches as seen on Wireshark:Switch1:1-2Switch4:4-1
  9. The same steps happen between (Switch3 and Switch4) and (Switch2 and Switch4) at the same time as the previous steps.
  10. After Switch2, Switch3 and Switch4 no longer send their own BPDUs and confirmed that the configuration BPDU generated by Switch1 is the superior BPDU.
  11. At this point we can conclude that Switch1 is elected as the “Root Bridge”. All the ports of the Root Bridge are in “Designated” role and in “Forwarding” state, i mentioned the different states, so let’s check the different roles:
    1-Root Port: This port is the best port to reach the Root Bridge (i.e it has the lowest cost to reach the Root Bridge).
    2-Designated Port: This port indicates that this local Switch is the designated bridge in this link/segment, there are two switches participating in this link/segment, so the switch that has the superior BPDU is considered as the Designated switch/bridge, hence its port has the Designated role.
    3-Alternate Port: This port is the second best port to reach the Root Bridge (i.e it has the next lowest cost to reach the Root Bridge).
    For sure the Root Bridge (Switch1 at our case) is considered as the Designated switch as well on all the links/segments so all its ports should have the “Designated” role.
  12. Switch2 choose port Eth0/1 as the Root bridge, Switch3 choose port Eth0/0 as the Root bridge and Switch4 choose Eth0/3 as the Root bridge (assume that all the links have the same cost). The following figure shows the resulting topology:8 - CopyIt shows that the other switches stop sending their own BPDU and start to forward/relay the Superior BPDU out the other ports so that they can determine which port will be Designated and Alternate.
  13. Based on the STP criteria, Switch2 and Switch4 determined that Switch2 has the best sender Bridge ID (32769.aabb.cc00.0300), so it is elected as the Designated switch, hence its port has the Designated role and is put in the Forwarding state, while Switch4’s port has the Alternate role and is put in the Block state.
  14. Switch3 and Switch4 determined that Switch3 has the best sender Bridge ID (32769.aabb.cc00.0200), so it is elected as the Designated switch, hence its port has the Designated role and is put in the Forwarding state, while Switch4’s port has the Alternate role and is put in the Block state.
    The following figure shows the final loop-free topology:
    8- So after this we can deduce that the STP prevent the Loop from happening because the two links between (Switch4 and Switch2) and (Switch4 and Switch3) are blocked and cut from this Layer 2 switched network, hence the traffic can’t Loop in this resulting Layer2 loop-free switched network.

 

Now Let’s verify the STP on the 4 switches:

Switch1:

Switch1#show spanning-tree

VLAN0001
 Spanning tree enabled protocol ieee
 Root ID Priority 32769
 Address aabb.cc00.0300
 This bridge is the root
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
 Address aabb.cc00.0300
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
 Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 Shr 
Et0/1 Desg FWD 100 128.2 Shr 
Et0/2 Desg FWD 100 128.3 Shr 
Et0/3 Desg FWD 100 128.4 Shr 

Switch2:

Switch2#show spanning-tree

VLAN0001
 Spanning tree enabled protocol ieee
 Root ID Priority 32769
 Address aabb.cc00.0300
 Cost 100
 Port 1 (Ethernet0/1)
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
 Address aabb.cc00.0500
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
 Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 Shr 
Et0/1 Root FWD 100 128.2 Shr 
Et0/2 Desg FWD 100 128.3 Shr 
Et0/3 Desg FWD 100 128.4 Shr

Switch3:

Switch3#show spanning-tree

VLAN0001
 Spanning tree enabled protocol ieee
 Root ID Priority 32769
 Address aabb.cc00.0300
 Cost 100
 Port 1 (Ethernet0/0)
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
 Address aabb.cc00.0c00
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
 Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Root FWD 100 128.1 Shr 
Et0/1 Desg FWD 100 128.2 Shr  
 
Switch3#

Switch4:

Switch4#show spanning-tree

VLAN0001
 Spanning tree enabled protocol ieee
 Root ID Priority 32769
 Address aabb.cc00.0300
 Cost 100
 Port 1 (Ethernet0/3)
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
 Address aabb.cc00.0700
 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
 Aging Time 300 sec

Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Altn FWD 100 128.1 Shr 
Et0/1 Altn FWD 100 128.2 Shr  
Et0/3 Root FWD 100 128.4 Shr  
 
Switch4#

To briefly know the STP Root bridge you can issue the command “show spanning-tree root”

Swicth1:

Switch1#show spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 aabb.cc00.0300 0 2 20 15  
Switch1#

Switch2:

Switch2#sh spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 aabb.cc00.0300 100 2 20 15 Et0/1 
Switch2#

Switch3:

Switch3#show spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 aabb.cc00.0300 100 2 20 15 Et0/0 
Switch3#

Switch4:

Switch4#show spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 aabb.cc00.0300 100 2 20 15 Et0/3 
Switch4#

There are two methods the STP uses to choose the best path either by choosing the shortest path or longest path and you can check this using the command “show spanning-tree pathcost method “:

Switch1#show spanning-tree pathcost method 
Spanning tree default pathcost method used is short
Switch1#

You can see the BPDUs sent or received by the switch by using this debug command “debug spanning-tree bpdu transmit” and “debug spanning-tree bpdu receive”:

Switch1:

Switch1#debug spanning-tree bpdu transmit 
Spanning Tree BPDU Transmitted debugging is on
Switch1#
*Jan 1 20:17:44.614: STP: VLAN0001 Et0/0 tx BPDU: config protocol=ieee
 Data : 0000 00 00 00 8001AABBCC000300 00000000 8001AABBCC000300 8001 0000 1400 0200 0F00
*Jan 1 20:17:44.615: STP: VLAN0001 Et0/1 tx BPDU: config protocol=ieee
 Data : 0000 00 00 00 8001AABBCC000300 00000000 8001AABBCC000300 8002 0000 1400 0200 0F00
*Jan 1 20:17:44.615: STP: VLAN0001 Et0/2 tx BPDU: config protocol=ieee
 Data : 0000 00 00 00 8001AABBCC000300 00000000 8001AABBCC000300 8003 0000 1400 0200 0F00
*Jan 1 20:17:44.615: STP: VLAN0001 Et0/3 tx BPDU: config protocol=ieee
 Data : 0000 00 00 00 8001AABBCC000300 00000000 8001AABBCC000300 8004 0000 1400 0200 0F00
Switch1#u all
All possible debugging has been turned off
Switch1#

We found here that Switch1 sent 4 Configuration BPDU out the 4 ports (Eth0/0, Eth0/1, Eth0/2 and Eth0/3), based on the debug O/P we can deduce the following info
1-Protocol ID: 0000
2-Protocol Version: 00
3-BPDU Type: 00
4-BPDU Flags: 00
5-Root ID: 8001AABBCC000100 (8001 is the Hex form of the Root priority, AABBCC000100 is the Root MAC address).
6-Root Path Cost: 00000000
7-Bridge ID: 8001AABBCC000100 (8001 is the Hex form of the Bridge priority, AABBCC000100 is the Bridge MAC address).
8-Sender Port ID: 8001 (the Hex form of 128.1)
9-Message Age: 0000
10-Max Age: 1400
11-Hello Time: 0200
12-Forward Delay: 0F00

Switch2:

Switch2#debug spanning-tree bpdu receive 
Spanning Tree BPDU Received debugging is on
Switch2#
*Jan 1 20:19:59.046: STP: VLAN0001 rx BPDU: config protocol = ieee, packet from Ethernet0/1 , linktype IEEE_SPANNING , enctype 2, encsize 17 
*Jan 1 20:19:59.046: STP: enc 01 80 C2 00 00 00 AA BB CC 00 03 31 00 26 42 42 03 
*Jan 1 20:19:59.046: STP: Data 00000000008001AABBCC000300000000008001AABBCC00030080080000140002000F00
*Jan 1 20:19:59.046: STP: VLAN0001 Et0/1:0000 00 00 00 8001AABBCC000300 00000000 8001AABBCC000300 8008 0000 1400 0200 0F00
*Jan 1 20:19:59.046: STP(1) port Et0/1 supersedes 0
Switch2#u all
All possible debugging has been turned off
Switch2#

We found here that Switch2 receive one Superior configuration BPDU on the port Eth0/1 from Switch1 and it is similar to the previous debug O/P so no need to discuss it again.

Regarding the different modes and protocols for spanning tree, i will mention them in the next post.

 

Hope that the post is helpful.

Regards

Mostafa Hamza

11 thoughts on “1-R&S/Virtual LAN (VLAN) and Spanning Tree Protocol (STP).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s