Support This Site burning void logo
 
Blogs:
Reviews
Site Blog
Writers' Exercises
Engineering Ardor
 
Resources:
Roleplaying
Writing
Cooking
Computers
Links
 
Cafepress Shops:
Stuff for Gamers
Caffeinated Chicanery
 
Admin:
Home
About Us
Contact Us
Twilight Time list
Site Update list

Sponsors:


(Your Link Here)
 
Text Link Ads
 
 
Search Now:
In Association with Amazon.com
 
 

Home --> IAQ -->

Class A, B, and C Networks and CIDR

By Jeffrey Howard
All rights reserved unless noted otherwise

 

On a mailing list I read, someone asked to what class (as in class A, class B, or class C) an address belonged and what determined the network class. The Internet has been moving towards classless addressing network since CIDR (Classless Inter-Domain Routing) was adopted, but classes still keep rearing their ugly heads to confuse people. Let me try to explain.

Network Classes

IP addresses consist of a 32-bit number. This refers to IPv4, of course. IPv6 has a much larger address space. Since the Internet is a large network composed of smaller networks, it makes sense that this address space is broken down into smaller chunks. Network classes were the mechanism that broke down the address space.

Class A networks have network addresses from 1.0.0.0 through 127.0.0.0. The network number is the first octet, being from 1 to 127. That number uniquely identifies the class A destination network. The rest of the address, 3 octets, uniquely identifies a machine within that network.

Class B networks have addresses from 128.0.0.0 through 191.255.0.0. The network number is the first two octets, being from 128.0 through 191.255. The number uniquely identifies which class B network is the destination of the packet. The rest of the address, uniquely identifies a machine on that network.

Class C networks have addresses from 192.0.0.0 through 223.255.255.0. The network number is the first three octets, being from 192.0.0 through 223.255.255. Each class C network can have one octet worth of hosts.

Class D networks have addresses from 224.0.0.0 to 239.255.255.255. Class D network addresses are used for multicast protocols.

Class E networks have addresses from 240.0.0.0 to 255.255.255.255. Class E networks are reserved for future use.

To get an address of one of these classes, one would fill out an application form justifying the need for a network of a certain size. Upon approval, the network addresses would be allocated.

Subnetting

Obviously, an organization with a class A network isn't going to try to plug nearly a million and a half computers into the same piece of wire, hanging off of the same router, and cheerfully assume that everything will work. Organizations split up their internal networks using subnetting. Subnets take some of the bits that represent hosts in a network class and use them to represent a subnet instead.

