Classless InterDomain Routing (CIDR) allows a block of IP addresses to be divided to accommodate the needs of networks more flexibly than the class system developed at the inception of the Internet. At the same time, CIDR allows network designers to avoid situations where large numbers of IP addresses are unused. In order to understand CIDR, we must first understand the basics of the classful (also called stateful) IP addressing scheme used in the Internet. The formal name for the current addressing scheme is Internet Protocol Version 4 (IPv4).
An IP address is 32 bits long and is divided into 4 octets (8-bit groupings). Each octet has a range of values equal to 28 or 256. The low value of the range is 0, the high value being 255.
The 4 bytes in the 32-bit ip address are transmitted in order: bits 0 through 7 first, then bits 8 through 15, then bits 16 through 23 and bits 24 through 31 last. This is the network byte order, also called big endian byte ordering. Computers that store binary integers in other formats, such as little endian byte ordering, must convert them to the network byte order before transmitting Stevens, W. Richard, TCP/IP Illustrated Volume 1, p 34, Addison Wesley 1994. As we discuss stateful (class) IP addresses and CIDR (classless) IP addresses, this definition becomes very important. It explains why a router determines which bits of an IP address represent the network and which represent the host.
Addresses on the public Internet are divided into five classes. class A addresses were originally designed for very large domains; class B addresses for intermediate size domains; and class C addresses for small domains. Class D addresses were reserved for multicast networks. Class E addresses are experimental, and we do not plan to discuss them tonight.Routers that route Class A, B and C IP addresses use ARP to advertise and discover routes to unknown hosts, to store routes for hosts, and to store cost information concerning those routes. Cost, in the sense of routing, is a determination of the number of routers the information must pass through, and the speed of transmission to the next router, also called a hop, in the route. A lower cost route is a faster route.
First Octet Network 1st Octet Bit Position |
Second Octet Host 2nd Octet Bit Position |
Third Octet Host 3rd Octet Bit Position |
Fourth Octet Host 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
A Class A subnet is 255.0.0.0. That means a network router reads the first octet (0 through 255) as a network address. However, your router reads the second, third and fourth octet as a host address. Therefore, the network address range is 0.0.0.0 to 9.0.0.0 and 11.0.0.0 to 126.0.0.0. 10.0.0.0 is allocated for virtual private networks. This range is extremely important to our discussion of CIDR.
The potential host addresses are the remaining 24 octets. The range of host addresses in a class A network is 224 or 16,777,216. This network could not be managed with a single router.
First Octet Network 1st Octet Bit Position |
Second Octet Network 2nd Octet Bit Position |
Third Octet Host 3rd Octet Bit Position |
Fourth Octet Host 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
A Class B subnet is 255.255.0.0. That means a network router reads the first 2 octets (0 through 255 then 0 through 255 again) as a network address. However, your router reads the third and fourth octet as a host address. Therefore, the network address range is 128.255.0.0 to 191.255.0.0, excluding reserved IP addresses from 172.16.0.0 through 172.31.255.255. The reserved range in the class B range is set aside for internal communication between clients and servers on the same host.
The potential host addresses are the remaining 2 octets. The range of host addresses in a class B network is 216 or 56,536. During the inception of the Internet, the allocation for a medium size network was quite generous also.
First Octet Network 1st Octet Bit Position |
Second Octet Network 2nd Octet Bit Position |
Third Octet Network 3rd Octet Bit Position |
Fourth Octet Host 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
A Class C subnet is 255.255.255.0. That means a network router reads the first 3 octets (0 through 255 then 0 through 255 again, then 0 through 255 one more time) as a network address. However, your router reads the fourth octet as a host address. Therefore, the network address range is 192.0.0.0 to 191.255.0.0, excluding reserved IP addresses from 192.168.0.0 through 192.168.255.0. The reserved range in the class C range is set aside for internal LAN addresses.
The potential host addresses are the remaining octet. The range of host addresses in a class C network is 28 or 256. The host range is reduced by one for the gateway address, and by one for the broadcast address, leaving 254 usable host addresses. Our perception of a small network has also changed since the inception of the Internet.
Class D IP addresses are used in multicast networks. A multicast can be considered broadcast by subscription. The multicast network is a means of conserving bandwidth and routing resources when many hosts subscribe to the same continuously updating data. Stock tickers, news feeds and streaming video are well suited to multicast capabilities.
Multicasting provides two services for an application:
Multicast uses IGMP protocol for the mechanics. Very broadly speaking, multicast delivery feeds data to a multicast router that is often called a rendezvous point. The transmission point for the multicast feed is often static routed to the rendezvous point or multicast router. (A static route is defined in the router configuration, not discovered through ARP). A well placed rendezvous point or multicast router is close in terms of cost metrics to the hosts who have subscribed to the multicast feed. Here, the multicast router copies the feed, (also called replicating) and delivers the feed more efficiently to the receiving hosts than if the feed were routed throughout the WAN by traditional ARP. The IGMP protocol conserves bandwidth by providing a single feed through substandial distance within the network, rather than requiring a feed for each receiving host. It further conserves routing resources by use of static routes, and by using ARP-like protocols in an environment where the cost metrics are much lower (often a single hop).
A Class D IP address always has 224 as the initial octete value: the first three bits are "on" and the fourth bit is null. The first octet value is 128, plus the second (64), plus the third is (32), plus the fourth bit which is null, equals 224. The remaining four bits of the first octet, and the first bit if the second octet are not used in the host address. The remaining 23 bits of a Class D IP address are reserved for host addresses (Stevens, W.R., p 175-176). Therefore the Class D subnet is 255.128.0.0. We will learn the reason for the second octet value when we discuss subnetting in CIDR.
CIDR involves using a subnet value less than 255 for the final octet of a class. Many benefits flow from this capability. For example, when a domain does not need 250-some hosts to appear on the Internet, it can purchase the number of public IPs it actually needs from an ISP. The ISP is then free to assign the balance of IPs to other domains. This operation is called subnetting. Also, the owner of an address block can create a network that is larger than the traditional Class A, B, or C network by reassigning a bit usually used for a network address to hosts. For example, a Class B network can contain a maximum of 65,534 hosts, and its subnet is 255.255.0.0. If a network designer designates a subnet or 255.254.0.0, the maximum number of hosts becomes 131,068, or roughly 217, instead of 216. The latter operation is called supernetting.
Router and NIC configurations must be more explicit within CIDR. The IP address is written to designate a network address within the Class A, B or C block. Another line of a router configuration can designate a different network address within that same address block.
Let's consider an imaginary Class C address block owned by a small Internet service provider. The network address for this block is 221.241.17.0. The following table shows the bit allocation and illustrates how to derive the octet values for the network address.
First Octet Network 1st Octet Bit Position |
Second Octet Network 2nd Octet Bit Position |
Third Octet Network 3rd Octet Bit Position |
Fourth Octet Potential Host Addresses 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | NA | 208 | 216 | 220 | NA | 221 | 128 | 192 | 224 | 240 | NA | NA | NA | 241 | NA | NA | NA | 16 | NA | NA | NA | 17 | LAN | LAN | LAN | LAN | LAN | LAN | LAN | LAN |
Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | For Destination Network and Host IPs |
||||||||||||||||||||||||||||
A | A | I | A | A | A | I | A | A | A | A | A | I | I | I | A | I | I | I | A | A | A | I | A | LAN | LAN | LAN | LAN | LAN | LAN | LAN | LAN |
From this Class C block, I will create two domains with IP space for 4 hosts in each domain. Because each domain requires a broadcast and network address also, I most provide at least six usable addresses. By inspecting the bit values, you can see that our choices are to assign one usable IP space, two usable spaces, four usable spaces or eight usable spaces. The assignment is done by using the subnet to assign bits to the network addresses or the host addresses.
Recall that a Class C address has the following subnet: 255.255.255.0. The subnet value is obtained from the cumulative value of bits in each ocetet. In our example, CIDR allows us to assign additional bits to the subnet. Our domains need IP addresses for 4 hosts, plus a network address and a broadcast address for a total of six usable IP addresses. Due to cumulative bit values, we must provide 8 usable addresses. The subnet that allows 8 usable IP addresses is 255.255.255.248, the cumulative values of each ocetet when 29 bits of an IP address are allocated to a network.
Moving backward for the end of the class C range, we find the last value of the range is 221.241.17.255. The final usable IP in the range is traditionally the broadcast address. This address is necessary to resolve IP addresses in the network to host MAC addresses, therby allowing the router to send data packets to the correct computer. The first address in the arrange is 221.241.17.248, which is the network address. This address allows your network to be identified to the public Internet on the router. The next address, 221.241.17.249 is traditionally the IP address of your router, and the five IP values of 221.241.17.250 through 221.241.17.254 are available for hosts on your network. The notation for this network is 221.241.17.248, subnet 255.255.255.248, or more correctly, 221.241.17.248 /29, with "/29" indicating the first 29 bits are network address.
First Octet Network 1st Octet Bit Position |
Second Octet Network 2nd Octet Bit Position |
Third Octet Network 3rd Octet Bit Position |
Fourth Octet Network or LAN 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | NA | 208 | 216 | 220 | NA | 221 | 128 | 192 | 224 | 240 | NA | NA | NA | 241 | NA | NA | NA | 16 | NA | NA | NA | 17 | 128 | 192 | 224 | 240 | 248 | LAN | LAN | LAN |
Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | ||||||||||||||||||||||||||||
A | A | I | A | A | A | I | A | A | A | A | A | I | I | I | A | I | I | I | A | A | A | I | A | A | A | A | A | A | LAN | LAN | LAN |
The same reasoning applies to our second domain. The subnet that allows 8 usable IP addresses is 255.255.255.248, the cumulative values of each ocetet when 29 bits of an IP address are allocated to a network. However, moving backward for the end of the class C range, we now find the last value of the range is 221.241.17.247, the second domain's broadcast address. The network address is 221.241.17.240 /29. The router traditionally uses 221.241.17.241, and the range for host addresses is 221.241.17.242 through 221.241.17.246.
First Octet Network 1st Octet Bit Position |
Second Octet Network 2nd Octet Bit Position |
Third Octet Network 3rd Octet Bit Position |
Fourth Octet Network or LAN 4th Octet Bit Position |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Bit Value | Bit Value | Bit Value | Bit Value | ||||||||||||||||||||||||||||
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | Cumulative Bit Value | ||||||||||||||||||||||||||||
128 | 192 | NA | 208 | 216 | 220 | NA | 221 | 128 | 192 | 224 | 240 | NA | NA | NA | 241 | NA | NA | NA | 16 | NA | NA | NA | 17 | 128 | 192 | 224 | 240 | NA | LAN | LAN | LAN |
Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | Active (A) or Inactive (I) Bits | ||||||||||||||||||||||||||||
A | A | I | A | A | A | I | A | A | A | A | A | I | I | I | A | I | I | I | A | A | A | I | A | A | A | A | A | I | LAN | LAN | LAN |
The following tables demonstrate subnet mask resolution and the CIDR conversion table(From R J Smith's Homepage) which lists CIDR bit length, subnet mask, number of networks and number of hosts.
7 bit Final Octet 128 |
6 bit Final Octet 192 |
5 bit Final Octet 224 |
4 bit Final Octet 240 |
3 bit Final Octet 248 |
2 bit Final Octet 252 |
||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Network | Broadcast | Network | Broadcast | Network | Broadcast | Network | Broadcast | Network | Broadcast | Network | Broadcast |
0 | 127 | 0 | 63 | 0 | 31 | 0 | 15 | 0 | 7 | 0 | 3 |
128 | 255 | 64 | 127 | 32 | 63 | 16 | 31 | 8 | 15 | 4 | 7 |
128 | 191 | 64 | 95 | 32 | 47 | 16 | 23 | 8 | 11 | ||
192 | 255 | 96 | 127 | 48 | 63 | 24 | 31 | 12 | 15 | ||
128 | 159 | 64 | 79 | 32 | 39 | 16 | 19 | ||||
160 | 191 | 80 | 95 | 40 | 47 | 20 | 23 | ||||
192 | 223 | 96 | 111 | 48 | 55 | 24 | 27 | ||||
224 | 255 | 112 | 127 | 56 | 63 | 28 | 31 | ||||
128 | 143 | 64 | 71 | 32 | 35 | ||||||
144 | 159 | 72 | 79 | 36 | 39 | ||||||
160 | 175 | 80 | 87 | 40 | 43 | ||||||
176 | 191 | 88 | 95 | 44 | 47 | ||||||
192 | 207 | 96 | 103 | 48 | 51 | ||||||
208 | 223 | 104 | 111 | 52 | 55 | ||||||
224 | 239 | 112 | 119 | 56 | 59 | ||||||
240 | 255 | 120 | 127 | 60 | 63 | ||||||
128 | 135 | 64 | 67 | ||||||||
136 | 143 | 68 | 71 | ||||||||
144 | 151 | 72 | 75 | ||||||||
152 | 159 | 76 | 79 | ||||||||
160 | 167 | 80 | 83 | ||||||||
168 | 175 | 84 | 87 | ||||||||
176 | 183 | 88 | 91 | ||||||||
184 | 191 | 92 | 95 | ||||||||
192 | 199 | 96 | 99 | ||||||||
200 | 207 | 100 | 103 | ||||||||
208 | 215 | 104 | 107 | ||||||||
216 | 223 | 108 | 111 | ||||||||
224 | 231 | 112 | 115 | ||||||||
232 | 239 | 116 | 119 | ||||||||
240 | 247 | 120 | 123 | ||||||||
248 | 255 | 124 | 127 | ||||||||
128 | 131 | ||||||||||
132 | 135 | ||||||||||
136 | 139 | ||||||||||
140 | 143 | ||||||||||
144 | 147 | ||||||||||
148 | 151 | ||||||||||
152 | 155 | ||||||||||
156 | 159 | ||||||||||
160 | 163 | ||||||||||
164 | 167 | ||||||||||
168 | 171 | ||||||||||
172 | 175 | ||||||||||
176 | 179 | ||||||||||
180 | 183 | ||||||||||
184 | 187 | ||||||||||
188 | 191 | ||||||||||
192 | 195 | ||||||||||
196 | 199 | ||||||||||
200 | 203 | ||||||||||
204 | 207 | ||||||||||
208 | 211 | ||||||||||
212 | 215 | ||||||||||
216 | 219 | ||||||||||
220 | 223 | ||||||||||
224 | 227 | ||||||||||
228 | 231 | ||||||||||
232 | 235 | ||||||||||
236 | 239 | ||||||||||
240 | 243 | ||||||||||
243 | 247 | ||||||||||
248 | 251 | ||||||||||
252 | 255 |
Length | Mask | Number of Networks |
Network Type | Number of Hosts |
---|---|---|---|---|
/1 | 128.0.0.0 | 128 | A | 2,147,483,392 |
/2 | 192.0.0.0 | 164 | A | 1,073,741,696 |
/3 | 224.0.0.0 | 32 | A | 536,870,848 |
/4 | 240.0.0.0 | 16 | A | 268,435,424 |
/5 | 248.0.0.0 | 8 | A | 134,217,712 |
/6 | 252.0.0.0 | 4 | A | 67,108,856 |
/7 | 254.0.0.0 | 2 | A | 33,554,428 |
/8 | 255.0.0.0 | 1 | A | 16,777,214 |
/1 | 255.128.0.0 | 128 | B | 8,388,352 |
/10 | 255.192.0.0 | 164 | B | 4,194,176 |
/11 | 255.224.0.0 | 32 | B | 2,097,088 |
/12 | 255.240.0.0 | 16 | B | 1,048,544 |
/13 | 255.248.0.0 | 8 | B | 524.272 |
/14 | 255.252.0.0 | 4 | B | 262,136 |
/15 | 255.254.0.0 | 2 | B | 131,068 |
/16 | 255.255.0.0 | 1 | B | 65,534 |
/17 | 255.255.128.0 | 128 | C | 32,512 |
/18 | 255.255.192.0 | 64 | C | 16,256 |
/19 | 255.255.224.0 | 32 | C | 8,128 |
/20 | 255.255.240.0 | 16 | C | 4,064 |
/21 | 255.255.248.0 | 8 | C | 2,032 |
/22 | 255.255.252.0 | 4 | A | 1,016 |
/23 | 255.255.254.0 | 2 | C | 508 |
/24 | 255.255.255.0 | 1 | C | 254 |
/25 | 255.255.255.128 | 2 | subnet | 124 |
/26 | 255.255.255.192 | 4 | subnet | 62 |
/27 | 255.255.255.224 | 16 | subnet | 30 |
/28 | 255.255.255.240 | 32 | subnet | 14 |
/29 | 255.255.255.248 | 32 | subnet | 6 |
/30 | 255.255.255.252 | 64 | subnet | 2 |
/31 | 255.255.255.254 | none | subnet | none |
/32 | 255.255.255.255 | 1/256th | C | 1 |