IPv4 Addressing and Address Classes

Network Layer · 30 min

Core CS · Computer Networks

Four numbers, thirty-two bits, one line drawn through them

Every subnetting question you will ever be set is this one skill: turn four decimals into 32 bits, find the line the mask draws through them, and read off the network, the broadcast and the host count. Classful addressing is where that line used to be decided by the leading bits of the first octet.

Type any address and watch it come apart, bit by bit
An IPv4 address is 32 bits with a network part on the left and a host part on the right. The address alone never tells you where the split falls. The mask does. Classful addressing was the rule that let the leading bits imply the mask, and that shortcut handed half the internet to 126 organisations.

01 The idea

Thirty-two bits, and the line that cuts them in two

A MAC address names a card. It is flat, it has no parts, and nothing can route on it, which is why the previous lesson had to shout on a single link to find one. An IPv4 address is the opposite kind of number. It is 32 bits, and those bits are split into two fields: a network part on the left saying which network the machine is on, and a host part on the right saying which machine on that network. A router at the far end of a corporate backbone handling a packet for 172.16.94.221 reads only the network part, matches it against its table, and sends the packet onward without knowing or caring that .94.221 exists. That is the entire reason the internet scales: one row in a routing table covers millions of machines.

You never see those 32 bits. You see 172.16.94.221, and the dots are punctuation added for people. The bits are cut into four groups of eight called octets, each printed as a decimal from 0 to 255, because eight bits hold 28 = 256 distinct values and 0 to 255 is how you write them. On the wire the IPv4 header carries the source and destination as 32 bare bits each with nothing between them. So the first thing to learn is the conversion in both directions, and to learn it as a mechanical habit rather than a calculation, because every number later in this module comes out of it.

Now the awkward part. The split between network and host is not visible in the address. 172.16.94.221 could be one machine on a network of 65,534, or one machine on a network of 62, and the digits are identical in both cases. What decides is a second 32-bit number carried alongside, the subnet mask: a 1 bit wherever the address bit belongs to the network, a 0 bit wherever it belongs to the host. The 1s are always contiguous and always start at the left, so a mask is completely described by how many of them there are. 255.255.0.0 and /16 are the same mask written two ways, and you will meet both in the same afternoon.

In 1981, when RFC 791 defined IPv4, carrying a mask around felt wasteful, so the designers made the address imply it. Look at the leading bits of the very first octet. A leading 0 means class A and the mask is /8. A leading 10 means class B and the mask is /16. A leading 110 means class C and the mask is /24. Nothing else about the address is consulted, and no mask needs to be sent anywhere: any machine holding the address can work out where the line falls. That is classful addressing, and it is the reason the first octet ranges are worth memorising.

It is also why classful addressing collapsed. Three sizes is three sizes. Class C gives you 254 usable addresses and class B gives you 65,534, with nothing at all in between, so an organisation with 400 machines had to be handed a class B and leave 65,134 addresses unused. Half the total address space sits in class A, which was carved into only 126 networks. By 1993 the arithmetic had become unsurvivable and classless addressing replaced it, which is the next lesson. Classful is dead on every router on the planet, and it is still asked in interviews and written exams every year, so you need both halves of that sentence.

An IPv4 address is 32 bits with a network part and a host part, and only the mask says where the boundary is. Classful addressing let the leading bits of the first octet imply that mask: 0 gives class A and /8, 10 gives class B and /16, 110 gives class C and /24. Once you know the boundary, everything else is an AND and an OR.
OctetEight bits, printed as a decimal from 0 to 255. Four of them separated by dots is one whole IPv4 address, so an address is 32 bits or 4 bytes. The dots exist only for reading; the header carries 32 bare bits. An octet can never be 256 or higher, which is the fastest way to spot a made-up address.
Subnet maskA second 32-bit number laid over the address. A 1 marks a network bit, a 0 marks a host bit, and the 1s are contiguous starting from the left. Because of that, the count of 1s describes it completely: /16 and 255.255.0.0 are the same mask. The mask is configuration; it is never carried inside the packet.
ClassThe 1981 rule that made the address imply its own mask. The leading bits of octet 1 decide it, and only those bits: 0 is A, 10 is B, 110 is C, 1110 is D for multicast, 1111 is E for reserved. Every other bit of the address is ignored by the classification.

