Networking

Build Your Skills: IP address classes overview

Breaks down the five IP address classes in order to explain how they manipulate TCP/IP protocol functionality

Before two or more computers can communicate with each other, a set of rules has to be in place describing the procedures for each host or router on the network to follow when sending data to—or receiving data from—other hosts or routers. This set of rules is referred to as a protocol, and TCP/IP is the most common set of rules in use for computing today. To understand computer networking as well as internetworking, you must understand the TCP/IP protocol suite. In this Daily Drill Down, I’ll provide you with an introduction to the TCP/IP protocol suite.

IP addresses
The TCP/IP protocol suite uses an Internet address, or IP address, to uniquely identify each host or router on an internetwork. What makes IP addresses unique is that each address identifies only one host or router on the Internet. Any host or router that wants to be connected to the Internet must use the addressing scheme used by TCP/IP.

An IP address is a 32-bit (4-byte) number written in dot notation, which simply means that each byte is separated by a dot, or period. A typical IP address in dot notation would look like this:
192.168.10.21

The same address written in binary format would be:
11000000.10101000.00001010.00010101

As you can see from the binary example above, each byte in an IP address can represent any number from 0 to 255. With 4 bytes used in each IP address, this means that the total number of IP addresses available is 2, or 4,294,967,296 possible IP addresses. Every IP address contains two distinct parts:
  • The netid identifies the network.
  • The hostid identifies the host on that network.

IP address classes
Although a lot of IP addresses are available, you don’t just pick out any address for use with your company network and assign addresses however you like. Depending on your networking requirements, you are assigned (by your service provider) a specific class of IP address.

There are five classes of IP addresses: A, B, C, D, and E. In the following sections, I’ll discuss each class.

Class A addresses
Class A networks are assigned to organizations with very large numbers of computers—including servers and routers—attached to their networks. A government department or a Fortune 500 corporation would be examples of this type of network. The following characteristics apply to class A networks:
  • Class A addresses range from 0.0.0.0 to 127.255.255.255.
  • The leftmost bit in a class A network is always 0.
  • The first 8 bits (first byte) define the netid.
  • The remaining 24 bits define the hostid.

It would appear that because the first 8 bits define the netid, the maximum number of class A networks available would be 2, or 128 networks. However, a netid with all bits set to 1 and a netid with all bits set to 0 are reserved for special use. This means that the actual number of class A networks available is 2 minus 2, or 126 networks.

As I mentioned earlier, class A addresses use 24 bits to define the hostid. In theory, there is a maximum of 2, or 16,777,216, hostids available. Like netids, a hostid with all bits set to 1 and a hostid with all bits set to 0 are reserved for special use. This means that the actual maximum number of hostid addresses on a class A network is 2 minus 2, or 16,777,214.

This limitation applies to all IP address classes. I’ll discuss the limitation in more detail later.

Class B addresses
Class B networks are also assigned to organizations with large networks. Class B networks have the following characteristics:
  • Class B network addresses range from 128.0.0.0 to 191.255.255.255.
  • The first 2 bits in a class B address are always 10 (128).
  • In a class B network, the netid is determined by the first 16 bits (first 2 bytes).
  • The hostid is determined by the last 16 bits (last 2 bytes).
  • There are 2 (65,536) possible IP addresses for each class B network.
  • The netids 172.16.0.0 to 173.31.0.0 are reserved for special use. This makes the actual maximum number of class B netids 2 minus 2, or 65,534.

Class C addresses
Class C networks are assigned to organizations with small to medium networks. The class C network is the most common network in use today. Class C networks have the following characteristics:
  • Class C network addresses range from 192.0.0.0 to 223.255.255.255.
  • Class C networks use the first 24 bits to determine the netid.
  • The three leftmost bits in a class C network are always 110 (192).
  • The next 21 bits are used to define network.
  • There are 2, or 2,097,152, possible class C networks.
  • In class C networks, 8 bits are used to define the hostid. Because an address with all bits set to 1 or all bits set to 0 is not allowed, the maximum number of hostids on a class C network is 2 minus 2, or 254 hostids.

Class D IP addresses
Class D IP addresses are reserved for multicasting. Class D networks have the following characteristics:
  • In class D addresses, the first 4 bits are always 1110 (224).
  • The remaining 28 bits are used to define multicast addresses.
  • There is no netid or hostid in a class D address. The whole address is used for multicasting.

Class E IP addresses
Class E addresses are reserved for special use on the Internet. There is no netid or hostid in a class E address. The first 4 bits in a class address are always 1111 (240).

