Monday, March 17, 2008

SWITCHING


Ethernet switch operate at layer 2 of OSI reference model and having similar function to that of Ethernet bridges. An Ethernet switch learns the MAC address of the devices attached to its ports and store in a MAC database. When the Ethernet switch receive packet they concern to the MAC database for the right port to deliver. When a switch network includes loop for redundancy, an Ethernet switch prevent the duplicate frame from traveling over the redundant path if Spanning Tree Protocol (STP) is configured.

STP is used to up and down the switch or to avoid the switching loop or layer 2 loops or we can say that the ultimate goal is to block the port. The network composes of different segments. There are four states of spanning tree protocol, Blocking (10 Sec), Listening (10 Sec), Learning (15 Sec), and Forwarding (15 Sec). The port when shutdown is in blocking state, Listening states after blocking state include hearing to check for Bridge Protocol Data Unit (BPDU), this states indicate listening to all frames. When a port is in Learning sates it settle MAC address with the MAC address it hears on its ports. While in forwarding state the port is able to forward and receive the packets. The total time a port take to convert from Blocking state to Forwarding state is 50 minutes. The time it takes to convert from listening to learning or from learning to forwarding state is called Forward Delay. Assume we have two switches X and Y and X was elected as a Root Bridge, now lets say the switch X fails, switch Y will detect the missing BPDU from the Root Bridge. One of the spanning tree timers is called MAXAGE timer. When MAXAGE timer expire and a new BPDU has not been received from the neighbor, a spanning recalculation is calculated and after the network is converged (Convergence in the spanning tree protocol means a state where all the switches or bridges ports have transitioned to either blocking or forwarding state.), the switch Y becomes the root bridge and is then forwarding the traffic between the two segments.

Example: Refer to Fig no: 1, we have two segments and two switches are attached namely SW1 and SW2 through HUB. Suppose Computer A wants to send data to Computer B, so there is only one port on switch to enter the data and one port to leave the data similarly on SW2 one port for receiving and one port for forwarding as both of them are attached through HUB so it will always broadcast the data in circular from and a circular loop will be created and that is called switching loop. If we want to break the loop we have to switch off any one port of the switch using STP.

There are certain Conditions of STP which we have to follow while configuring the STP, i.e. One Root Bridge / Network, One Designated Port / Segment, and One Root Port / Non Root Bridge.

The selection of the Root Bridge, Non-Root Bridge, Designated Port, Root Port and Non-Designated Port are done on the basis of specific rules. Collectively Designated and Root port are called Forwarding Port and Non-Designated port is called Blocking port. The selection is done on Election keeping in view the Priority Number and Mac Address collectively called Bridge ID. Root Bridge is the most powerful unit in the network and will be only one in the whole network and the remaining ports will be Non-root Bridge. The one will be the Root Bridge having lowest priority number and this is the case in selection of designated port also, if two points have the same priority number then the election will be based on MAC address the one will be elected having lowest MAC address (48-bits). Let’s take an example and apply all the conditions.

Example: Refer to Fig No: 2, we have two segments namely 1 and 2. The S1 is attached to segment 1 and a computer is attached to it while the other S2 to S6 are attached to both segments and another computer is attached to segment 2. Now the selection for the root bridges and others are done as under:

Step # 1: When election is done for the Root Bridge (RB), so S1 is elected as a Root Bridge as it has the lowest priority number that is one while the remaining all points are termed as Non-root bridges (NRB).

Step # 2: Now election for the designated port on both the segments:

a) On segment 1 the S1 has the lowest priority number so it is declared Designated port (DP).
b) On segment 2 the S2 has the lowest priority number among all so it is declared designated port.

Step # 3: Now election for the Root Port (RP), those ports will be consider as a root port which have a direct path to the root bridge as in the given figure the upper ports will be called as a root port. Now there will be one Root Port per Non-root Bridge. If the S1 one port is Root Port and other is Designated Port then the second port of all other switches are termed as Non-Designated Port (NDP). So data will be forwarding from computer 1 attached to segment 1 to computer 2 attached to segment 2 through the following way:

Machine A----------S1--------------S2-----------------Machine B

Where S1 and S2 are declared Root Port and Designated Port while the second port of the remaining switches are declare Non-root bridges and will be turned off so there will be no switching loop while data is receiving and forwarding.

As I have discussed above if S1 fails then convergence process is take place and re-election is made and another switch having lowest priority number will be elected as a new root bridge and data then will be forwarding through that root.