IP Address Explained

HacksLand | The computer science playground

Posted by Thilan Dissanayaka on Aug 12, 2019
In this tutorial I'm going to cover an important topic in networking. Yes it's internet protocol. Internet and every other networks are built on some rules. We cal them network protocols. When developing a network what do you expect? The primary goal is to communicate with other devices those 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?. Think about following example. LAN There are 6 computers and all of these are in a one small network. Now computer A wants send some data to computer B . So sender want to include the name of receiver in data if not this data packet cannot be delivered to destination. Now when receiver getting the data he also want to know from where he receiving this data. So the name of sender also included in data packet. Now there are couple of things to notice. First the name of computer must be unique. If there are hundred PCs there should be hundred names. Second thing is this name should be short and easily presentable. 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 more longer size of that also go 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 as IP address. If we get this long story shortly there is a unique number for every device that connected to a network. At this time 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 a IP address. That means 4 bytes. Actually a IP address looks like this.
There are 4 parts . Above address is In binary format. For easy reading we use IP address in decimal .like this one. . When we think about a one byte (8bits) it can contain 256 different values. So it contains 0 to 255. (00000000 to 11111111). In IPV6 we use 128 bits (16 bytes). A IPV6 address will look like following.
. I hope you got a clear idea about this concept. Now move onto next topics. When we think about a LAN above concept is OK and can be full satisfied. But think about internet. You know that a LAN is a network of small number of computers those located in a local aria. But in Internet there are many small networks. All of these networks contain lot of computers and other networked devices. connected Lans Now in above pic, computer A is in Network 1 and computer B is in Network 2. When computer A sending a massage to computer B , he need to know the name of receiver and the name of the network that receiver is located on.Because computer B is not in same network. This is the time things getting interested. As a solution to this problem we divide IP address to two parts. One is network ID. It contains the name of network. Second part is host id. That one contains the name of 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 a 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. devided IP 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 can be a network. devided IP2 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 a IP address class? To deliver a packet of data computer must know which part contains network ID and what is host ID. To do this task we use first 3 or 4 bits of a IP address. You know that a IP address is a 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, the it is a Class B address. Class C If the first two bits are 1 and the third bit is 0, the it is a Class C address. OK. That's all for this tutorial. In next post I'll explain subnets. Thank you for reading. Don't forget to put a comment and share it.  :-)

Hi, I'm Thilan. An engineering student from SriLanka. I love to code with Python, JavaScript PHP and C.

Also read

Sep 22
Cryptography basic terms

Hi guys, I thought to start a tutorial serious on cryptography. Because its an essential subject to....

Mar 23
Reverse TCP shell with Metasploit

Metasploit is an awesome tool. It can be used to automate the exploitation process , generate shell....

Aug 12
Variables | Python programming

You know that variable is a memory space ant it contains a value. When we talk in low level that's....