What is a switch? A Beginner’s Guide to Networking
A switch is a network device that routes data packets between devices in a network and generally optimizes data transmission in local area networks (LANs). Switches connect network segments or devices together, allowing multiple devices to transmit data at the same time. This increases efficiency, especially in large networks, and minimizes the possibility of collisions.
Switches examine incoming data packets and decide which device each packet should go to. It does this according to the MAC (Media Access Control) addresses of the devices. When a data frame reaches the switch, the switch looks at the source and destination MAC addresses and routes the frame through the correct port. Compared to hubs, switches only send data to the necessary ports, which increases network performance.
Figure 1: Switch Symbol
How Switches Work:
Initially, switches used static switching tables. The system administrator had to manually add the MAC address of each device and the port it was connected to to the table. This process is quite laborious and error-prone, so modern switches operate dynamically today. Dynamic tables allow the switch to automatically learn the devices on the network. Switches analyze each data frame on the network and add the source MAC addresses to their tables. In this way, in the future, the MAC address of the device and the port it is connected to will be ready to send data to the relevant device.
Figure 2: Simple switch network structure
Dynamic MAC Address Learning:
Switches learn MAC addresses dynamically. This process works as follows:
- When PC2 sends a frame to PC1, the switch does not have any information about PC2 or PC1. The frame is sent out of all three ports. By looking at the source address, the switch learns that PC2 is connected to port 1. This means that future frames destined for PC2 should be sent out of port 1. The switch adds the MAC address information for PC2 to its table for this port. The first entry in the table is made.
Figure 3: Empty Switch Table
Figure 4: PC1's MAC information is entered into the table
- When PC1 sends a frame to Laptop0, the switch does not have any information about this computer (information already entered into the table). Therefore, it scans the network again. In the meantime, it adds the MAC information of PC1 to the table.
Figure 5: PC0's MAC information is also added to the switch table
- The learning process continues until the table has information about each port. However, it should be noted that the learning process can take a long time. For example, if a computer does not send a communication request or data, the computer’s information is never added to the table.
Figure 6: Processing the MAC information of all computers connected to the switch ports into the table