In this article, we will discuss What is switch in networking? How does it work? What are the advantages of switch? and the difference between Hub and Switch. So let’s discuss.
Table of Contents
Switch in Networking
Switch is a network device that has multiple ports that are used to connect devices and create a network.
It works on a layer 2 (data-link layer) of the OSI model and has multiple ports, whichever PC connects to the in ports connects that computer to the network.
A switch can actually learn the physical addresses of the devices, that are connected to it and it stores these physical addresses (called MAC address) in its table.
It is an intelligent device because it has a memory where it maintains the table called CAM table (Content Accessible Memory), and stores the port number and MAC addresses of all devices, which helps to identify every device on a network.
Why switch is a layer-2 device?
Switch is called a Layer-2 device because it forward frames based on MAC addresses. It has storage capability, where a table is maintained. That’s table helps to identify every device connected to switch on the basis of MAC addresses.
A switch can actually learn the physical addresses of the devices, that are connected to it and it stores these physical addresses (called MAC address) in its table.
For Example:
Let’s there are 4 PCs (pc1, pc2, pc3, pc4). When pc1 transmits data to pc2, data first arrives in switch device, where the switch knows which device is connected to which port, the switch looks at its table of MAC addresses and matching ports, and transmit the data to the correct port so the data packet would only go to that computer.
Also Read: What is Hub in Networking? and How it Works?
How Switch Work?
It works on star topology because all the devices are connected to the central node. Data from the source device is first arrived at the switch and then transferred to the destination device.
When first-time devices are connected to the switch, it broadcast the message, where it identifies the port number and MAC address and store it on its table, this information helps to identify the destination device on the network and sends it directly to that device.
So after the broadcast, the switch knows which device is connected to which port no, so next time it does not need to broadcast the message, it will forward the information with the help of port no and MAC addresses.
Advantages of Switch
- Multiple computers can connect using the switch and communicate with each other.
- It is an intelligent device because it can learn other device’s MAC address.
- It maintains a table, helps to identify every computer on a network.
- Switch is able to works on full-duplex mode means each computer is able to send and receive data at the same time.
- There is no or very less frame collision because every port of the switch has a separate collision domain.
- It increases the performance of the network.
Also Read: What is Hub in Networking? and How it Works?
Difference Between Hub and Switch | Hub Vs Switch
Hub | Switch |
---|---|
It is used to create a network. | It is used to create a network. |
It always broadcast the data to every device. | First time it broadcast to identify every device on a network, then unicast the data. |
Hub is not an intelligent device. | Switch is an intelligent device. |
It works on layer-1 (physical layer) of the OSI model. | It works on layer-2 (data-link layer) of the OSI model. |
It does not have any memory to store devices information | It has the capability to store devices information. |
It does not maintain any kind of table. | It maintain a table where all device information is stored. |
It cannot store MAC address. | It can store all device's MAC addresses and port numbers. |
It operates on half-duplex mode. | It operates on full-duplex mode. |
It has single collision domain. | Every port has separate collision domain. |
Only one device communicate at a time. | Two or more devices can communicate at a time. |