CS Atlas GATE 2027
Computer Networks course
0 / 90 complete

Computer Networks/Phase 3 · Network Layer

Chapter review L3.1 · Item 47 of 90

IPv4 addressing, subnetting, CIDR, LPM & VLSM

Read at your own pace. Try the questions before opening the answers.

On this page

Chapter recap

Chapter 3.1 gave our datagram its universal 32-bit hierarchical address. We traced the evolution from fixed classes (A–E) and special addresses (0.0.0.0, 255.255.255.255, 127.x.y.z) to subnetting (borrowing s bits for 2ˢ subnets of 2ʰ − 2 usable hosts), CIDR slash notation /n with its power-of-2 size and alignment rules, route aggregation, Longest Prefix Match (LPM) in router forwarding tables, and largest-first VLSM block design.

Merged rule card

From 3.1.1 IPv4 address structure, dotted decimal, net-id vs host-id

  • IPv4 address = 32 bits = 4 octets (0–255 each), total space = 2³².
  • Split: Net-ID (left n bits) + Host-ID (right h = 32 − n bits).
  • Identifies a network interface (routers have one IP per link).

From 3.1.2 Classful addressing (A–E) and special IPv4 addresses

  • Classes by 1st octet: A = 0–127 (0, 8 net bits), B = 128–191 (10, 16 net bits), C = 192–223 (110, 24 net bits), D = 224–239 (1110, multicast), E = 240–255 (1111, reserved).
  • Usable hosts = 2ʰ − 2 (exclude host all-0s = network address, host all-1s = directed broadcast).
  • Specials: 0.0.0.0 = this host (src only); 255.255.255.255 = limited broadcast (local LAN only); 127.x.y.z = loopback.

From 3.1.3 Subnet masks, subnetting, network/broadcast & usable hosts

  • Borrow s bits from host field, leaving h bits → 2ˢ subnets, each with 2ʰ − 2 usable hosts.
  • Subnet address = IP AND Mask; Broadcast = host bits all 1s.
  • Stride Δ = 256 − Mask octet: blocks start at 0, Δ, 2Δ, … and end at Δ−1, 2Δ−1, ….
  • Valid mask octets: 128, 192, 224, 240, 248, 252, 254, 255.

From 3.1.4 CIDR notation (/n), block size, alignment & route aggregation

  • CIDR a.b.c.d/n: n prefix bits, h = 32 − n host bits, block size N = 2ʰ.
  • Alignment rule: first address must be divisible by 2ʰ (for /(24−k), 3rd octet must be divisible by 2ᵏ).
  • Supernetting: 2ᵏ contiguous, aligned /n blocks merge into one /(n − k) block.

From 3.1.5 Forwarding tables & Longest Prefix Match (LPM)

  • Match condition: Row N/n (mask M) matches destination D iff (D AND M) == N (i.e. D falls in [N .. N + 2³²⁻ⁿ − 1]).
  • Longest Prefix Match (LPM): Among all matching rows, pick the one with the largest prefix length n.
  • Default route 0.0.0.0/0: matches every address with n = 0 (used only if nothing else matches).

From 3.1.6 Variable-Length Subnet Masking (VLSM) & block allocation

  • Block size for H usable hosts: smallest 2ʰ with 2ʰ − 2 ≥ H; prefix = /(32 − h).
  • Largest-first rule: sort subnets by decreasing 2ʰ and allocate sequentially so every block is naturally aligned.
  • Non-overlap: sum of block sizes ∑ 2ʰᵢ ≤ 2³²⁻ⁿ_parent, and every block starts on a multiple of its own 2ʰᵢ.

