Written by ouilookup
Updated on 2020-04-14
If you have been working as a network administrator for quite some time, you probably already know about switches.
Switches are essential blocks of any network environment.
When they associated with computers, they are responsible for receiving and transmitting traffic over a network.
However, do you really know how computers communicate?
What tools do they use when you are dealing with a private local network?
Is it different when you are communicating over a larger network, or Internet?
In this tutorial, you are going to discover everything that there is to know about computer communication.
By the end of this tutorial, you will be able to clearly identify how computers are communicating and which tools they are using in order to achieve it.
Before jumping into the explanation, there is an important concept that you need to grasp : the OSI model.
The OSI model is made of seven layers :
In this list, we are going to focus on the second point because it is the one that relates to MAC addresses.
In most cases, communication is done via Ethernet.
Ethernet, in simple words, is a protocol that defines a way for devices to communicate with each other.
It defines the way frames are formatted, how large they should be, where data should be stored and so on, the destination as well as the source of the message.
The destination and source are represented by the destination MAC address and the source MAC address of both devices.
But, what is a MAC address?
A MAC Address is an unique identifier given to your network adapter when it was built by a given NIC vendor.
MAC addresses are represented by 12 hexadecimal characters, six groups of two, separated by colons or dashes (98-E7-43-78-65-74 or 9C-7B-EF-45-F5-45 for example).
If your device is communicating over Internet, you can be pretty sure that it has a network interface card equipped with a MAC address (computers, gaming consoles, mobile phones..)
However, a MAC address on its own is not enough for your computer to send a message over a network.
Remember the OSI model we saw in the previous chapter?
When sending a message over the network, your message will be encapsulated with information from the presentation layer to the data-link layer.
In other words, it will be assigned TCP (or UDP) headers, IP headers as well as Ethernet headers before going onto the wire.
If you just plugged your computer to the network, there is a chance that your computer does not know anything about other computers on the network.
It is important to say that if your computer already communicated over the network, it has a cache that it is going to use to format packets correctly.
Instead of having to connect every single computer to each other on a network, we use a device that binds the computers together : the switch.
For now, let’s assume that we don’t have any router, as we simply want to send messages over a simple local subnet.
Use the following schema as a starting point : you have three computers on the network linked via a simple switch.
Computer A wants to send a message to computer B, how can it achieve that?
In order to understand how computer A can send a message to computer B, you need to understand the ARP protocol.
ARP is a protocol used by computers in order to discover MAC addresses associated with IP addresses over a network.
In short, when computer A decides to send a message to computer B, it does it using the IP address of computer B (184.108.40.206/24 in our case).
But if you remember the OSI model we saw just before, you realized that the message needs to have Ethernet headers.
That is to say that the message needs to have a source MAC address and a destination MAC address.
However, computer A has no idea of the MAC address of computer B.
In order to learn about it, it is going to use the ARP protocol.
Computer A will send an ARP discover frame to the switch stating that it needs to learn about the MAC address of computer B.
From there, your switch will broadcast the frame to all computers connected to the switch. As a consequence, every computer on the local network will receive the ARP discover frame.
When receiving the message, if the IP address matches, the corresponding computer will send a message back stating that it is matching.
If it doesn’t match, the NIC of the corresponding computer will drop the message.
From there, the switch also learns about the MAC address and forwards the message back to the initiating computer.
Awesome, your computer now knows that the computer 220.127.116.11/24 has the 00-60-70-14-45-10.
Now, your computer is able to properly format the message, the missing Ethernet header can now be completed!
As a consequence, the message is sent over the network and both computers can now happily communicate without any trouble.
Now, you may be wondering : if I want to communicate with another computer located in another network, very far away from me, do I need to know about every single MAC address on Earth?
In the previous chapter, we saw that communication can easily be achieved on a local subnet using the ARP protocol.
However, in most cases, you want to be able to communicate over Internet.
To answer the previous question, you don’t have to have every single MAC address stored on your computer, ARP is a protocol for local Ethernet resolution.
To complexify things a little bit, let’s add a router to our previous network and state that computer A now wants to communicate with computer D.
To understand communication over Internet, you need to understand the decision made by your computer to send a computer over the network.
When sending a message, your computer goes into the following decision making process :
If this is the case, we use the algorithm seen in the previous chapter (using ARP).
If this is not the case, the message is simply forwarded to your local router in order to be routed over Internet.
Note that your computer needs to know about the MAC address of your router in any case, using the ARP protocol described in the previous section.
The key here is to understand that the destination IP will be the one of the computer D but the MAC address is the one of the local gateway.
In our example, the destination IP is not on the same subnet, so the message will be forwarded to the default gateway (aka our local router).
From there, the message is routed through hundreds of different routers to your destination and the response (if any) is sent back to you by the destination computer.
Awesome, you now know how message are sent over a network and how they can reach a local or a distant destination!
In this tutorial, you learnt how computers can easily communicate over a network.
If you are dealing with a local subnet, you now know that the ARP protocol is used and that your message is broadcasted to everyone in order to learn the destination MAC address.
If you want to send your message over Internet, you often send your message to your local gateway (using the destination IP but the MAC of your router!).
From there, complex routing algorithms are used in order to reach the destination computer.
If you found this article useful, make sure to share it on social networks and to give credits to our authors.
Icons used in this article were designed by Freepik & Smashicons from Flaticon.