5.3VLSM, aggregation and longest-prefix match
The idea
VLSM gives each LAN a block just big enough. Aggregation merges neighbouring blocks into one shorter prefix. A router chooses a route by longest-prefix match.
Think of it like this: Street addresses: "Main Street 5" beats "the city of Pune" when you are asked where to deliver; the most specific address wins.
Why it exists
GATE gives a forwarding table and an address, or a list of blocks to aggregate.
How it works
- VLSM: round (hosts + 2) up to a power of two, allocate the largest first so every block stays aligned.
- Aggregation: two equal blocks merge if adjacent and the first starts on a boundary of the bigger block.
- Longest-prefix: list every entry whose prefix matches the destination, take the one with the largest /n.
- The default route 0.0.0.0/0 matches everything but loses to any longer prefix.
Worked example: Destination 145.36.109.70, entries 145.36.0.0/16, 145.36.128.0/17, 145.36.64.0/18, default.
The /16 and /18 match (64 to 127 contains 109); /17 covers 128 to 255 and does not. Longest is /18 so the packet leaves on that entry's interface (GATE 2025).
Now play with it
- →Use the LPM lab with 10.1.1.132 and the GATE 2024 table.
- →In the aggregation lab enter 12.20.164.0/22, 12.20.168.0/23, 12.20.170.0/23 and see why a single /20 covers extra addresses.
| LAN | hosts needed | block | usable range | broadcast |
|---|---|---|---|---|
| 1 | 50 | 192.168.1.0/26 | 192.168.1.1 to 192.168.1.62 | 192.168.1.63 |
| 2 | 20 | 192.168.1.64/27 | 192.168.1.65 to 192.168.1.94 | 192.168.1.95 |
| 3 | 10 | 192.168.1.96/28 | 192.168.1.97 to 192.168.1.110 | 192.168.1.111 |
| 4 | 2 | 192.168.1.112/30 | 192.168.1.113 to 192.168.1.114 | 192.168.1.115 |
Addresses left over at the end of the parent block: 140. Sort by size, give the biggest LAN the first aligned block, and round each LAN up to the next power of two (hosts + 2).
Two blocks merge only if they are the same size, adjacent, and the first one starts on a boundary of the bigger block. If the covering prefix holds more addresses than the list, aggregating that way would also claim addresses that belong to someone else.
| prefix | interface | matches? | prefix length |
|---|---|---|---|
| 145.36.0.0/16 | E1 | yes | /16 |
| 145.36.128.0/17 | E2 | no | /17 |
| 145.36.64.0/18 | E3 | yes | /18 |
| 145.36.255.0/24 | E4 | no | /24 |
| 0.0.0.0/0 | E5 (default) | yes | /0 |
Forwarded out of E3: the matching entry with the longest prefix (/18) wins.
Check yourself
Which can be a valid CIDR block?
Exam notes (the dense version)
VLSM gives each LAN a block just big enough: round (hosts + 2) up to a power of two, allocate the biggest first from a block so alignment holds. Route aggregation merges adjacent equal-size blocks into one shorter prefix (4 contiguous /24s become one /22) and shrinks routing tables. A router forwards by longest-prefix match: among all matching entries the one with the longest mask wins; the default route 0.0.0.0/0 matches everything but loses to any longer match.
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.