Sub topic 18
GATE Problem Patterns and Shortcuts
Prerequisites and a reliable method
This chapter assumes binary-to-decimal conversion, IPv4 addressing, subnet masks, packet headers, and basic graph terminology. It also assumes that you know the difference between a host, a router, and a network.
For a numerical problem:
- Write down the given prefix, mask, MTU, or graph.
- Identify what the question asks for.
- Apply one invariant or formula.
- Check boundary values and units.
- Reject answers that violate alignment, broadcast, or protocol rules.
A useful exam habit is to separate address calculations, fragment calculations, and routing calculations. Mixing their rules causes most errors.
Addressing and CIDR shortcuts
For an IPv4 prefix /p, the number of addresses is:
\[ 2^{32-p} \]
For an ordinary subnet, usable host addresses are:
\[ 2^{32-p}-2 \]
The subtraction removes the network and broadcast addresses. Do not subtract two when the question asks for total addresses, or when dealing with special point-to-point conventions explicitly stated in the problem.
To find a subnet boundary, calculate the block size in the changing octet:
\[ \text{block size}=256-\text{mask octet} \]
The network address is the greatest boundary not exceeding the given address. The broadcast address is one address before the next boundary.
For VLSM, sort requirements from largest to smallest. Allocate each requirement the smallest block satisfying:
\[ 2^h-2 \geq \text{required hosts} \]
where \(h\) is the number of host bits. This prevents a large requirement from being stranded between smaller allocations.
For aggregation, prefixes must be contiguous, aligned, and equal-sized before merging. Two /24 networks can merge into a /23 only when their first 23 bits match and the first network begins on the correct /23 boundary.
Forwarding and fragmentation patterns
A router uses longest-prefix match. Among all matching routes, select the route with the greatest prefix length.
| Destination | Matching routes | Selected route |
|---|---|---|
| 10.1.2.3 | 0/0, 10/8, 10.1/16 | 10.1.0.0/16 |
For IPv4 fragmentation, use the payload size, not the total datagram size:
\[ \text{payload}=L-H \]
Each non-final fragment carries a payload that is a multiple of 8 bytes. The maximum such payload is:
\[ \left\lfloor\frac{MTU-H}{8}\right\rfloor \times 8 \]
The fragment offset is measured in 8-byte units. The More Fragments flag is 1 on every fragment except the last. A common mistake is to compute the offset in bytes.
NAT, PAT, and routing algorithms
NAT changes an address. PAT, also called NAT overload, changes a transport-layer port as well, allowing many private hosts to share one public address. Count translation-table entries, not merely hosts, when a question describes simultaneous flows.
For distance-vector problems, repeatedly relax every link using the Bellman-Ford rule:
\[ Dx(y)=\minv\{c(x,v)+D_v(y)\} \]
Count-to-infinity occurs when routers increase a stale route through one another. Split horizon forbids advertising a route back through the interface from which it was learned. Poison reverse advertises that route with an infinite metric instead.
For link-state problems, flood the topology and run Dijkstra from the source. For RIP, the metric is hop count and 16 means infinity. OSPF uses cost and link-state flooding within an autonomous system. BGP uses path vectors and policy between autonomous systems.
Exercise
A datagram has total length 4000 bytes, a 20-byte header, and crosses an MTU of 1500 bytes. What are the fragment offsets?
Show answer
The payload is 3980 bytes. Each non-final payload is 1480 bytes. The offsets are 0, 185, and 370 because offsets use 8-byte units.