Sub topic 1
IPv4 Addresses: Structure and Notation
Prerequisites
Assume you can convert between binary and decimal, and you know that hosts, routers, and packets operate at different network layers. You should also understand that an IPv4 address identifies a network-layer interface.
IPv4 address structure
An IPv4 address is a 32-bit value. It is normally written as four decimal octets separated by dots. Each octet contains 8 bits and therefore ranges from 0 through 255.
For example:
192.168.10.25Its binary form is:
11000000.10101000.00001010.00011001The address has two logical parts:
- The network part identifies the IP network.
- The host part identifies an interface within that network.
The boundary between these parts is specified by a subnet mask or a prefix length. In 192.168.10.25/24, /24 means that the first 24 bits are the network part and the final 8 bits are the host part.
For a /24 network:
- Network address:
192.168.10.0 - Usable host range:
192.168.10.1through192.168.10.254 - Broadcast address:
192.168.10.255
The network address identifies the subnet itself. The broadcast address reaches all hosts on that subnet. In the usual host-count formula, a subnet with h host bits has 2^h - 2 usable host addresses. The two excluded values are the network and broadcast addresses.
This Python example confirms the address components:
import ipaddress
interface = ipaddress.ip_interface("192.168.10.25/24")
print("address:", interface.ip)
print("network:", interface.network.network_address)
print("broadcast:", interface.network.broadcast_address)
print("usable hosts:", interface.network.num_addresses - 2)Classful addressing and why it was replaced
Before CIDR, IPv4 used fixed classes. The class determined the default network boundary.
| Class | First-octet range | Default prefix | Typical use |
|---|---|---|---|
| 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 |
Class A, B, and C were unicast classes. Class D was reserved for multicast, and Class E was reserved for experiments. 127.0.0.0/8 is reserved for loopback, so it is not a normal Class A network.
Classful allocation wasted addresses. An organization needing 300 host addresses could not use one Class C network, which supports only 254 hosts, but a Class B allocation provided over 65,000 addresses. CIDR replaced fixed classes with a flexible prefix length, allowing allocation to match actual requirements and enabling route aggregation.
Exercise
For 172.16.5.130/16, identify the network address, broadcast address, and number of usable host addresses.
Show answer
Network address: 172.16.0.0; broadcast address: 172.16.255.255; usable hosts: 2^16 - 2 = 65,534.