02 Worked example

One address, taken apart bit by bit

One address carries this lesson, the console in section 04 and half the cheat sheet: 172.16.94.221. Nothing here is recalled. Each number below is produced by an operation on bits you can check on paper, and the console reproduces every one of them digit for digit.

Start with the conversion, because everything after it is bit arithmetic. Write the eight place values 128 64 32 16 8 4 2 1 above a row and fill left to right, subtracting when the value fits. Take the last octet, 221: 221 is at least 128, so write 1 and 93 is left; 93 is at least 64, so 1 and 29 left; 29 is under 32, so 0; 29 is at least 16, so 1 and 13 left; then 8 fits leaving 5, then 4 fits leaving 1, then 2 does not, then 1 does. That is 11011101. Going back the other way is addition and nothing else: 128 + 64 + 16 + 8 + 4 + 1 = 221. Do the same for the other three and the whole address is 10101100.00010000.01011110.11011101.

32 bits, four octets172.16.94.221 becomes 10101100. 00010000. 01011110. 11011101. Check the first octet: 128 + 32 + 8 + 4 = 172.
Read the leading bitsOctet 1 starts 1 then 0. The pattern 10 is class B. That is why class B runs 10000000 = 128 to 10111111 = 191.
The class fixes the maskClass B means /16, that is 255.255.0.0, that is 11111111.11111111. 00000000.00000000. 16 network bits, 16 host bits.
AND, then ORAddress AND mask gives 172.16.0.0, the network. Address OR the inverted mask gives 172.16.255.255, the directed broadcast.
What is left is yours172.16.0.1 to 172.16.255.254, and the count is 216 − 2 = 65,534. The two missing ones are the two above.

The highlighted node is the one to slow down on, because it is the only step in the chain that classful addressing performs for free and classless addressing refuses to. Everything to its left is arithmetic on the address itself and is true forever. Everything to its right depends entirely on where the line was placed. Move that line and every remaining number changes: the same 172.16.94.221 on a /26 has a network address of 172.16.94.192, a broadcast of 172.16.94.255 and 62 usable hosts, and not one digit of the address changed.

Now the two operations, written out so there is nothing to take on trust. The mask is /16, so the first sixteen mask bits are 1 and the last sixteen are 0. AND gives 1 only where both inputs are 1, so every network bit survives unchanged and every host bit is forced to 0:

10101100.00010000.01011110.11011101  the address
11111111.11111111.00000000.00000000  the mask
10101100.00010000.00000000.00000000  = 172.16.0.0, the network address

The broadcast is the mirror image. Invert the mask so its host positions are 1, then OR, which gives 1 wherever either input is 1. Network bits pass through untouched because they are ORed with 0, and every host bit is forced to 1:

10101100.00010000.01011110.11011101  the address
00000000.00000000.11111111.11111111  the inverted mask
10101100.00010000.11111111.11111111  = 172.16.255.255, the directed broadcast

Those two results are the endpoints of the block, and neither of them can be typed into a machine. Add one to the first and subtract one from the second and you get the usable range: 172.16.0.1 through 172.16.255.254, since 00000001 is 1 and 11111110 is 254. Counting them is where 2h − 2 comes from, and it is worth deriving once rather than memorising. There are 16 host bits, so the host field can take 216 = 65,536 different patterns. Exactly two of those patterns are spoken for: all zeros names the network itself, all ones is the broadcast for it. Take those two away and 65,534 patterns are left for actual machines. Nothing about the number 2 is magic; it is one address at each end of the block.

Hold on to the shape of that, because the rest of the module is this same procedure with the line in a different place. Convert, find the boundary, AND for the network, OR for the broadcast, subtract two for the count. Classful addressing is the special case where the boundary is always at bit 8, 16 or 24 and the address tells you which.

03 Mechanics

Five classes, and the addresses that are not hosts

Two tables carry this section. The first is the class scheme itself, with every count derived rather than quoted. The second is the set of addresses that look like ordinary hosts and are not, which is where most marks are actually lost.

