Netid and Hostid

Networking

In classful addressing, an IP address of class A, B and C is divided into netid and hostid. The netid determines the network address while the hostid determines the host connected to that network.

Byte 1Byte 2Byte 3Byte 4
Class ANetidHostid
Class BNetid Hostid
Class CNetid Hostid
Class DMulticast Address
Class EReserved for future use

Blocks and Hosts

Each class is divided into blocks. The numbers of block in a class can be calculated by the number of bits in the netid.

CLASS A

Class A has 1 byte (8 bits) netid and from the binary notation we see that Class A address starts with 0 so there are total 7 bits that can be changed out of 8.

Therefore total number of blocks in Class A = 27 = 128

There are 3 bytes (24 bits) for hostid in Class A so total number of host in each block = 224 = 16,777,216

So total number of addresses in Class A = No. of Blocks in Class A x No. of Hosts in each block of Class A

= 128 x 16,777,216

= 2,147,483,648

This is 50% of the total addresses in IPv4.

1st block of Class A has the netid 0

And the host id is between

0.0.0.0

0.255.255.255

Similarly, 2nd block of Class A has the netid 1

And the host id is between

1.0.0.0

1.255.255.255

Netid 0

Netid 1

Netid 127

Class A

0.0.0.0

to

0.255.255.255

1.0.0.0

to

1.255.255.255

127.0.0.0

to

127.255.255.255

Block 1

Block 2

Block 128

CLASS B

Class B has 2 bytes (16 bits) netid and from the binary notation we see that Class B address starts with 10, so there are total 14 bits that can be changed out of 16.

Therefore total number of blocks in Class B = 214 = 16,384

There are 2 bytes (16 bits) for hostid in Class B so total number of host in each block = 216 = 65,536

So total number of addresses in Class B = No. of Blocks in Class B x No. of Hosts in each block of Class B

= 16,384 x 65,536

= 1,073,741,824

This is 25% of the total addresses in IPv4.

1st block of Class B has the netid 128.0

And the host id is between

128.0.0.0

128.0.255.255

Similarly, 2nd block of Class B has the netid 128.1

And the host id is between

128.1.0.0

128.1.255.255

Netid 128.0

Netid 128.1

Netid 191.255

Class B

128.0.0.0

to

128.0.255.255

128.1.0.0

to

128.1.255.255

191.255.0.0

to

191.255.255.255

Block 1

Block 2

Block 16,384

CLASS C

Class C has 3 bytes (24 bits) netid and from the binary notation we see that Class C address starts with 110, so there are total 21 bits that can be changed out of 24.

Therefore total number of blocks in Class C = 221 = 2,097,152

There is 1 byte (8 bits) for hostid in Class C so total number of host in each block = 28 = 256

So total number of addresses in Class C = No. of Blocks in Class C x No. of Hosts in each block of Class C

= 2,097,152 x 256

= 536,870,912

This is 12.5% of the total addresses in IPv4.

1st block of Class C has the netid 192.0.0

And the host id is between

192.0.0.0

192.0.0.255

Similarly, 2nd block of Class B has the netid 192.0.1

And the host id is between

192.0.1.0

192.0.1.255

Netid 192.0.0

Netid 192.0.1

Netid 223.255.255

Class C

192.0.0.0

to

192.0.0.255

192.0.1.0

to

192.0.1.255

223.255.255.0

to

223.255.255.255

Block 1

Block 2

Block 2,097,152

CLASS D

It consists of a single block. It is designed for multicasting.

Class D

224.0.0.0 to 239.255.255.255

Single block of 268,435,456 addresses

CLASS E

It also consists of a single block. It is reserved for future use.

Class E

240.0.0.0 to 255.255.255.255

Single block of 268,435,456 addresses

There are 128 blocks in Class A so only 128 organizations can be assigned Class A address, but each block has 2,147,483,648 hosts which mean the organization needs to be really huge to consume all the addresses in the block.

There are 16,384 blocks in Class B so total 16,384 organizations can be assigned Class B address and there are 65,536 hosts in each block which mean each organization must be quite large to consume all the addresses in the block.

There are 2,097,152 blocks in Class C so total 2,097,152 organizations can be assigned Class C address but there are only 256 hosts in each block which mean the organization must be quite small to use this class.

This is the reason why a lot of addresses are wasted because of classful addressing.

Class A address can be allocated to only 128 organizations which sound quite ok but each of these organizations must have 16,777,216 machines (host) which is not impossible. While Class C address can be assigned to a lot of organizations (2,097,152 to be precise) but if an organization gets Class C then it cannot have more than 256 computers (host).

Purpose of IPv4 Addressing

The main purpose of IPv4 addressing was to define a destination for an Internet Packet. When classful addressing was designed, it was assumed that the Internet was made up of interconnected networks i.e. the Internet was viewed as a network of networks.