5.1IPv4 addresses and classes
The idea
An IPv4 address is 32 bits written as four decimal bytes. In the classful scheme the first octet tells the class: A 0 to 127, B 128 to 191, C 192 to 223, D (multicast) 224 to 239, E 240 to 255.
Think of it like this: A phone number with an area code (network) and a local number (host); the class tells you where the split is.
Why it exists
Questions ask for the number of networks or hosts in a class and for special addresses.
How it works
- Class A: 8 network bits, 24 host bits. Class B: 16 and 16. Class C: 24 and 8.
- Hosts per network = 2host bits − 2 (all-zeros is the network, all-ones is the broadcast).
- Number of networks: A 27, B 214, C 221 (the leading class bits are fixed).
- Private ranges: 10/8, 172.16/12, 192.168/16; 127/8 is loopback.
Worked example: How many networks can class C have?
24 network bits minus the 3 fixed leading bits (110) = 21 bits: 221 (GATE 2012).
Now play with it
- →Type 135.46.57.14 with /16 in the subnet lab and read the class.
- →Change the first octet and see the class change.
| Class | First octet | Default mask | Networks | Hosts per network | Use |
|---|---|---|---|---|---|
| A | 0 to 127 | /8 | 2^7 = 128 (126 usable) | 2^24 − 2 | very large networks |
| B | 128 to 191 | /16 | 2^14 | 2^16 − 2 | medium |
| C | 192 to 223 | /24 | 2^21 | 254 | small |
| D | 224 to 239 | - | - | - | multicast |
| E | 240 to 255 | - | - | - | reserved |
Special: 127.0.0.0/8 loopback, 255.255.255.255 limited broadcast, 10/8, 172.16/12 and 192.168/16 private.
Network bits (16) and host bits (16)
Network address = address AND mask. Broadcast = network with all host bits set to 1. Usable hosts = 232 − n − 2.
Check yourself
The address 150.10.5.2 is in class
Exam notes (the dense version)
An IPv4 address is 32 bits. Classful ranges by the first octet: A 0 to 127 (/8, 2²⁴ − 2 hosts), B 128 to 191 (/16), C 192 to 223 (/24, 254 hosts), D 224 to 239 (multicast), E 240 to 255. Number of networks: A 2⁷ (126 usable), B 2¹⁴, C 2²¹. Special: 127.x.x.x loopback, all-ones = limited broadcast, 0.0.0.0 "this host", and private ranges 10/8, 172.16/12, 192.168/16. Each block loses 2 addresses (network and broadcast) for hosts.
Previous year questions: IP Addressing & Network Layer (26)
PYQs are grouped by topic, so this is the full set for IP Addressing & Network Layer; try the ones that match this subtopic. Open all 26 on the topic page.