How do computers talk to each other?
It’s not magic. Before I studied computers and networking, I wanted to believe it was magic because I thought any other explanation would be too difficult and complicated to wrap my head around. The reality is, it can be very easy to understand.
Let me start by saying this is an explanation of IP addresses within a LAN (Local Area Network.) An example of a local network is a few computers connected in the same building. This does not include the WAN (Wide Area Network) that the Internet is. IP addresses do exist in a WAN environment, but you can operate a LAN network without connecting it to the Internet and just share or print files within the network.
In this example, let’s say we have 2 computers and they are both connected to the same router. The router acts as a central location for all the computers to connect to and is the gateway to communicate with the other computers (also the gateway for the Internet if needed.)
In order to communicate within the network, each device (including the
router) needs to have its own IP address. An IP address acts just like the address on the front of an envelope when you mail something through the postal service. It identifies who the recipient is.
An IP address has 4 octets. An octet is one part of the IP address and each part is separated by a period. The router in this example has an IP address of 192.168.1.1 and everything else in its network will start the same, only changing the last octet. Each octet has a value that ranges from 0-255. When a computer is connected into the router, it will send a message to the router with its MAC address (a MAC address is a unique address assigned to every network device by the manufacturer.) It’s introducing itself to the router. Then, the router responds by assigning it an IP address to use so it can communicate with it easily and the other computers won’t have to memorize its MAC address. Then the next computer connects, and it is given an IP address also. Now the computers can communicate with each other through the router.
If Computer B wants to connect and send a file to Computer A, this is what the conversation would look like:
Computer B: “Hi. My name is [MAC address]. Can I join this network?”
Router: “Yes, and here is an IP address for you. You are now known on this network as 192.168.1.3.”
Computer B: “What is Computer A’s IP address?”
Computer B: “Please send this file to 192.168.1.2”
Router: “192.168.1.2, here is a file for you from 192.168.1.3!”
Now Computer A has a file from Computer B. This concept is also similar to how computers communicate on the Internet, and also how a computer communicates with a printer connected on the same network.
Now you can’t say it’s just magic anymore.