CIDR (pronounced as cider) is used with IP routing. CIDR was introduced in the early 1990s to replace classful network addressing. Recall from ICS 184 that we have Class A, Class B and Class C network address blocks.
This was not a very efficient use of addressing. Imaging that a company needed just 20 IP Address in the early 1990s. They would have been given an entire Class C address block. This would have wasted about 230 IP Addresses!
With using CIDR we can provide smaller networks when needed. This helped delay the eventually IPv4 exhaustion (the running out of IP4 address space, which as occurred over a decade ago).
In this course we just need to understand what CIDR notation means. This also helps with understanding of VLSM (Variable Length Subnet masking).
CIDR provides the number of bits that are used to calculate the netmask that is used. We should be familiar with 255.255.255.0 as a subnet mask (most like you have seen this at home or from ICS 184). A subnet mask of 255.255.255.0 can be written as /24. How is this calculated? A subnet mask has 32-bits, just like an IPv4 address, and is also written in dotted decimal notation, with each part being made of 8-bits.
(8-bits).(8-bits).(8-bits).(8-bits)
We just add up all the bits in a subnet mask to determine the CIDR. Though, you also need to be able to take a CIDR value and determine the subnet mask. For example, if you are given a CIDR of /27 what is the subnet mask? We know that a /27 has 27 1's in a row in dotted decimal notation:
1111 1111.1111 1111.1111 1111.1110 0000
Now we need to take each part of the subnet mask and convert the binary value to decimal. This is where power of two's comes in to play (see below):
20 = 0
21 = 2
22 = 4
23 = 8
24 = 16
25 = 32
26 = 64
27 = 128
Using the values we just need to add up the value if it is a 1 in the subnet mask. If it is a 0 we do not add it in. The three byte values are easy as they are all 1's we know it will be 255 (this is the maximum value). The last byte value we need to calculate. Only the first three values are 1's, so we need to add 128+64+32=224. We can then write the subnet mask as 255.255.255.224.
Also, with using the CIDR value we can determine the number of hosts we can have in this network. We know that a IPv4 address has 32 bits. We also know that the network portion of our network uses 27 bits. We just need to find the number of bits that differ: 32-27 = 5. This means we have 5-bits to use for hosts. Take this value and plug it in for x:
2x = (# of Hosts)
In our example we'd have: 25 = 32. So, we could have a maximum of 32 IP addresses in this network. Though in reality you'd need to subtract 2 (one for the broadcast address and one for the network address), so we would really have a total of 30 IP addresses for hosts available.