Let’s start from the beginning, what Is an IP Address?

So, an IP address is that number that uniquely identifies a device on a network; it is the social security number of the device on the network. The address is always a set of four numbers separated by a dot (.) and each ranging from 0 to maximum of 255, in any combination you want. So, it will look something like this from 0.0.0.0 to a maximum range of 255.255.255.255. Each number before the dot (.) is called an octet and this means we have 4 octets. An octet is made up of eight (8) digits, individually called bit and collectively called byte. Meaning, in an octet, the number of zero would be 00000000 (8 zeros) and each zero is a bit, while the 8 zeros together will be called a byte. So, since octet is 8 bits, then 4 octets will be 8 zeros in 4 places. So, in other words, we should have something like “00000000.00000000.00000000.00000000” representing an IP. So, now represent the 00000000 with alphabets, we should have A.B.C.D (instead of the zeros, simplified right!). if we count the zeros, we will have 32 digits or if we multiply each octet by 4 octets, we will still have 32, that’s why ip addresses are called a 32-bit number. Also, worthy of note is that these 8-digit octet numbers are binary numbers and binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: typically “0” (zero) and “1” (one).

So, representing (A) above, which is the first octet, we will have;

  • a=an octets made up of 8 digits, starting from 0-7.
  • a= [0,1,2,3,4,5,6,7] this means,
  • a=[20, 21, 22, 23, 24, 25, 26, 27] The rule is that any number raised to the power of 0 equals to 1. So, 20 equals 1, hence, 1 on next line.
  • a= [1, 2, 2×2, 2x2x2, 2x2x2x2, 2x2x2x2x2, 2x2x2x2x2x2, 2x2x2x2x2x2x2]
  • a= [1+2+4+8+16+32+64+128 ] =255

 Therefore A=255. We will do the same thing for the remaining 3 octets B.C.D in order to get a complete ip address.

Summary for octets, an IP is made up of 4 octets and each octet range from 0-255 and the range is from (1,  2, 4, 8, 16, 32, 64, 128) and if we add the numbers, we will get 255.

Binary Explanation

Understanding the Binary conversion for IP addresses is very key to your understanding IP addressing in general. Computers communicate in zeros (0) and ones (1).  One =On while zero = off.  All IP addresses  (example: 192.168.1.10) are a combination of the decimal numbers and they ALL fall into the decimal numbers you see in the counting binary diagram, which represent an octet

Example: So, for an octet with 180; 

  • place a 1 in the binary column of 128 as shown above since its the highest in the decimal range and closest to 180,
  • Next, if you add 128+64 =192 which is above the 180, so we cannot use 64, so, place a zero above 64.
  • if you add 128+32, you get 160, meaning you need 20 to make the 180 and looking at the rest of the decimal numbers, you can add 16 and 4 together to get 20, so place a 1 above 32, 16 and 4 while you put a zero in the remaining spaces. 
  • so, we should have 10110100 -this is our binary representation of 180

The binary representation for 192.168.1.10 = 11000000.10101000.00000001.00001010.

 

 

 

 

 

 

 

The Two parts of an IP Address

A single IP address can contain information about the network and its sub-network and ultimately the host. 

An IP address like 192.168.1.10 as earlier explained is a combination of 4 octets and each octet is a byte and each byte is 8 bits. The octets of the IPv4 is further classified into two parts namely;

  • The network part also called the network ID and
  • the host part also called the Host ID.

Depending on the class of the Ip address, the network ID and the host ID can be different. The subnet mask helps to determine which part of the Ip address is the network ID and which is the Host ID.

 Network ID: The network ID is a part of the IP address starting from the left that identifies the specific network on which the device is located.

On a typical home network, where a device like your laptop has the IP address 192.168.1.10 with a subnet mask of 255.255.255.0, the first three octets 192.168.1 part of the address will be the network ID which will be the same for all devices that will be on that network; all devices starting with (192.168.1. from 0-255). It’s custom to fill in the missing part with a zero, so we might say that the network ID of the device is 192.168.1.0 but the ip address of that laptop is 192.168.1.10. This means, your laptop is using the (.10 within that range) of the address while others are using the remaining vacant numbers within the range. This also means, all the devices on that network of 192.168.1 (0-255) are on same subnet.

Host ID: The host ID is the part of the IP address not taken up by the network ID. It is the part of the IPv4 address that you can assign to each host. It identifies a specific device and in the TCP/IP world, devices are called “hosts” and on that network. 192.168.1.10 is a host on the 192.168.1.0 network.

IPv4 Address classifications

Class A, 127  ip address range 127 is not in the picture. This is because this is reserved for loopback testing. 127.0.0.0/8 range. This block should NOT appear ever on any network anywhere, as they are meant for just internal testing only.

Classful addressing

This is an IP address allocation method that allocates IP addresses according to five major classes as shown here. Each IP class is equipped with its own default subnet mask as shown and this binds that IP class to a prefixed number of Networks and prefixed number of Hosts per network. Classful IP addressing does not provide any flexibility of having less number of Hosts per Network or more Networks per IP Class, these are the traditional classes A, B, C,D,E.

Class A -Classful & Classless addressing

This is an IP address allocation method that is designed to replace  classful addressing to minimize the rapid exhaustion of IP addresses. CIDR or Classless Inter Domain Routing provides the flexibility of borrowing bits of Host part of the IP address and using them as Network in Network, called Subnet. By using subnetting, one single Class A IP address can be sub-divided into smaller sub-networks which provides better network management capabilities.

In Class A, only the first octet is used as Network identifier and rest of three octets are used to be assigned to Hosts (i.e. 16,777,214 Hosts per Network). This network is too large and will be difficult to maintain

CIDR Explanation for subnets

In order to to sub-divide the large Class A network into smaller networks, bits from Host part are borrowed and the subnet mask is changed accordingly to represent the new subnet. Remember, an IP is 4 octets =32bits, which means 8bits.8bits.8bits.8bits =32bits. So, a class A will be 8bits.

So, when we have a 9bit in Class A as shown in the diagram, it means we have borrowed 1 bit from the 2nd octet. Remember Binary explanation above that each octet is  128/64/32/16/8/4/2/1. Therefore, the 1 bit borrowed represent the number of subnets you can have (21=2), if we borrowed 4, it will be (24=16) and so on. So since we borrowed 1 bit from the octet, we will have 7 bits left in the 2nd octet, while the remaining 3rd and 4th octets will still have their 8 bits. if we add the 7+8+8, we will have 23 which is (223-2) 8388606 Hosts per Subnet.

In summary, See list of all possible combination of Class A subnets the borrowed bits represents the subnets, while the remainder represent the hosts on the subnet.  In subnetting, the first and last IP address of every subnet is used for Subnet ID and Subnet Broadcast IP address respectively and therefore cannot be assigned to hosts and that is why the diagram shows the last row having 30 instead of 32 Network Bits.

The formula for calculation is as follows; 

  • Subnets = (2n)      -(Number of borrowed bits)
  • Hosts= (2n-2)        -(Number of what is left from the borrowed bits)

Class B -Classful & Classless addressing

In Classful Networking, 14 bits are used by default as Network bits providing (214) 16384 Networks and (216-2) 65534 Hosts. To subnet class B, we do the same thing like we did for class A,  we borrow bits from Host bits of 3rd and 4th octets as shown below;

Class C -Classful & Classless addressing

Class C IP addresses are normally assigned to a small size network as it can only have 254 hosts in a network. Every step of subnetting like class A and B applies here too.