Determining the address class
For any given IP address, the address class is easy to determine. If the address is written in binary format, the leftmost bits in the address will define the class.
  • If the first bit is 0, the address is a class A address.
  • If the first bit is 1 and the second bit is 0, the address is a class B address.
  • If the first 2 bits are 1 and the third bit is 0, the address is a class C address.
  • If the first 3 bits are 1 and the fourth is 0, the address is a class D address.
  • If the first 4 bits are 1, the address is a class D address.
  • If the address is written in decimal format, the first number determines the address.
  • If the first number is between 0 and 127 inclusive, the address is class A.
  • If the first number is between 128 and 191 inclusive, the address is class B.
  • If the first number is between 192 and 223 inclusive, the address is class C.
  • If the first number is between 224 and 239 inclusive, the address is class D.
  • If the first number is between 240 and 255 inclusive, the address is class E.

Determining the netid and hostid
Determining the netid and hostid contained within any given IP address is not difficult. Once you’ve determined the class of the IP address, use the following process:
  • If the class is class A, the first byte is the netid and the remaining 3 bytes are the hostid.
  • If the class is class B, the first 2 bytes are the netid and the remaining 2 bytes are the hostid.
  • For a class C address, the first 3 bytes are the netid and the last byte is the hostid.
  • For a class D address, there is no netid or hostid. All class D addresses are reserved for multicasting.
  • For class E addresses, there is no netid or hostid. All class E addresses are reserved for special uses.

The table below lists the number of netids and hostids available for each IP address class.

Class Number of network addresses Number of host addresses
A 2 - 2 (126) 2 – 2 (16,777,214)
B 2 –2 (16,384) 2 – 2 (65,534)
C 2 –2 (2,097,152) 2 – 2 (154)
D None None
E None None
We’ve listed the number of netids and hostids available for each IP address class.

Special IP addresses
Class A, B, and C addresses each have addresses set aside for special purposes. You should become familiar with six special addresses, which I’ll describe in the following sections.

Network address
In class A, B, and C addresses, any address with a hostid with all bits set to 0 is used to define the network address. This address is never assigned to a host. This simply means that your network itself is given an IP address with all the hostid bits set to 0. This is not the same as the netid. The network address is always an address with the host bits set to 0. For example, if a host on a network has an IP address of 142.23.120.24, the network address is:
142.23.0.0

This host on this network
If an IP address consists of all zeros, the address refers to this host on this network. A host uses this address when it is booted, but the host does not know its IP address. This address is always a class A address, regardless of the network configuration.

Specific host on this network
An IP address with all netid bits set to 0 refers to a specific host on this network. Setting the netid bits to 0 ensures that any IP information sent using this address is not routed. The information will remain within the local network. For example, if my IP address is 216.120.46.100 and I know I am on the 216.120.46 local network, I could send information to the host with the IP address 216.120.46.69 by using the address 0.0.0.60.

Direct broadcast address
Any class A, B, or C address with the hostid set to all ones is known as a direct broadcast address. Routers to send information to all hosts on a specific network use this address. For example, if you sent IP information to 204.36.120.255, all hosts on the 204.36.120.0 network would receive the information sent.

Limited broadcast address
Any class A, B, or C address with all bits set to 1 (255.255.255.255) is used to send information to all other hosts on the same network as the host sending the information. In other words, this address sends IP information to all hosts on your local network.

Loopback address
Any IP address with the first byte set to 127 is used for the loopback address. The loopback address is used to test the TCP/IP software on a computer and it does not provide any information on the configuration of a network interface. The most common loopback address is 127.0.0.1. When you run the command
ping 127.0.0.1

you can determine whether your TCP/IP software is running properly. A child process on a computer may also use the loopback address to send a message to its parent process.

Private IP networks
There are three blocks of IP addresses that may be used by any organization for TCP/IP networking. These IP addresses are nonroutable, meaning they are limited to use within the local network only. The three groups of nonroutable IP addresses are listed in the table below.

Address Block Netmask Class
10.x.x.x 255.255.255.0 A
176.16.0.0/12 –176.31.255.255 255.255.0.0 B
192.168.0.0 – 192.168.255.0 255.255.255.0 C
The three groups of nonroutable IP addresses are shown according to class.

Any organization may use any address from the blocks listed above without registering the IP addresses used on its network.

Summary
The TCP/IP protocol suite provides the foundation for internetworking. In this Daily Drill Down, I introduced you to the TCP/IP protocol suite.

Editorial disclaimer 
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.
0 comments

Editor's Picks