ClassLeading bitsFirst octetDefault maskNet / host bitsNetworks in the classUsable hosts each
A0 1 to 126 /8 = 255.0.0.0 8 / 24 126 — 27 = 128, minus 0 and 127 16,777,214 = 224 − 2
B10 128 to 191 /16 = 255.255.0.0 16 / 16 16,384 = 214 65,534 = 216 − 2
C110 192 to 223 /24 = 255.255.255.0 24 / 8 2,097,152 = 221 254 = 28 − 2
D1110 224 to 239 none none Multicast, the block 224.0.0.0/4. 228 group addresses, not networks. not applicable
E1111 240 to 255 none none Reserved by RFC 1112 for future use, the block 240.0.0.0/4. Never allocated. not applicable

Where those network counts come from, since guessing them is the classic slip. Class A has eight network bits, but the leading one is pinned at 0 by the definition of the class, so only seven are free: 2⁷ = 128 possible network numbers. Two are then removed. 0.0.0.0/8 is reserved to mean “this network” and 127.0.0.0/8 is the loopback block, so 128 − 2 = 126 and the usable first octets run 1 to 126 rather than 0 to 127. Class B pins two bits, leaving fourteen free: 2¹⁴ = 16,384, with nothing carved out. Class C pins three, leaving twenty-one: 2²¹ = 2,097,152. Answering “128 class A networks” is the standard mistake and it is one subtraction away from correct.

How the address space was actually divided, which is the whole argument of the next lesson. Class A is every address whose top bit is 0, so it is 2³¹ = 2,147,483,648 addresses out of a total of 2³² = 4,294,967,296. That is exactly half the internet, split among 126 organisations. Class B takes 230, a quarter. Class C takes 229, an eighth. Class D and class E take 228 each, 6.25% apiece. Those shares sum to 50 + 25 + 12.5 + 6.25 + 6.25 = 100, which is a useful check that you have the leading-bit patterns right. Now put a real organisation into that scheme. A company with 400 machines cannot use class C, because 254 usable addresses is not 400. So it is given a class B and uses 400 of 65,534, wasting 65,134 addresses that no one else can ever touch. There was no size in between, and no way to say “give me 512”, because the leading bits of the first octet were the only thing allowed to decide.

The second table is the one that actually costs marks. Every row is an address that parses like a host address and is not one.

AddressWhat it meansAssignable to an interface?Where you meet it
Host bits all zero
172.16.0.0
Names the network itself, not any machine on it. no Routing tables. “Route to 172.16.0.0/16” means the whole block.
Host bits all one
172.16.255.255
The directed broadcast for that one network. Every host on it receives the packet. no The second of the two addresses that the − 2 removes.
0.0.0.0 “This host on this network” as a source. “Any address” as a bind target. “Everything” as a route. no Source address of a DHCP DISCOVER; the wildcard a server binds to; the default route 0.0.0.0/0.
127.0.0.1 Loopback. The whole of 127.0.0.0/8 is reserved by RFC 1122 and looped back inside the host. already bound ping 127.0.0.1, the name localhost, and every service you test before deploying it.
255.255.255.255 Limited broadcast. Every host on this link and no further. A router never forwards it. no Destination of a DHCP DISCOVER, sent from UDP port 68 to port 67 before the client has any address at all.
169.254.0.0/16 Link-local, defined by RFC 3927. A host picks one for itself when DHCP does not answer. self-assigned Windows calls it APIPA. Seeing 169.254.x.x means DHCP failed, every time.
RFC 1918 private
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
Usable addresses that no router on the public internet will carry. yes Every home and office LAN on earth, behind NAT.

The private ranges, written out exactly, because two of the three get misquoted. 10.0.0.0/8 runs from 10.0.0.0 to 10.255.255.255: one whole class A network, 224 = 16,777,216 addresses. 192.168.0.0/16 runs from 192.168.0.0 to 192.168.255.255: 256 consecutive class C networks, 216 = 65,536 addresses. The one people get wrong is 172.16.0.0/12. The prefix is /12, not /16, so the mask covers the first octet and the top four bits of the second. Write them out: 172 is 10101100, and the second octet ranges over 0001 followed by any four bits, which is 00010000 = 16 up to 00011111 = 31. So the block runs 172.16.0.0 to 172.31.255.255, sixteen consecutive class B networks, 220 = 1,048,576 addresses. It does not stop at 172.16.255.255 and it does not reach 172.32.anything, and both of those are common enough to be worth writing on your hand.

