09 Oct 2017
Internet 101: CIDR
This article assumes the reader has basic knowledge of IP.
IP defines the IP address, and the packets that are sent across networks. However, it doesn’t state how the packets are routed. What happens when a packet arrives at a router? The only information the router has is the destination address. If it isn’t directly connected to the machine hosting this address, how will it know where to send the packet?
The answer to this question is complex, but it begins with Classless Inter-Domain Routing. CIDR is the modern way of allocating IP addresses. An IP address is split into two contiguous groups of bits. The most significant group is called the network prefix, while the other identifies the host. In CIDR notation, this is expressed using a slash and a number, which specifies the number of bits in the network mask.
For example, 192.168.1.0/24 represents a contiguous block of IPv4 addresses from 192.168.1.0 to 192.168.1.255. Suppose all these addresses live on one network, serviced by router A. Router B connects to A, and knows that A services this block. It therefore needs only one entry in its routing table—a mapping from 192.168.1.0/24 to A. This entry will match all packets destined for a host on A’s local network. Essentially, CIDR allows for fine-grained aggregation of routing prefixes.
IP addresses are allocated according to this method. The IANA allocates a short prefix to a regional internet registry, which then allocates slightly longer prefixes to local internet registries. These then allocate still longer prefixes to ISPs and large companies, and so on. As long as IP addresses are allocated roughly in accordance to the geographic topology of the internet, this greatly reduces the size of routing tables. In practice, however, this is not enforced.
IPv4 address exhaustion has resulted in accelerated fragmentation of IPv4 space, and fragmentation leads to more complex routing. The size of the global internet routing table has been growing steadily as a result. This can be a problem for internet facing routers, which need to store the entire table and use it to forward packets.
The IPv6 table is also growing quickly, but this is mostly due to increased IPv6 adoption. It is unlikely to reach the same size as IPv4 thanks to improved allocation.
 Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan. RFC 4632, 2006. https://tools.ietf.org/html/rfc4632