How Switch works

 How switch works

Every network card has unique identifier called a Media Access Control (MAC) address. and the MAC address is used in LANs for transmission between devices on the same network segment. Devices that want to commune need to know each other MAC addresses before sending out frames.

Switches use MAC addresses table to make accurate forwarding or filtering decision. And when a switch receive a frame, it associate the MAC address of the sending device with the port on which it was receive. The table that stores such information is called a MAC address table.  MAC table is stored in the volatile memory, so information are erase after the switch is rebooted.

Switch usually perform below three functions in a LAN:

  • Address learning – Switches learn MAC by inspect the source MAC address of each received frames.
  • Forward/filter decisions – Switches decide that that to forward or filter a frame, based on the destination MAC..
  • Loop avoidance – Switch uses Spanning Tree Protocol (STP) to prevent network loops while still allowing redundancy.

How a switch works

Let us say that the host A wants to commune with host B for the first time. Host A only knows the IP address of host B, but since this is the first time when the two hosts communicating, the MAC addresses are not known. Host A use the ARP process to find the MAC address of host B. The switch forward the ARP request to all ports except the port the host A is connected to. And Host B receive the ARP request and respond with its MAC address. Host B also learns the MAC address of host A ( host A sent its MAC address in ARP request). Host C receives the ARP request, but does not reply since the IP address listed in the request is not its own.

As above mentioned, a switch learn which MAC address are associated with which port by inspect the source MAC address of each received frames. And host B replied with the ARP reply that included its MAC address, the switch know the MAC address of host B and stores that its MAC address table. And For the host A, the switch knows its MAC because of the ARP request that included it.

Now, when the host A sends a packet to the host B, the switch look up in its MAC table and forward the frame only out Fa0/2 port – the port on which host B is connect to. Other hosts on the network will not be involved in communication:

How switch forwards unicast frames

NOTE
By default, MAC address stay in the switch MAC address table for 5 minute. So if host A and host B decide to commune inside the next 5 minute, a new ARP process will not be required.

 

Switch#show mac-address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0003.e489.513e    DYNAMIC     Fa0/2
   1    00e0.8f13.6970    DYNAMIC     Fa0/1

The output is self-explanatory: all ports belongs to VLAN 1 and MAC address associated with specific ports. DYNAMIC means that the address were learn dynamically by using the source MAC addresses of the received frame.


Post a Comment

0 Comments