Tuesday, 3 January 2017

How Network Switch Works

Switch is a device which takes forwarding decision based on the MAC address and it works on data link layer. You might know what is MAC. MAC is 48 bit address assigned to each device which is given by NIC card. So switch takes help of MAC address to identify source and destination device. Now consider a basic switch network.
Fig. Switch Network
Consider you are about to start a new organisation. So you will need one network to provide internet connectivity to computers. Also you will need to connect all computers to server and printers. Switch is a device to provide such connectivity. Such network is called as LAN (Local Area Network).

Computers and other devices will be connected to a switch through cables with each device having universally unique MAC addresses. If computer A wants to communicate with computer C. Computer A will create data frame to be sent. In this frame, it will add its source MAC address and destination MAC address i.e. MAC of computer C. Computer A will forward this frame to a switch. Switch will forward this frame only on the port to which computer C is connected. For this switch maintain a table called forwarding table. Forwarding table have entries of ports and MAC of connected devices. To decide on which port to forward, a switch takes help of destination MAC address in the frame.

The number of devices can be connected to switch depends upon the number of ports on switch. The number of ports varies depending on the manufacturer. Mostly the number of ports is greater than 8.

Till this point, we saw this network as a private network i.e. the communication is within the organization. If device wants to connect to internet i.e. public network, then a technique called VPN or Tunnelling is used. We will see this technique in upcoming post.

The basic common example of switch network is WiFi network. We can consider WiFi router (Wireless Access Point) as a wireless switch. To understand the principle of communication, we have to understand the concept of public and private IP address. We will study a difference between public and private in upcoming post.