Two broadcasts, and the difference the exam wants. A directed broadcast is the all-ones host part of a specific network, like 172.16.255.255. It names a real network, so a router elsewhere on the internet can in principle forward it as ordinary unicast and have the last router turn it into a link broadcast. That is exactly how the smurf amplification attack worked, so RFC 2644 changed the default in 1999 and routers have shipped with directed-broadcast forwarding disabled ever since. A limited broadcast, 255.255.255.255, names no network at all; it is scoped to the link by definition and the first router drops it. That is why a DHCP client, which has no address and no idea what network it is on, has to use the limited one.

Where the textbook and the deployed network part company. Teach yourself the classful rules, then hold two corrections next to them. First, 2ᵘ − 2 assumes both the all-zeros and all-ones patterns are unusable, which stops being sensible on a two-address point-to-point link where it leaves zero: RFC 3021 allows a /31 with both addresses usable, and router-to-router links are configured that way routinely. Second, no router has inferred a mask from the leading bits since CIDR arrived in 1993; a modern box is told the prefix length explicitly and would happily run 10.0.0.0/23 even though 10 is “a class A”. Class identification survives because it is a fast, cheap way to test whether you can convert to binary and reason about a boundary, and because the vocabulary stuck: people still say “a class C” when they mean a /24. Know it, and know that it decides nothing.

05 Cheat sheet

Thirteen answers to have ready

Every row is something you can be asked to state or compute in under ten seconds. The right-hand column is the specific wrong answer that gets given, not a general caution.

What they askThe answerThe trap
Size of an IPv4 address32 bits = 4 bytes = 4 octetssaying 48 bits — that is a MAC address, from the previous lesson
Leading bits, by class0 = A, 10 = B, 110 = C, 1110 = D, 1111 = EMemorising the decimal ranges only. The bits generate the ranges, so the bits are the cheaper thing to hold.
First-octet rangesA 1–126, B 128–191, C 192–223, D 224–239, E 240–255saying class A is 1–127 — 127 is the loopback block, not a usable network
Default masksA /8, B /16, C /24Offering a mask for class D or E. Neither has a network/host split, so neither has a mask.
Networks per classA 126, B 16,384, C 2,097,152saying 128 for class A — the leading bit is pinned, then 0 and 127 are removed
Usable hosts per networkA 16,777,214, B 65,534, C 254quoting 2ᵘ and forgetting the − 2
Where − 2 comes fromall-zeros host = network address; all-ones host = directed broadcastSaying “one is for the router”. A gateway holds an ordinary host address like everything else.
Two ways to write a mask/16 and 255.255.0.0 are the same numberTreating the prefix length as a count of octets. It counts bits, so /24 is three octets of ones.
0.0.0.0this host as a source; any address as a bind; everything as a routecalling it a broadcast
127.0.0.1loopback; the whole 127.0.0.0/8 is reservedCalling it a usable class A network. It costs 16,777,216 addresses and carries one function.
255.255.255.255limited broadcast, this link only, never forwardedconfusing it with the directed broadcast, which names a specific network and can be routed
Private ranges, RFC 191810.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16writing 172.16.0.0/16 — the block is /12 and ends at 172.31.255.255
An address starting 169.254link-local, RFC 3927: DHCP did not answerTrying to route it. It is valid on the local link only, and it is a symptom, not a configuration.
The mask draws the line, not the addressThe same 32 bits mean different networks under different masks. An address quoted without a prefix length is an incomplete answer, and the classful default is only a guess at what the prefix might have been.
2h − 2, never 2hThe all-zeros host pattern names the network and the all-ones pattern is its broadcast. Neither can be configured on an interface, so a /24 gives 254 and not 256. The one documented exception is a /31 point-to-point link under RFC 3021.
Read the bits, then the decimalEvery class boundary is a bit pattern that happens to land on a decimal. If you forget that class B ends at 191, rebuild it: 10 followed by six ones is 10111111, which is 128 + 63 = 191.

