Computer Networks · Module 5 — Network Layer
IPv4 addressing: structure, network and host, classes
MAC addresses are flat. AA:BB:CC:11:22:33 tells you the manufacturer and nothing about where the device is.
Sign in to track your score
192.168.1.42 looks like four random numbers. It is one 32-bit number, cut into four pieces so humans can read it out loud.
Why & what
Why IP addresses exist. MAC addresses are flat. AA:BB:CC:11:22:33 tells you the manufacturer and nothing about where the device is.
To find a machine among billions, an address must say something about location. Otherwise every router on earth would need a list of every device on earth.
So IP addresses are built in two halves.
- The network part: which network this device sits on.
- The host part: which device inside that network.
Routers only need to know how to reach networks. That is what makes the internet possible.
What an IPv4 address is. A 32-bit number, written as four decimal numbers separated by dots. Each part is called an octet: 8 bits, so 0 to 255.
192.168.1.42 is really 11000000 10101000 00000001 00101010.
Where the split falls. That depends on the subnet mask, which is Topic 5.3. For now: in Aisha's network, 192.168.1 is the network part and 42 is the host part.
Classes. Before masks were flexible, the first number decided the split.
| Class | First number | Split | Made for |
|---|---|---|---|
| A | 1–126 | /8 | very large networks |
| B | 128–191 | /16 | medium networks |
| C | 192–223 | /24 | small networks |
| D | 224–239 | none | multicast |
| E | 240–255 | none | experimental |
127 is missing on purpose: 127.0.0.1 is loopback, the address a machine uses to talk to itself. Classes are obsolete. CIDR replaced them, in Topic 5.3. But they are asked about constantly, so learn the table.
How it works
- Every device on a network gets an address whose network part matches everyone else's on that network.
- The host part must be unique within that network.
- Two addresses in every network are reserved: the network address (all host bits 0) and the broadcast address (all host bits 1).
- So Aisha's network 192.168.1.0 cannot use .0 or .255 for a device.
- A router compares the network part of a destination against its table to decide where to send the packet.

Common confusion
Students think the class of an address decides how it is routed today. Actually, classes were abandoned in 1GG3. Nothing on the modern internet routes by class.
They wasted enormous space. A company needing 300 addresses had to take a Class B block of 65,534 and waste the rest. CIDR replaced classes with a flexible mask. The only reason to learn classes is that exam papers and interviewers still ask for the table.
Interview angle
Asked as: "What are the parts of an IP address?" or "Which class does 192.168.1.42 belong to?" Model answer:
An IPv4 address is 32 bits, written as four octets in dotted decimal. It splits into a network part and a host part. Routers forward using the network part, and the host part identifies a specific device inside that network. Historically the first octet decided the split: Class A is 1 to 126 with a /8, Class B is 128 to 191 with /16, Class C is 192 to 223 with /24, and D and E are multicast and experimental. 192.168.1.42 is Class C by that scheme. Classes are obsolete though. CIDR replaced them because they wasted huge blocks. Today the split is set by the subnet mask, not by the first octet.
- 1.
How many bits are in an IPv4 address?
- 2.
Which class does 192.168.1.42 fall in under the old scheme?
- 3.
What is 127.0.0.1 used for?
- 4.
Why do routers care about the network part and not the host part?