One of the biggest problems is to choose the correct IP address range to use. So before we can continue with the task of allocating an address for each machine we need to be aware of some of the addressing schemes that are used.
We'll briefly describe three main schemes below. Class-based and subnetting, although still widely used, have largely been overtaken by the classless scheme known as Classless Inter-Domain Routing (CIDR), pronounced “cider.”
IP addresses have historically been based on the “class” system. For this, various classes were created: “A,” “B,” “C,” and “extended addressing mode.” “A,” “B,” and “C” were assigned a network portion and a host portion, which was a fixed value for each. An escape code was provided to access “extended addressing mode,” which would later be split further into classes “D” and “E” (multicast and experimental, respectively).
There was no concept of subnetting within the classes; routers would simply examine the address and deduce its class based on the value of its high-order bits. The network information would be obtained based on the global rules for that class (i.e., what portion of the address relates to the network and which portion relates to the host). This information is summarized in Table 11.1.
Class | High-Order Bits | Network Bits | Host Bits | Address Bits (b=high order n=network h=host) |
---|---|---|---|---|
A | 0 | 7 | 24 | bnnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh |
B | 10 | 14 | 16 | bbnnnnnn.nnnnnnnn.hhhhhhhh.hhhhhhhh |
C | 110 | 21 | 8 | bbbnnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh |
Extended Addressing Mode | 111 | — | — |
Using the information shown here, we can calculate the number of hosts that are available in each network and also the number of networks that are available in each class. For example, class “A” has 7 bits available for network addresses and 24 bits for host addresses. Converting this to decimal provides us with 126 subnets and 16,777,216 hosts in each network. Table 11.2 shows these details for each class.
Class | Address Range | First Byte Binary/ Decimal | Number of Available Classes | Max Number of Addresses per Network |
---|---|---|---|---|
A | 1.0.0.0–126.255.255.255 | 00000000/0 | 126 | 16,777,216 |
B | 128.0.0.0–191.255.255.255 | 10000000/128 | 16,384 | 65,536 |
C | 192.0.0.0–223.255.255.255 | 11000000/192 | 2,097,152 | 256 |
D (Multicast) | 224.0.0.0–239.255.255.255 | 11100000/224 | — | — |
E (Reserved) | 240.0.0.0–255.255.255.254 | 11110000/240 | — | — |
This method of addressing became regarded as inflexible for a number of reasons, the main one being that the number of addresses available for each class is fixed. This often led to address wastage, because, for example, if a company required 2,000 addresses, a class “C” address was too small, while a class “B” was too large. The result was usually to assign a class “B,” which can contain over 65,000 addresses. The company would use just 2,000 of them, resulting in over 60,000 being wasted. It soon became obvious that some other method of address allocation was required.
The problems with address wastage led to subnetting being introduced. This allows the IP address to be split into subnets by applying a netmask to it. To accommodate this within the standard 32-bit address, the subnet details are contained in the host portion. The subnet mask is used to determine which portions of the host component are actually subnet information. The network portion of the address is never affected and so routing still works in a similar way as classful addressing.
Every “1” bit in the subnet mask is used to indicate the network portion of the address, while every “0” bit indicates the host portion. Because the original network portion of the class itself remains the same, each class will have a minimum subnet mask “value.” Table 11.3 shows examples of various subnet masks across different classes.
Class | Subnet Mask | Address Bits (b=high order n=network s=subnet h=host) |
---|---|---|
A | 255.255.0.0 | bnnnnnnn.ssssssss.hhhhhhhh.hhhhhhhh |
A | 255.255.255.240 | bbnnnnnn.ssssssss.ssssssss.sssshhhh |
B | 255.255.252.0 | bbbnnnnn.nnnnnnnn.ssssssnn.hhhhhhhh |
C | 255.255.255.248 | bbbnnnnn.nnnnnnnn.nnnnnnnn.ssssshhh |
We can also see from this that—because the subnet information “eats” into the host details—as the number of subnets increases, the number of hosts available will decrease, and vice versa. Using this information, let's look at an example of how to calculate the available hosts and subnets for an IP address:
Class “C” IP address: 192.168.22.1
Network address: 192.168.22.0
Subnet mask: 255.255.255.192
The subnet mask in binary will be: 11111.11111.11111.11000000
The netmask will be applied as: bbbnnnnn.nnnnnnnn.nnnnnnnn.sshhhhhh
From this, we see that the last six zeros will form the host component and the preceding two bits will be the subnet. Converting the binary values to decimal leaves us with four subnets each comprising 64 host addresses. Table 11.4 shows the subnets and address ranges that would be generated using this netmask.
Subnet Address | Address Range | Broadcast Address |
---|---|---|
192.168.22.0 | 192.168.22.1–192.168.22.62 | 192.168.22.63 |
192.168.22.64 | 192.168.22.65–192.168.22.126 | 192.168.22.127 |
192.168.22.128 | 192.168.22.129–192.168.22.190 | 192.168.22.191 |
192.168.22.192 | 192.168.22.193–192.168.22.254 | 192.168.22.255 |
Alternatively, we could have applied a netmask of 255.255.255.128 to get two subnets, each comprising 126 hosts, or a mask of 255.255.255.248 to get 32 subnets of six hosts each, and so forth.
CIDR takes the concept of subnetting a step further. It was introduced to allow a more flexible approach to assigning addresses and is supported in Solaris 2.6 and above. Whereas subnetting can never alter the network portion of the address, CIDR removes these rules and allows users to assign a mask consisting of an arbitrary number of bits. This mask is known as either a “bit mask” or “supernet mask.” CIDR addresses are displayed as “network address/bit mask,” although the dotted notation is still used by many people.
For example, if we were using a class “C” address of 192.168.22.0 and we wanted to use a bit mask of 25 bits, we would indicate this by writing 192.168.22.0/25. This means that the network portion of the address comprises the first 25 bits, and the host component the last seven bits. Table 11.5 shows an example of calculating the network and host details for the previous syntax.
Description of Calculation | Value |
---|---|
Network number | 192.168.22.0/25 |
Supernet mask (binary) | 11111111.11111111.11111111.10000000 |
Supernet mask converted to “dot” notation | 255.255.255.128 |
Network number converted to binary | 11000000.10101000.00010110.00000000 |
First 25 bits of the network number | 11000000.10101000.00010110.0 |
Last seven bits—the host component range (binary) | 0000000 to 1111111 |
Last seven bits—the host component range (decimal) | 0 to 127 |
This shows this subnet has an addresses range from 0 to 127—a total of 128. However, 0 refers to the network itself and 127 will be the broadcast address, so we have 126 addresses available for use: 1 through 126.
Table 11.6 shows the CIDR bitmask value for every possible address and the classful equivalent it would have.
CIDR Bitmask Value | Dotted Notation | Max Number of Addresses | Equivalent Classful Value |
---|---|---|---|
/1 | 128.0.0.0 | 2,147,483,648 | 128 As |
/2 | 192.0.0.0 | 1,073,741,824 | 64 As |
/3 | 224.0.0.0 | 536,870,912 | 32 As |
/4 | 240.0.0.0 | 268,435,456 | 16 As |
/5 | 248.0.0.0 | 134,217,728 | 8 As |
/6 | 252.0.0.0 | 67,108,864 | 4 As |
/7 | 254.0.0.0 | 33,554,432 | 2 As |
/8 | 255.0.0.0 | 16,777,216 | Class A network |
/9 | 255.128.0.0 | 8,388,608 | 128 Bs |
/10 | 255.192.0.0 | 4,194,304 | 64 Bs |
/11 | 255.224.0.0 | 2,097,152 | 32 Bs |
/12 | 255.240.0.0 | 1,048,576 | 16 Bs |
/13 | 255.248.0.0 | 525,288 | 8 Bs |
/14 | 255.252.0.0 | 262,144 | 4 Bs |
/15 | 255.254.0.0 | 131,072 | 2 Bs |
/16 | 255.255.0.0 | 65,536 | Class B network |
/17 | 255.255.128.0 | 32,768 | 128 Cs |
/18 | 255.255.192.0 | 16,384 | 64 Cs |
/19 | 255.255.224.0 | 8,192 | 32 Cs |
/20 | 255.255.240.0 | 4,096 | 16 Cs |
/21 | 255.255.248.0 | 2,048 | 8 Cs |
/22 | 255.255.252.0 | 1,024 | 4 Cs |
/23 | 255.255.254.0 | 512 | 2 Cs |
/24 | 255.255.255.0 | 256 | Class C network |
/25 | 255.255.255.128 | 128 | ½ C |
/26 | 255.255.255.192 | 64 | ¼ C |
/27 | 255.255.255.224 | 32 | ⅛ C |
/28 | 255.255.255.240 | 16 | 1/16 C |
/29 | 255.255.255.248 | 8 | 1/32 C |
/30 | 255.255.255.252 | 4 | 1/64 C |
/31 | 255.255.255.254 | 2 | 1/128 C |
/32 | 255.255.255.255 | 1 | — |
Normal TCP/IP communication is based on unicast addresses. This means data is sent from one host and directed to another host (i.e., single host-to-host traffic). For this type of communication, the assigned host address of the system would be used; for example, 192.168.22.10.
The broadcast address is derived from the host's network address, but with the host component set to all one's (for example, 192.168.22.255). Whenever data is sent to the broadcast address, all hosts on that network will receive the data.
Multicast addresses are designed to allow a group of hosts to register an interest in receiving a set of data. This means the hosts have a choice of whether to receive the data or not. It is normally controlled at the program level. For example, Network Time Protocol (NTP) has been allocated a multicast address of 224.0.1.1. This will be used by the client programs to perform time queries.
A number of addresses cannot be assigned to a host, for various reasons. Table 11.7 shows these, along with an example of each.
Address Type | Examples | Reason |
---|---|---|
0.0.0.0 | 0.0.0.0 | Used to indicate the default route |
x.x.x.0 | 192.168.22.0 | Used to signify the network address |
x.x.x.255 | 192.168.22.255 | Used for the broadcast address |
255.255.255.255 | 255.255.255.255 | Used to refer to all hosts on the local network |
127.x.x.x | 127.0.0.10 | The loopback interface (described later) |
128.0.x.x | 128.0.1.1 | Reserved by the Network Information Center |
129.0.0.x | 129.0.0.1 | Reserved by the Network Information Center |
191.255.x.x | 191.255.1.1 | Reserved by the Network Information Center |
223.255.255.x | 223.255.255.1 | Reserved by the Network Information Center |
Multicast Address | 224.0.0.1 | Reserved for multicast addresses |
Experimental Address | 240.0.0.1 | Reserved for experimental use |