← 🌐 IP Addressing & Network Layer
Subtopic 1 of 5

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

  1. Class A: 8 network bits, 24 host bits. Class B: 16 and 16. Class C: 24 and 8.
  2. Hosts per network = 2host bits − 2 (all-zeros is the network, all-ones is the broadcast).
  3. Number of networks: A 27, B 214, C 221 (the leading class bits are fixed).
  4. 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.
ClassFirst octetDefault maskNetworksHosts per networkUse
A0 to 127/82^7 = 128 (126 usable)2^24 − 2very large networks
B128 to 191/162^142^16 − 2medium
C192 to 223/242^21254small
D224 to 239---multicast
E240 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.

10000111 .00101110 .00111001 .00001110

Network bits (16) and host bits (16)

Class (if classful)B
Subnet mask255.255.0.0
Network address135.46.0.0
Broadcast address135.46.255.255
First usable host135.46.0.1
Last usable host135.46.255.254
Addresses in block65536
Usable hosts65534

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

Remember: Class by first octet. Hosts 2^h − 2. Networks A 2^7, B 2^14, C 2^21.
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.