For example, consider a class C network that, for some reason, really ought to be treated as though it were composed of 64 networks with two machines each. This might be useful for a farm of machines that answer modems and form PPP connections. One would use the first 24 bits of the network address to indicate the class C network address. The next 6 bits would be used to indicate the subnet. Each subnet consists of two machines, so the last two bits are used to indicate which machine on on the subnet is the destination. (If it seems odd that two bits are used to represent two machines, remember that the 00 is the network number (often used for broadcast) and 11 is used for broadcast. Thus 01 and 10 are the two machines on the network.

In our example, the rest of the world will only take note of the fact that it's a class C network and route to that network accordingly. Other machines don't have to be concerned with how the network is subnetted. Subnetting is purely internal. This means that no amount of subnetting can change the class of a network address. If the first octet is between 1 and 127, then the network address is a class A address, no matter what subnet it may be on.

However, note also the interesting side effect of subnetting. A class C network usually has 254 addresses that can be used for end hosts. By subnetting it into 64 subnets that each have 4 addresses, but only two machines, we've lost the use of a great number of IP addresses.

What Went Wrong?

Now that class A, B, and C networks are demystified, allow me to explain why network address classes are no longer used. That's right. Everything above about what class a network belongs to is outdated. I still see questions about network address classes, and there are a great number of tutorials and books on TCP/IP that still teach addressing in terms of network classes. But that simply isn't the direction things are going. Classes are legacy terminology hanging around to confuse the unwary.

Network address classes failed to scale up with the size of the Internet. There were two problems with them. The first, and by far less significant problem is that network address classes are not an efficient way to allocate IP addresses. An organization with 12 machines really doesn't need a class C network. However, if they didn't have an umbrella organization that could subnet its network as needed, then they grabbed a class C and let the unused addresses go to waste.

As demonstrated by IPv6, doubling the length of the address field can solve inefficient address allocation handily. There was a more pressing issue. Class A networks were far too large for anyone to justify needing the space, so most of the class A networks went unallocated. Class C networks were too small for most organizations. The most commonly requested size of network was the class B network, so much so that there weren't enough to go around. When that happened, the authority responsible for allocation started forcing smaller organizations to apply for several class C networks rather than a class B network.

Why was this a problem? Well, each new network had to be routed individually. Towards the edges of the network, this is no big deal. Everyone has an upstream gatway that they label as the default gatway. After all, if you have a cable modem or a DSL link, where would you send packets other than upstream to your ISP? But at the backbone of the network, large ISP's route between each other. In the days of class-based routing, these ISP's had to keep track of every class A, B, and C network individually and route appropriately. At the worst of the problem, some backbone routers kept track of more than ten thousand entries.

CIDR (Classless Inter-Domain Routing)

The solution was to move to CIDR (Classless Inter-Domain Routing). CIDR called not only for technical changes, but for a reorganization of how address space is granted to applicants. The idea behind CIDR is identical to that of subnetting. If one knows the path to a network, one shouldn't have to worry aobut the subnets; subnets are an internal matter. Now, instead of having a class, network addresses are coupled with a 32-bit mask that indicates how many bits are considered to be part of the network address.

There is a double advantage of CIDR style addressing. First, networks can be allocated to any size, avoiding some address space waste. For example, this web page is currently served from the network 140.186.123.192/27. The /27 indicates that the first 27 bits indicate the network. This means that our network has 32 addresses, 30 of which are usable for machines. That's smaller than a class C network, but we don't need the extra addresses. A class C network would read xxx.xxx.xxx.yyy/24, indicating that the first 24 bits (first three octets, the x's) are the network address on which to route.

The real advantage goes as network sizes scale up. CIDR addresses can be aggregated into supernetworks as well as split into subnets. For instance, imagine a network that was composed of 8 class C networks. In CIDR, it could be a single network address with a /21 network mask. How routing is handled inside that /21 network is irrelevant to routers sending packets towards that network. This only works if the class C networks are consecutively numbered. This should make sense; if the networks are not consecutively numbered, then one cannot construct a mask that includes only those networks and no others. CIDR is thus a tremendous advantage in the backbone. Instead of routing tables listing the 8 class C networks in the example above, each router need list only the aggregated network with a /21 netmask.

Because the network numbers must be consecutive, handing out random blocks of class C size is insufficient. Continuing with the example above of a network that could fill 8 class C networks, a social mechanism must be in place to ensure that network addresses are handed out in an aggregable fashion. To accomplish this, supernet blocks are handed out to ISPs. Since the entire supernet block is routed to that one ISP, the load on backbone routers is relived. ISPs are then responsible for breaking up their supernet into subnets for their customers. To reduce the strain on their own routers, ISPs have incentive to make the IP address allocations as aggregable as possible.

CIDR is called classless because network classes are no longer used for routing. Now, a mask along the entire length of the 32-bit IP address yields the network number. This has the advantage of allowing networks to aggregate into supernets, lightening the load on backbone routers with large routing tables.

Since network numbers were not originally handed out with aggregation into supernets in mind, how are legacy networks handled? The migration path from classful routing to classes routing is simply to turn all class A networks into /8 CIDR table entries, class B into /16, and class C into /24. That allows existing networks to migrate into CIDR routing without renumbering the networks. While this page presents CIDR as the de facto state of the world, and class based routing as a historical artifact, to the best of my knowledge, the migration is not complete. Renumbering a large network is a significant undertaking.

But if you are just starting now, please think of your network in terms of a network mask and CIDR, rather than a class of network.

jhoward@burningvoid.com

 
 
Google
 
Web burningvoid.com

This information is provided "as is," with no warranty or guaranty. The IAQ pages have not been maintained in some time; they're being kept up because, judging by the traffic and link-backs, people still find them useful.
Copyright 1998-2004 by Jeffrey Howard and Heather Grove, except where stated otherwise.