Practice questions

  1. NAT · 1 mark

    A Class B network 172.16.0.0 is subnetted with subnet mask 255.255.252.0. How many usable hosts exist per subnet?

    Write your answer before opening the key.

  2. MCQ · 2 marks

    What is the directed broadcast address of the subnet to which host 172.16.45.19 with mask 255.255.248.0 belongs?

    1. 172.16.47.255
    2. 172.16.45.255
    3. 172.16.48.255
    4. 172.16.255.255
  3. MSQ · 2 marks

    Which of the following CIDR blocks are properly aligned (valid network prefixes)?

    1. 200.10.24.0/21
    2. 200.10.20.0/21
    3. 10.0.128.0/17
    4. 192.168.1.64/26
  4. MCQ · 2 marks

    Two routers advertise 192.168.16.0/22 and 192.168.20.0/22 to an upstream ISP. What single aggregated CIDR prefix represents both blocks?

    1. 192.168.16.0/21
    2. 192.168.16.0/20
    3. 192.168.0.0/16
    4. They cannot be aggregated into a single prefix without extra addresses.
  5. MCQ · 2 marks

    A router forwarding table has: (1) 128.75.43.0/25 → R1, (2) 128.75.43.64/26 → R2, (3) 128.75.43.0/24 → R3, (4) 0.0.0.0/0 → R4. Which next hop is chosen for 128.75.43.130?

    1. R1
    2. R2
    3. R3
    4. R4
  6. NAT · 2 marks

    From 192.168.10.0/24, we allocate three subnets for 110 hosts, 55 hosts, and 25 hosts using largest-first VLSM. What is the 4th octet of the network address of the 3rd subnet (for 25 hosts)?

    Write your answer before opening the key.

  7. MCQ · 1 mark

    Which IPv4 address is used by a booting host as its source IP before it knows its own address?

    1. 0.0.0.0
    2. 255.255.255.255
    3. 127.0.0.1
    4. 192.168.0.1
  8. NAT · 1 mark

    How many bytes longer is an Ethernet MAC address than an IPv4 address?

    Write your answer before opening the key.

Answer key

Try the questions first. Open when you are ready to check.
  1. 1022 — 252 = 11111100₂ (6 ones in 3rd octet) → prefix /22, leaving h = 10 host bits. Usable hosts = 2¹⁰ − 2 = 1022.

    Review lesson 3.1.3

  2. A — In 3rd octet, stride Δ = 256 − 248 = 8. Multiples of 8: 40, 48. Since 40 ≤ 45 < 48, the subnet starts at 172.16.40.0 and ends at 172.16.47.255.
    • B: Forgets that 3 bits of the 3rd octet are also host bits.
    • C: 48.0 is the start of the next subnet.
    • D: That is the unsubnetted Class B broadcast.

    Review lesson 3.1.3

  3. ACD — /21 needs 3rd octet divisible by 8 (24 is, 20 is not); /17 needs 3rd octet divisible by 128 (128 is); /26 needs 4th octet divisible by 64 (64 is).
    • B: 20 is not divisible by 8 (20 = 00010100₂ has a 1 in the host part of a /21).

    Review lesson 3.1.4

  4. A — 16.0/22 covers .16..19; 20.0/22 covers .20..23. Together they cover .16..23 (8 octets), and 16 is divisible by 8 → 192.168.16.0/21.
    • B: /20 covers 16 octets (.16..31).
    • C: Too broad (includes extra addresses).
    • D: 16 is a multiple of 8, so they aggregate cleanly.

    Review lesson 3.1.4

  5. C — 4th octet is 130. (1) .0/25 covers 0..127 (no match). (2) .64/26 covers 64..127 (no match). (3) .0/24 covers 0..255 (matches, n=24). (4) /0 matches (n=0). Longest matching prefix is /24 → R3.
    • A: .0/25 only covers 0..127.
    • B: .64/26 only covers 64..127.
    • D: /0 loses to /24.

    Review lesson 3.1.5

  6. 192 — 110 hosts → 128 (.0/25, 0..127); 55 hosts → 64 (.128/26, 128..191); 25 hosts → 32, starting at .192 (192.168.10.192/27).

    Review lesson 3.1.6

  7. A — 0.0.0.0 means "this host on this network" and is valid only as a source address during bootstrap.
    • B: 255.255.255.255 is limited broadcast (destination only).
    • C: 127.0.0.1 is loopback.
    • D: Ordinary private unicast address.

    Review lesson 3.1.2

  8. 2 — MAC address = 6 bytes (48 bits); IPv4 address = 4 bytes (32 bits); difference = 2 bytes.

    Review lesson 3.1.1

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.