06 Where & why

Where these numbers show up on a real machine

None of this is a teaching abstraction. Every number below is printed by a command you can run, or documented by a provider you will deploy on, and each one shows a place where the real system agrees with the textbook or deliberately does not.

Linux · ip route
The prefix length is right there in the output

ip addr show prints an interface as inet 172.16.94.221/16, address and mask in one token, because they are useless apart. ip route prints default via 172.16.0.1 alongside a line for 172.16.0.0/16, and the kernel derived that second line by ANDing the address with the mask exactly as you did on paper. The default route is stored as 0.0.0.0/0: a zero-length prefix, so no bits have to match and every destination hits it. That is why it is always the last resort in a longest-prefix match.

AWS VPC
The real subnet gives 251 hosts, not 254

You create a VPC by choosing an RFC 1918 block, typically something like 10.0.0.0/16, and cut /24 subnets out of it. AWS then reserves five addresses in every subnet rather than two: the network address, the VPC router, the DNS resolver, one held for future use, and the broadcast address, which AWS reserves even though it does not support broadcast at all. So a /24 that the textbook says holds 254 usable addresses holds 251 in a VPC. The − 2 is the protocol floor; a provider may take more, never fewer.

Windows · ipconfig
169.254 is a diagnosis, not a setting

Run ipconfig /all on a machine with no internet and you will sometimes see an IPv4 address of 169.254.x.y with mask 255.255.0.0 and no default gateway. Nobody configured that. The host broadcast a DHCP DISCOVER from 0.0.0.0 to 255.255.255.255, got no reply, and fell back to picking a link-local address for itself under RFC 3927. The missing gateway is the giveaway: the machine can reach its own link and nothing beyond it.

Google Public DNS 8.8.8.8
A class A block that stopped behaving like one

Read the first octet: 8 is 00001000, leading bit 0, so classful rules call it class A with a /8 mask. And 8.0.0.0/8 genuinely was handed out as a single class A allocation, sixteen million addresses to one holder, which is the waste from section 03 in one line. Today the internet does not treat it as one network at all: 8.8.8.0/24 is announced separately by Google. The class still tells you how to read the bits. It has told you nothing about the routing since 1993.

Two sentences to be able to defend on the spot. The address is 32 bits and the mask is the only thing that says where the network part ends, which is why the same address on a different mask is a different network with a different broadcast and a different host count. Classful addressing let the leading bits imply that mask, and three fixed sizes could not fit real organisations, which is the problem classless addressing was invented to solve and the subject of the next lesson.

07 Interview questions

What they ask, and what they follow up with

This topic is asked early because it is cheap to mark and impossible to bluff. Expect an address on a whiteboard, a request for the class, and then a follow-up that changes the mask to see whether you were reading bits or reciting ranges.

