Quick intro to classful IP addressing

James Ma
4 min readApr 3, 2022

All computers have assigned IP address that are attached to the Internet, or even in your local network. More often than not, your computer is likely to use the IP version 4 protocol.

IP is the TCP/IP network layer protocol. It provides the following functions:

  • Global addressing structure
  • Types of service requests
  • Fragmentation of packets
  • Re-assembly of packets at the destination host

There are also other protocols at the network layer, such as:

  • ARP — Address Resolution Protocol
  • ICMP — Internet Control Message Protocol
  • IGMP — Internet Group Management Protocol

If you look at a IPv4 address, it’s a 32-bit IP address field. For example, the IP address 129.15.17.3 can be written in binary form as:

10000001.00001111.00010001.00000011

This field is divided into 2 parts:

  • The Network ID
  • The Host ID

There are five classes of IP address, namely A, B, C, D and E. Each class of address within the IP scheme has a unique bit pattern.

Let’s look at each class of IP address at the bit level.

Class A address

Class A address represenation.

The leading bit is set to 0. The remaining 7 bits is the network feld, and the remaining 24 bits is the host addresses.

This gives a total of 126 Class A networks and a whoopping 16,777,214 hosts per network!

Range of IP addresses in Class A are 001.hhh.hhh.hhh through 127.hhh.hhh.hhh, with “h” to denote the host ID.

Class B address

Class B address respresentation.

The 2 leading bits is set to “10”, giving a 14-bit network field and 16-bit host addresses.

This gives a total of 16,384 Class B networks and 65,534 hosts per network.

Range of IP addresses in Class B are 128.001.hhh.hhh through 191.254.hhh.hhh.

Class C address

Class C address representation.

The 3 leading bits are set to “110”, giving a 21-bit network and 8-bit host addresses.

This gives a total of 2,097,152 Class C networks & 254 hosts per network.

Range of IP addresses in Class C are 192.000.001.hhh through 223.255.254.hhh.

Class D address

Class D address representation.

Also used as a multi-cast address, the 4 leading bits are set to “1110”. The remaining 28 bits specify a multi-cast group ID.

Range of IP addresses in Class D are 224.000.000.000.000 through 239.255.255.255.

Class E address

Class E address representation.

The 4 leading bits are set to “111”. Class E addresses are reserved for future use. The IP address 255.255.255.255 is used as a LAN broadcast address.

Some special rules for IPv4

  • The host portion of any IP address should not be all 1 bits, otherwise it will be interpreted as “all hosts” in the network. For example, the address 128.1.255.255 is interpreted as all hosts on Network 128.1.0.0.
  • The network portion of any IP address should not be all 0 bits, otherwise it will be interprested as “this network”. For example, the address 0.0.0.63 is interpreted as meaning Host 63 on “this” network.
  • The Class A network number 127 is assigned as the “loopback” function. This means that a datagram sent by a higher-level protocol to a Network 127 address should loop back inside the host.

What is classless IP addressing

As you can see, because blocks of IP addresses are allocated for each class, it may not be most efficient way of distributing IP addresses. Classless IP addressing is designed to remove the notion of “classes” to allow flexibility and scalability in assigning IP addresses.

Read more about classless IP addressing here: https://medium.com/@jamesmawm/classless-inter-domain-routing-cidr-cheatsheet-for-ip-addresses-6af94c481fa8

--

--

James Ma
James Ma

Written by James Ma

Tech lead at a digital bank startup in Singapore.

No responses yet