what is a network switch, how does the network switch work, mapping network switch ports with MAC address
WHAT IS A NETWORK SWITCH?
In this blog we will discuss what is a network switch and how does it works? Network
switch interconnects different devices using copper and fiber links. It
operates on physical and data link layers of the OSI model. It does not work on
network or transport or application layers. The PDU for the data link layer is
a frame and that means the switch operates with frames because it works on the physical
layer. It works with bits. A switch may have many ports. For example, 8 ports,
12 ports, 24 ports, 48 ports, or even hundreds of different ports. The switch could
combine different types of ports. Like ports for connections of copper cables or
fiber cables. Also, there are so-called end-user-facing ports. Those ports are
used for connections of end-user devices like desktops, computers, laptops, or
some servers. Also, every switch has several uplink ports that are used for
connections to other switches.
The
cumulative bandwidth of all uplink ports is not equal to the cumulative
bandwidth of all end-user-facing ports. The reason for that is not all ports
are utilized and not loaded by traffic that's why there is no need to create equal
size uplink ports. Uplink ports use fiber links and higher speed rates.
How does the network switch works?
Network
switches don't care about IP addresses TCP sessions and they don't care which data
is transmitted on the application layer of the OSI or TCP/API model. Their
single responsibility is to transfer frames between different devices as fast
as possible. That is a single goal of every network switch.
Here on this diagram, you see several computers that are connected to the same switch. Every computer has its own unique Media Access Control (MAC) address. The MAC address is a set of hexadecimal characters and each MAC address has six sections split using either column or dash. In this example, those three computers are connected to the same switch but two different ports, and the ports are shown in the table.
In this example, gigabit ports are used. Those ports are capable of transfer rates up to one gigabit per second and naming of those ports like Gi0/1, Gi0/2, and Gi0/3. Here zero is the number of the slot in the switch. Switches for home office use or small office use have a single slot and its id is zero like in this example and every slot has some set of ports and the numbers of ports start with one. In this example first port in this slot zero is one. If the switch has many slots then the names of those ports like 1/5 or 2/6 etc. In the MAC address table, MAC addresses are assigned to every specific port. What does it mean to assign a specific MAC address to a specific port?
Suppose
you install a new switch to take them out of the box or move them from another
data center and place them into your location and afterward several devices
like laptops or desktop computers or servers are connected to different ports
of this switch. The goal of the switch is to transfer frames between different devices.
Suppose the MAC address table is kept in the memory of the switch is empty at
the moment.
For example, computer A sends any frame with a destination MAC address equal to computer B MAC address. Computer A wants to communicate with computer B. In this case, the switch receives the frame and first, it adds the source MAC address to the MAC address table and to the port where this frame was received from. Then it looks for the destination MAC address in the same MAC address table. The moment MAC address is absent in the table correct in such case switches forwards such frame to all ports except that port where this frame was received from. That means that in this example this first frame will be sent both to computer B and computer C. Afterwards computer B and C will compare their MAC addresses with destination MAC address in this frame and if MAC addresses match in computer B. Then the computer will strip MAC address header and proceed to the upper layer of the TCP/ IP model to the network layer.
Computer C will discard such a frame
because the destination MAC address in such frame does not match with its own MAC
address. So computer B has received the first frame and let's suppose that it
wants to send some response to computer A. It also constructs some frames and
adds a transport-layer header, network layer header. Only afterward it adds a
data link header that contains the source and destination MAC addresses and
sends the frame back to computer A. So destination MAC address is A source MAC
address is B. Same as before the network switch takes a frame looks first at
source MAC address B and it sees that B MAC address is absent in MAC address
table. But this frame was received on port Gi0/2 and it's a good time to add
the MAC address of computer B to the MAC address table. Now there are two
records in the MAC address table.
Afterward,
the switch looks at destination MAC address A and looks again in the MAC
address table. It finds A MAC address in the MAC address table and it seems
that the device with such MAC address is located behind port Gi0/1. Now switch
forwards this frame only to Gi0/1. It does not send the frame to computer C or
other computers located behind other ports because. Now it knows where the destination
MAC address is located. So that's how the second frame was sent from computer B
to A.
Let's
say that computer C also wants to send some data either to computer A or B. It
sends some frames to the B MAC address and again switches looks into the MAC address
table. It seems that the source MAC address is absent behind the port Gi0/3 and
it adds the C MAC address to the MAC address table. Also, it looks next at the destination
MAC address in such a frame. It finds that such MAC address is located behind
port Gi0/2 and forwards such frame directly from port to computer B. The MAC
address table is complete for this example and the switch will forward frames
only between pair of ports. So it receives some frame for example at port Gi0/2
looks at destination MAC address in the frame and forwards such frame to a specific
port either to computer A or to computer B. That’s how the network switch
operates.
Conclusion
Network
switches work only with MAC addresses. And it does not change the frame header
or network layer header or some other headers. It processes every frame and
looks only at the header of the frame. Also, it verifies frame check sequence
and if it is incorrect switch can discard frames.
COMMENTS