What is an IPv4 address, physically? How many bits, and why is it written the way it is?
It is 32 bits, four bytes, carried as 32 bare bits in the IPv4 header with nothing separating them. Dotted decimal is a convention for humans: cut the 32 bits into four groups of eight, print each group as a decimal, and separate them with dots. Eight bits hold 256 values, which is why every octet lands between 0 and 255, and an address with a 256 in it is invalid on sight. The octet boundary also happens to be where the classful splits fall, which is why the old scheme reads so neatly in decimal.
An IPv4 address has two parts. What are they, and what decides where the boundary is?
A network part on the left and a host part on the right. The mask decides the boundary and nothing else does: a 1 bit in the mask marks a network bit, a 0 marks a host bit, and the 1s are contiguous starting from the left, so the count of them describes the mask completely. That is why /16 and 255.255.0.0 are the same thing. The address on its own is ambiguous, which is why a bare address quoted without a prefix is an incomplete answer.
Give me the five classes with their leading bits and first-octet ranges.
Leading 0 is class A, 1 to 126. 10 is class B, 128 to 191. 110 is class C, 192 to 223. 1110 is class D, 224 to 239, multicast. 1111 is class E, 240 to 255, reserved. Learn the bits rather than the decimals, because the bits regenerate the decimals: if you blank on where class C ends, write 110 followed by five ones, which is 11011111, and that is 223. Going the other way round only works if your memory holds.
Why does class A have 126 networks and not 128?
The class pins the leading bit at 0, so only seven of the eight network bits are free, giving 2⁷ = 128 possible network numbers. Two of them are then removed: 0.0.0.0/8 is reserved to mean "this network" and 127.0.0.0/8 is the loopback block. 128 − 2 = 126, and that is why the usable first octets run 1 to 126. Classes B and C lose nothing equivalent, so their counts are the plain powers 2¹⁴ and 2²¹.
Where does 2ᵘ − 2 come from? Derive it rather than quoting it.
With h host bits the host field can hold 2ᵘ distinct bit patterns. Exactly two of them are not available to a machine: all zeros names the network itself, and all ones is the directed broadcast for that network. Neither can be configured on an interface, so 2ᵘ − 2 remain. A class B network has 16 host bits, so 65,536 − 2 = 65,534. The formula also shows its own limit: a /31 would give zero usable addresses, which is why RFC 3021 had to carve out an explicit exception for point-to-point links.
Tell me what 0.0.0.0, 127.0.0.1 and 255.255.255.255 each mean.
0.0.0.0 means "this host on this network" and is legal only as a source, which is how a DHCP DISCOVER leaves a machine that has no address yet; it doubles as the wildcard a server binds to for every interface, and as 0.0.0.0/0 it is the default route. 127.0.0.1 is loopback, and the whole 127.0.0.0/8 is reserved: the kernel turns the packet round internally and it never reaches a network card. 255.255.255.255 is the limited broadcast, delivered to every host on the local link and never forwarded by a router. None of the three can be configured on an interface.
What are the private address ranges, exactly?
RFC 1918 defines three: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Written as ranges that is 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255, and 192.168.0.0 to 192.168.255.255. The middle one is the one that gets misquoted, because the prefix is /12 rather than /16, so the second octet runs 16 to 31 and the block is sixteen consecutive class B networks. No router on the public internet carries any of them, so a packet from one needs NAT to get out.
A router receives a packet addressed to 172.16.255.255. What happens to it?
That is the directed broadcast for 172.16.0.0/16, and the textbook answer and the deployed answer differ. In principle a router forwards it as ordinary unicast until it reaches the last hop for that network, which then broadcasts it onto the link. Because that made the smurf amplification attack trivial, RFC 2644 changed the default in 1999 and routers have shipped with directed-broadcast forwarding disabled ever since, so in practice it is dropped. Contrast 255.255.255.255, which the first router always drops, because it names no network and there is nowhere to forward it to.
Same address, two different masks. Does anything actually change?
Everything except the address does. Take 172.16.94.221: on the classful /16 the network is 172.16.0.0, the broadcast is 172.16.255.255 and there are 65,534 usable hosts. Put the same address on a /26 and the network becomes 172.16.94.192, the broadcast becomes 172.16.94.255, and there are 62 usable hosts. Not one digit of the address moved. That is the single most useful thing to be able to say about masks, and it is why an address is always quoted with a prefix length in real work.
Classful addressing is obsolete. Why are you still being asked about it?
Honestly, because the vocabulary outlived the rules. Every router on the internet has been classless since CIDR arrived in 1993, and no modern box infers a mask from the leading bits; it is told a prefix length explicitly and will happily run 10.0.0.0/23. But people still say "a class C" when they mean a /24, the first-octet ranges still tell you at a glance whether an address is likely private, and class identification is a cheap way for an examiner to check you can convert to binary and reason about a boundary. Answer with both halves: the rules, and the fact that they decide nothing today.
How does an IPv6 address differ from this, structurally?
It is 128 bits rather than 32, written as eight groups of four hex digits separated by colons rather than four decimals separated by dots, which is why 2³² is about 4.3 billion addresses and IPv6 is a number with 39 digits. The network and host split survives as a prefix length, so /64 reads exactly like /24 does here. Two things do not survive: IPv6 has no classes and never did, and it has no broadcast address at all, with multicast groups doing that job instead. So there is no equivalent of the − 2 in an IPv6 subnet.

08 Practice problems

Six to work out on paper

