As mentioned above, IP addresses in the currently used version of IP, IP version 4, are 32-bit numbers. To represent an IP address for use by humans, dotted decimal notation is used. The address is written as four decimal numbers separated by periods, where each number represents a byte of the address in order. Thus the entire address space lies in the range 0.0.0.0 through 255.255.255.255.
Since all networks are treated equally, but some are much larger than others, it would be very inefficient to split the 32-bit address in a fixed way between the network and host part. Instead, IP allows the address to be split at any point, with the most significant part representing the network address, and the least significant part representing the host address within that network. To identify the split point, network masks are used; these are numbers in which the network part of the address is set to all ones, while the host part is set to all zeroes. The network address can thus be obtained by taking the bitwise AND of the IP address and the network mask, while the host address can be obtained by taking the bitwise AND of the IP address and the one's complement of the netmask.
Historically, the split between network and host part was done on byte boundaries, allowing three different classes of IP address. Class A addresses were used for large networks, and used 24 bits for the host address part; class B addresses were used for medium sized networks, and used 16 bits for the host address part, while class C addresses were used for small networks, with only 8 bits used for the host address part.
As the Internet grew, even this approach became too restrictive, and Internet routing protocols are now classless; nevertheless, the idea of IP address classes remains a useful terminological convention. The address classes are shown in Figure 1.1.
There are some special address values that are worth noting:
In general, all zero values in a host or network part can be read as `this', while all one values can be read as `all' (provided the address can still be interpreted unambiguously).
The relationship between dotted decimal addresses and address classes is shown in Figure 1.2.