IP Addressing & Subnets
In this document, we're going to talk about an important topic in networking. It's internet protocol. Internet and every other network are built on some rules. We call them network protocols. When developing a network what we expect? The primary goal is to communicate with other devices that are connected to the network. So there should be a way to identify each device. If not, how we can send data to a device?. Let me take the following example.
There are some computers in one small network. Now Computer_A wants to send some data to Computer_B. So the sender wants to include the name of the receiver in the data if not this data packet cannot be delivered to the destination. Now when the end device receives the data it also wants to know from where this data is receiving. So the name of the sender should also be included in the data packet.
Now there are a couple of things to notice. First, the name of all devices connected to the network must be unique. If there are a hundred devices, there should be a hundred names. The second thing is this name should be short, simple, and easily usable.
Take the words Computer_A and Computer_B. Both of them are long 10 characters. That means we should allocate 10 bytes (80 bits) for that. If the name is the longer size of that also goes higher. So different names get different lengths and sizes. That is not nice. The solution to this problem is a number with a fixed length. We call this number an IP address.
If we get this long story short there is a unique number for every device that connected to a network. We call it an IP address. At the moment, there are two IP address schemes. IPV4 and IPV6. The most used version is IPV4. So we are going to talk more about IPV4. In IPV4 we use 32 bits for an IP address. That means 4 bytes. Actually, an IP address looks like this.
But for the easy presentation, we divide it into four parts. Actually, this is how we keep remembering or telling a phone number.
There are 4 parts as the first octet, the second octet, and so on. The above address is In binary format. From our early ages, we have dealt with the decimal number system. Not binary. So it's easy to use an IP address in decimal like the following.
When we think about one byte (8 bits) it can contain 256 different values. So it contains 0 to 255. (00000000 to 11111111). In IPV6 we use 128 bits (16 bytes). An IPV6 address will look like the following.
I hope you got a clear idea about this concept. Now, let us move into the next topics. When we think about a LAN such as in the above image we know all devices that are connected to the network. So we can manually assign an IP address to each device. (Actually, In the above example, I have put a switch as the central device. It can't assign IP addresses. For the moment assume we are assigning IP addresses manually) . So if there are a hundred devices we can give hundred IP addresses. No problem.
But think about the following network. There are three small networks. All of these networks contain a number of computers and those networks are connected through routers.
Let's name the network which connected to the Router_1 as Network_1 And the network connected to the Router_2 as Network_2, and so on.
So how we assign IP addresses to these devices. Let's assume the network_A has 100 computers and network_B has 200 computers. So we need to give 100 IP s for the network_A and 200 IP s for the network_B. But how we can ensure this number of devices will remain the same. There may be some cases we add new devices to a network. So we can't give a fixed number of IP addresses.
What we can do is give an IP address range for a network.
Now in the above figure, computer_A is in Network 1 and computer B is in Network 2. When computer A sending a message to computer B, he needs to know the name of the receiver and the name of the network that the receiver is located on. Because computer B is not in the same network. This is the time things getting interested. As a solution to this problem, we divide IP addresses into two parts. One is network ID. It contains the name of the network. The second part is host id. That one contains the name of the device. Let's take an example.
In mathematics, there is a concept called permutations and combinations. By using that(specially permutations) we can calculate how many different numbers can be made with a given set of numbers. So when we think about one byte there are 256 different numbers. In a combined two bytes we can put 65,534 different numbers. If we allocate two bytes for network ID and another two bytes for host ID we can divide it like this. If you give one byte for network ID and three bytes for host ID the number of networks is limited and there are more hosts that can be a network. So there are some IP address classes and they use their own ways to divide network ID and host ID. So how we can identify an IP address class? To deliver a packet of data computer must know which part contains network ID and what is the host ID. To do this task we use the first 3 or 4 bits of an IP address. You know that an IP address is something like this. Class A If the first bit is 0, the address is a Class A address. Class B If the first bit is 1 and the second bit is 0, then it is a Class B address. Class C If the first two bits are 1 and the third bit is 0, then it is a Class C address. OK. That's all for this tutorial. In the next post, I'll explain subnets. Thank you for reading. Don't forget to put a comment and share it.