Write the place values 128 64 32 16 8 4 2 1 at the top of the page and keep them there. For every problem, convert before you reason, and never let a decimal answer influence a binary one. Two of these turn entirely on doing the AND column by column instead of guessing at the dotted decimal.

Both directions, by hand

Easy
Convert 200.35.7.140 into 32 binary bits, and convert 10101011.00000001.00000010.00000011 back into dotted decimal. Then give the class of each of the two addresses.
Follow-up
The two addresses are in different classes, and you can settle that half of the question from three bits each without converting a single one of the remaining 29. Doing the full conversion first and only then looking at the class is the slow route, and it is the one most people take.
Show the hint
Write the place values 128 64 32 16 8 4 2 1 above each octet and fill left to right, subtracting whenever the value fits; going the other way is pure addition of the place values that carry a 1.

The boundary in binary

Easy
Write only the first octet of each of these in binary and give the class: 63, 128, 191, 192, 239. Then count how many distinct first-octet values belong to each of the five classes by bit pattern, before any reservation is taken out, and check that your five counts add to 256.
Follow-up
Two of the five are adjacent decimals that land in different classes. The binary shows that the boundary sits exactly where it does because of a carry, not because anyone chose a round decimal number, and that is the reason the ranges look so arbitrary written out in base ten.
Show the hint
A class pins a fixed number of leading bits, so the values it can take come from the bits left free in that octet: count the free bits and raise 2 to that number.

The full derivation

Medium
For 198.51.100.77 under its default classful mask, give: the full address in binary, the mask in both binary and dotted decimal, the network address, the directed broadcast, the first and last usable host, and the usable host count. Show the AND column by column.
Follow-up
Two of the seven values you produce are addresses that no interface may ever carry. Naming both and saying why is the whole of the − 2, and a student who writes the count without being able to point at the two missing addresses has memorised a formula rather than understood a block.
Show the hint
Do the AND on the binary rather than reasoning about the decimal; the mask’s zero bits are exactly the bits you are permitted to change, and the broadcast is what happens when you set all of them.

A prefix that agrees by accident

Medium
The link-local block is 169.254.0.0/16. Give its first and last address and the number of addresses it contains. Separately, work out the class of 169.254.0.0 from its leading bits alone and state the default mask that class would have handed it. Then say whether the two masks agree.
Follow-up
The /16 written on the block and the /16 the class would have supplied are the same number arriving from two completely unrelated directions. A student who cannot separate the two reasons will assume every block’s prefix equals its class default, and exactly one of the two numbers still means anything after the next lesson.
Show the hint
Answer the two halves independently and do not let either influence the other: the class comes from the first octet’s leading bits, the extent comes from the /16 and nothing else.

Same network or not

Medium
A machine is configured 10.5.0.9 with its default classful mask. For each of the destinations 10.200.1.1, 11.5.0.9 and 172.16.94.221, do the AND in binary and say whether the destination is on the machine’s own network. Then say which mask you used for each AND, and why.
Follow-up
One of the three destinations differs from the machine’s own address by a single bit out of all 32 and still lands on a different network, while another differs in three octets and does not. A third is in a different class from the sender, which raises the real question: when the sender tests whether a destination is local, whose mask does it apply?
Show the hint
Work the third destination both ways, once with the sender’s mask and once with its own class default, and note whether the verdict changes; then work out what would have to be true for it to change.

The arithmetic that killed classful addressing

Hard
In 1990, under strict classful allocation with no subnetting, a company needs addresses for 700 hosts on one network. Say which class it must be given and why the smaller class will not do. Compute exactly how many addresses in that allocation it can never use, and express that as a percentage of the allocation to one decimal place. Finally, compute how many such companies it would take to exhaust the entire class B space, and compare that with the number of class B networks that exist.
Follow-up
The percentage is the number that ended classful addressing, and the fix was not to find more addresses. It was to stop letting the leading bits of an address decide where the boundary falls, which is exactly what the next lesson is about.
Show the hint
Work out the usable count for both candidate classes before choosing one, keep the count of networks in a class separate from the count of hosts in a network, and remember that the network count is fixed by how many bits are left after the leading pattern is spent.