The Secret Handshake: Basic Rules for Data Transfer Between Network Devices

The Secret Handshake: Basic Rules for Data Transfer Between Network Devices

Here, we will try to understand how network connections occur between two servers or network devices, and the basic rules for making the connection happen.

The Rules

The most important thing for any device or server is communication. Here, communication basically means transferring data. Data is the core element that flows across networks, and its direction determines whether it's a request or a response.

Suppose you want to browse google.com from your device. You request or search e.g., cute cat pictures. This requested data goes to google.com, and it gives you a response with cute cat pictures.

If you want to transfer data between any two network devices there are few basic rules to be followed. Suppose there are two network devices, A and B. We will check if these devices follow these network rules. After we verify this, we can transfer any kind of data between these devices.

  1. IP address - Both the devices should have a unique IP address. It ensures that data is sent to the right device without any confusion, allowing for smooth communication between devices.

  2. Connectivity - Wired Connectivity /Wireless Connectivity. Connectivity is a medium through which this data will transfer. The strength and reliability of this connectivity will determine how efficiently the data can be transferred, ensuring seamless communication between devices and systems.

  3. Same network - Two devices are considered to be on the same network if they can communicate with each other directly or by using shared network resources. In a typical home or office setting, devices connected to the same Wi-Fi network are considered to be on the same network as they can easily share files, printers, or internet access.


Practical Checking

Practically, we will check if the devices are on the same network by setting up two servers in AWS, named TestServer and TestServer2.

Setting up the Server

Checkout how to set up a server on AWS.

With this we are up with two servers - we will try to check the connectivity between these two servers applying above rules.

Obtaining IP address and netmask

From the terminal, we can check the IP address and netmask by using the ipconfig command.

ipconfig - Display IP addresses of all network interfaces.

Check few other networking commands

TestServer IP address (inet)= 172.31.41.100 and netmask = 255.255.240.0

TestServer2 IP address(inet) = 172.31.35.238 and netmask = 255.255.240.0


Checking if two devices are on the same network

TestServer IP address = 172.31.41.100 and netmask = 255.255.240.0

TestServer2 IP address = 172.31.35.238 and netmask = 255.255.240.0

Here, we see this term netmask, it basically tells us if these two servers are on the same network or not. Here's how-

Mathematically, if we want to check whether two network devices are on the same network, using the example of the two servers above, we have the IP Address and Netmask for both servers.

First of all, we have to change these decimal IP and netmask notations to binary. Then, for TestServer, perform an AND operation between the IP and netmask and say you get the output X. Similarly, obtain output Y for TestServer2.

If output X = Y , then these two servers are in same network.

Network devices perform these calculations behind the scenes, but we are smart and know a better approach: we can avoid these calculations by observing carefully.

Visually, we can see the IP address and netmask of both servers. These are sets of 32-bit decimal numbers divided into four sections called octets. Each octet is 8 bits, separated by dots, making a total of 4 octets = 32 bits. In each octet, there is a decimal number ranging from 0 to 255.

SERVERIP ADDRESSNETMASK
TestServer172.31.41.100255.255.240.0
TestServer2172.31.35.238255.255.240.0

Simply compare the netmask first. We can see that in TestServer, the first 2 octets are filled with the maximum value, i.e., 255. The same applies to TestServer2.

Here, in this case, the netmask is filled up to the maximum for the first 2 octets. So, we will also compare the first 2 octets of the IP addresses for both servers to check if they are the same. In this case, they are the same: 172.31.

Hence, these two servers are in same network.

Also, the first 2 octets here represent the network portion and rest as host portion.


Testing the connectivity

Above, we have discussed some rules. According to these rules, we have checked that these servers have unique IP addresses, they are in the same network, and since they are launched through AWS, connectivity is also sorted.

Time to test:

From TestServer, we are trying to check the connectivity to TestServer2. For this, we use the ping command. It provides statistics about the network packets or data that is being transferred.

Here in this case above we tried to ping TestServer2 but it says 0 data received

Why it say so if all the conditions are matching-

In AWS, whenever we launch an instance or server, it adds an extra firewall that does not allow ping. So, in this case, AWS is providing network security, and we can define a set of rules that determine which incoming traffic is allowed to reach your computer or network devices.

In AWS, this is managed by security groups. So, in the security group of TestServer2, we will add a rule to enable the specific protocol that the ping command uses, i.e., the ICMP protocol.

So, in AWS inbound rules, we will add and save this rule mentioned above.

Let's Try again:

Now, in above output it can be seen in the ping statistics, the data packets are being received, verifying that there is connectivity between these two servers.

MORE ON NETWORKING

Check out more on networking in this series - The Network Navigator.