RECAP
In the last article, we discussed how two applications running on different computers on the internet communicate through IP addresses and Ports, and how the OS’s socket handles the hidden details of the communication network. In this chapter, we can go deeper into IPs.
** Let's Start**
When we ask an internet service provider for internet, we can get the router/modem connected to the external cable. After the setup, we can connect all the devices in our home and use the internet. But there is a logical system behind this magic. I will discuss it here.
For computers, everything is binary: 1s and 0s. If we want to build a system for computers that identifies each other, we have to name each computer like places, people, etc. We cannot name them in the alphabet or with numbers like 1,2,3…, we have to name them in binary numbers.
If we have a bit, it has only two options: 0 or 1. So we can name one computer 0 and another one 1. If we have 2 bits, we have 4 combinations.
0 0
0 1
1 0
1 1
If we have n bits, we have ( 2n ) combinations, which can label 2n computers. In the IPv4 standard, we have 4 decimal numbers separated by dots; each number is 8 bits.
If we calculate the total number of devices that can be labelled by IPV4 is 4,294,967,296 (2³²). It is sufficient in the initial days, but as the number of devices that connect to the internet grows exponentially, we need to introduce a new method to connect a large number of devices.
Subnetting is dividing a larger network into many smaller networks, and NAT is one of the solutions. We go back to the ISP: if we request an internet connection for home, very rarely ISP give a direct IP.
WAN ( wide area network ) is the network that connects globally, but we have limitations here as discussed above. The ISP gets WAN public IPs, creates its own small network LAN ( local area network ) which covers our home along with the neighbourhood.
The ISP edge router ( WAN IP ) is the gateway to communicate with the external world. From the ISP edge router, they create a subnet for various routers, which includes our home. The router which is in our home creates its own network to manage all the devices that we connect. With this concept, we can connect many devices from a single WAN IP.
Our router in the home gets an IP from the ISP edge router. As we discussed above, the router in home which gives IP to each device we connect to it.
In our above example, we can see a local network that connects many hosts ( devices).
CIDR NOTATION ( classless inter-domain routing)
It's a modern way of representing IP. It purposefully avoids older class conventions of IP to avoid confusion, and it is no longer used.
EXAMPLE : 198.162.30.3 / 24
Here we have 32 bits IP; in this IP, 24 bits are dedicated to the network’s identification. We can observe that the first 3 parts were the same for all hosts, and the network ID of the network was 198.162.30.0.
If we identified the network 198.162.30.0, we need to find the exact host next; here, the remaining 32 - 24 = 8 bits after the network ID is host ID, which points to the exact host in the network. So the host ID is 3
DEFAULT GATEWAY
The router is generally a gateway, which connects this host to external devices. Other hosts communicate to this router; the router communicates outside of the network on behalf of the other devices. It is common to dedicate the first IP of the network to the router: 198.162.30.1
Number of networks vs. size of networks
There are only 32 bits in IPV4; if we dedicate more bits, we can create more labels. In our example, we dedicate 24 bits to the network ID ( label networks ). We can have 2 power 24 is 16,777,216 networks, but only 2 power 8, which is 256 devices, can be connected to each network.
Similarly, if we create a network, network ID = 198.0.0.0 and
host IP = 198.162.30.3 / 8
We have only 256 networks, but for each network we can connect 16,777,216 devices.
In the above paragraph, I mentioned the number of devices that can be connected to a network, but there are some special IDS which is reserved: the network ID and Broadcast ID. Broadcast ID will be discussed in future articles.
The number of networks is inversely proportional to the size of each network.
Let's discuss IPV6 to overcome the limitation of the 4 billion cap in IPV4. There are 8 groups of 16-bit numbers separated by “: “, and it is represented by hexadecimal numbers ( 0, 1, 2,.. 9, A, B, C, D, E, F).
Example
In CIDR Notation
2001:0db8:85a3:0000:0000:0000:0000:0015/64
Here in IPv6, the bits dedicated to representing the network ID are termed as Network prefix ( 2001:0db8:85a3:0000 ), and the host ID is termed as Interface ID ( 0000:0000:0000:0015 ).
Going to explain networking from a common point of view; follow me if you want to stay up to date with my content. And also feel free to discuss concepts in comments, let we interact



Top comments (0)