# IPv4 Classful Addressing

Internet protocol is a set of rules for the transfer of data/communication on the internet.IPv4 is the 4th version of the Internet Protocol.

The IPv4 uses **32-bit addresses** and has 4.3 billion addresses. It uses the dotted-decimal representation, for e.g: 192.168.0.2.

The IPv4 address format is: **8bit.8bit.8bit.8bit **(adds up to 32bit)

Now, there are two types of IPv4 addresses — ** Classful and Classless**.

We will see the ** classful addressing** method here.

# Classful Addressing:

Basically, there are 5 classes of addresses — A, B, C, D, E.

Let us now have a look at each of them one by one:

## Class A:-

In Class A, as you can see above, the 32-bit address, which is divided into four sections of 8 bits each, out of those, the **leading 8 bits** are used to represent the **network** and the **trailing 24 bits** are used to represent the network **host**.

For example: 125.16.32.64 is a class A address

Now, the 1st bit of a class A address is always zero.

Since 1 bit is fixed out of the 32 bits, there are 31 bits left to represent the address. So, in total, there can be 2³¹ addresses in class A and 2⁷ network ID.

The class A addresses constitute a total of 50% of the possible addresses.

And the range for the network address is 0 to 127 (How? → If we put all zeroes in the first octet i.e. 00000000 = 0 and if we consider the last address i.e. put all ones except for the 1st bit which is 0 by default, we get 01111111 = 127).

The first and the last address i.e 0.0.0.0 and 127.255.255.255 are never used since the former is the host address/identifier and the latter is the broadcast address.

Due to this, even though 128 network addresses are available, only 126 out of them can be used.

The default subnet mask for Class A is **255.0.0.0 **(i.e. to find the network ID, we just need to logically AND our address with this subnet mask…How interesting :-) ).

## Class B:-

In Class B, the **leading 16 bits** are used to represent the **network** and the **trailing 16 bits** are used to represent the network **host**.

For example: 136.192.168.64 is a class B address

Now, the 1st two bits in the first octet of a class B address are always 10.

Since 2 bits are fixed out of the 32 bits, there are 30 bits left to represent the address. So, in total, there can be 2³⁰ addresses in class B and 2¹⁴ network ID.

The class B addresses constitute a total of 25% of the possible addresses.

And the range for the network address is 128 to 191 (How? → If we put all zeroes except for the 1st 2 bits which are 10 by default, in the first octet, we get 10000000 = 128, and if we consider the last address i.e. put all ones we get 10111111 = 191).

The first and the last address i.e 128.0.0.0 and 191.255.255.255 are never used since the former is the host address/identifier and the latter is the broadcast address.

Due to this, even though 2¹⁴ network addresses are available, only 2¹⁴-2 out of them can be used.

The default subnet mask for class B is **255.255.0.0.**

## Class C:-

In Class C, the **leading 24 bits** are used to represent the **network** and the **trailing 8 bits** are used to represent the network **host**.

For example: 193.201.198.23 is a class C address

Now, the 1st three bits in the first octet of a class C address are always 110.

Since 3 bits are fixed out of the 32 bits, there are 29 bits left to represent the address. So, in total, there can be 2²⁹ addresses in class C and 2²¹ network ID.

The class C addresses constitute a total of 12.5% of the possible addresses.

And the range for the network address is 192 to 223 (How? → If we put all zeroes except for the 1st 3 bits which are 110 by default, in the first octet, we get 11000000 = 192, and if we consider the last address i.e. put all ones we get 11011111 = 223).

The first and the last address i.e 192.0.0.0 and 223.255.255.255 are never used .

Due to this, even though 2²⁹ network addresses are available, only 2²⁹-2 out of them can be used.

The default subnet mask for class C is **255.255.255.0.**

## Class D:-

In Class D, there are no hosts or networks.

For example: 225.108.162.1 is a class D address

Now, the 1st four bits in the first octet of a class D address are always 1110.

Since 4 bits are fixed out of the 32 bits, there are 28 bits left to represent the address. So, in total, there can be 2²⁸ addresses in class D.

The class D addresses constitute a total of 6.25% of the possible addresses.

And the range for the network address is 224 to 239 (How? → If we put all zeroes except for the 1st 4 bits which are 1110 by default, in the first octet, we get 111000000 = 224, and if we consider the last address i.e. put all ones we get 11101111 = 239).

These addresses are reserved for multicasting group email/broadcast.

## Class E:-

Class E addresses are very similar to class D addresses.

The 1st four bits in the first octet of a Class E address are always 1111.

Since 4 bits are fixed out of the 32 bits, there are 28 bits left to represent the address. So, in total, there can be 2²⁸ addresses in class E.

The class E addresses also constitute a total of 6.25% of the possible addresses.

And the range for the network address is 240 to 255 (How? → If we put all zeroes except for the 1st 4 bits which are 1111 by default, in the first octet, we get 111100000 = 240 and if we consider the last address i.e. put all ones we get 11111111 = 255).

These addresses are reserved for military purposes.

To summarize,

So, that was all about classful addressing in IPv4.

Feel free to leave a feedback in the comments.

Have a nice day 😊