GateAI

GATE CSE IPv4, CIDR and NAT PYQs

Standard yield10.6% of Computer Networks

IPv4 testing in GATE CS focuses heavily on numerical datagram mechanics (fragmentation offset, payload size, header scaling factors), CIDR subnetting (subnet al… Read the guide

Questions
14
Asked
since 2012
Total marks
21
Marks / paper
0.8

14 GATE CSE IPv4, CIDR and NAT PYQs with solutions, from Computer Networks. Browse all GATE CSE PYQs.

Questions

Every official paper that asked this topic, newest first.

What GATE tests in IPv4, CIDR and NAT

Concepts, patterns, formulas and traps distilled from past papers.

IPv4 testing in GATE CS focuses heavily on numerical datagram mechanics (fragmentation offset, payload size, header scaling factors), CIDR subnetting (subnet allocation, host ranges, bitwise masking, and longest prefix match forwarding), and IP header architecture (field modifications during transit, option field capacity, and encapsulated protocol numbers). Questions are evenly split between 1-mark conceptual/header checks and 2-mark multi-step arithmetic or routing table lookups.

Core concepts

  • IPv4 Header Format (HLEN scaling factor of 4, Total Length, TTL, Protocol, Header Checksum, Identification, Flags, Fragment Offset scaling factor of 8)
  • Datagram Fragmentation, MTU constraints, MF bit behavior, and Fragment Offset tracking
  • CIDR Prefix Notation, Subnet Masking, and Network/Broadcast Address identification
  • Variable Length Subnet Division and non-overlapping CIDR block partitioning
  • Longest Prefix Matching forwarding logic in CIDR routing tables
  • Router-induced header modifications at each forwarding hop vs static fields
  • IP Options sizing limits (Record Route 40-byte options space, 3-byte header overhead)
  • Layer 3 direct protocol encapsulation (ICMP=1, IGMP=2, OSPF=89) vs Layer 4 transport protocols (TCP=6, UDP=17 for RIP)
  • Broadcast domain / subnet counting across point-to-point router links and LAN interfaces

Recurring question patterns

  • Datagram Fragmentation and Offset Calculation

    CommonMCQ2 marks2014, 2013

    Given datagram size, header length, and link MTU, compute the number of fragments, payload bytes per fragment (strictly rounded to multiples of 8), fragment offset values, Total Length, and the More Fragments (MF) flag for a designated fragment.

  • CIDR Block Splitting and Subnet Allocation

    CommonMCQ2 marks2019, 2012

    Divide a given /n/n CIDR block into smaller variable-length subnets (e.g., half as /n+1/n+1, quarter as /n+2/n+2) and identify non-overlapping, valid subnet allocations, or determine whether given host IPs belong to the same subnet.

  • CIDR Longest Prefix Match Routing

    OccasionalNAT2 marks2014

    Given a destination IPv4 address in dotted-decimal format and a CIDR routing table with prefix entries of varying lengths, find the output interface or next-hop by determining the longest matching binary prefix.

  • Subnet Boundary and Assignable Host IP Computation

    OccasionalNAT2 marks2015

    Given an IP address with a CIDR prefix (e.g., w.x.y.z/nw.x.y.z/n), perform bitwise masking to find the subnet ID, broadcast address, and the decimal value of a specific octet of the first or last usable host address.

  • IPv4 Header Fields and Router Transit Behavior

    Commonmixed1 marks2025, 2024, 2015, 2014

    Identify which IPv4 header fields must change, may change, or remain unchanged during intermediate router forwarding (e.g., TTL decrement, Checksum recomputation, Fragment Offset) or identify encapsulated protocols directly in the Protocol field.

  • Header Options and Protocol Capacity Sizing

    OccasionalNAT1.5 marks2017, 2014

    Calculate capacity constraints based on IPv4 header bounds (e.g., 60-byte max header size, 40-byte options space minus overhead) or allocate bit fields for composite identifiers combining IP addresses, timestamps, and sequence counters.

  • Network Topology Subnet Counting

    OccasionalMCQ1 marks2022

    Given a network diagram with routers, Ethernet segments, firewalls, and servers, determine the total number of broadcast domains / subnets separated by router interfaces.

Formulas GATE uses

IPv4 Header Length in Bytes

Header Length (bytes)=HLEN×4\text{Header Length (bytes)} = \text{HLEN} \times 4

Converting the 4-bit HLEN / IHL field value into physical byte length (min 20 bytes, max 60 bytes).

Fragment Offset Byte Position

First Byte Sequence Number=Fragment Offset×8\text{First Byte Sequence Number} = \text{Fragment Offset} \times 8

Determining the relative starting payload byte index of an IPv4 fragment.

Maximum Fragment Data Payload

Max Payload=⌊MTU−Header Size8⌋×8\text{Max Payload} = \left\lfloor \frac{\text{MTU} - \text{Header Size}}{8} \right\rfloor \times 8

Partitioning an oversized IP datagram into fragments conforming to link MTU constraints.

Last Byte Index of Fragment Payload

Last Byte=First Byte+Fragment Payload Length−1\text{Last Byte} = \text{First Byte} + \text{Fragment Payload Length} - 1

Computing the sequence range of data bytes carried by a specific datagram fragment.

Subnet Block Size and Usable Host Count

Block Size=232−n,Usable Hosts=232−n−2\text{Block Size} = 2^{32 - n}, \quad \text{Usable Hosts} = 2^{32 - n} - 2

Finding address ranges and host capacities for a prefix length /n/n.

Record Route Option Capacity

Max Route Entries=⌊(60−20)−Overhead4⌋=⌊40−34⌋=9\text{Max Route Entries} = \left\lfloor \frac{(60 - 20) - \text{Overhead}}{4} \right\rfloor = \left\lfloor \frac{40 - 3}{4} \right\rfloor = 9

Calculating maximum IP address slots in the IPv4 Record Route option field.

Examiner traps in IPv4, CIDR and NAT

  • Forgetting that HLEN is in 4-byte words while Fragment Offset is in 8-byte units.
  • Failing to make intermediate fragment payload sizes exact multiples of 8 bytes before adding the header.
  • Confusing the 0-indexed byte sequence arithmetic (adding payload size directly without subtracting 1 for the inclusive end byte).
  • Selecting overlapping CIDR subnets when partitioning a parent block among multiple organizations.
  • Overlooking that every point-to-point link between two routers constitutes a distinct subnet.
  • Assuming RIP is directly encapsulated in IPv4 (it runs on top of UDP port 520, so the IP Protocol field is 17).
  • Assuming Source IP address is modified by a standard forwarding router (it remains unchanged unless NAT is explicitly performed).
  • Forgetting to subtract the 3-byte option overhead (Type, Length, Pointer) when calculating usable slots in the IPv4 Record Route option.

How questions are asked

  • Compute fragment offset and byte sequence range from datagram header values
  • Calculate the header field parameters (MF, Length, Offset) of the k-th fragment under a given link MTU
  • Perform longest prefix match on a binary/dotted-decimal routing table
  • Divide a CIDR prefix into disjoint non-overlapping subnets of specified sizes
  • Identify which IP header fields must or may change across router hops (MSQ/MCQ)
  • Count subnets/broadcast domains in a graphical or textual network topology
  • Bit-budgeting and wrap-around time calculation for composite IP-based identifiers
  • Calculate the decimal value of the last assignable host IP in a given CIDR block

Paper trends

  • Header field behavior questions transitioned from standard 1-mark MCQs to multi-correct MSQs requiring distinction between mandatory router changes (TTL, Checksum) versus conditional changes (Offset, Length, NAT-based Source IP).

    2024, 2015, 2014

  • Addressing questions shifted from legacy classful network counting to CIDR-centric arithmetic (subnet splitting, usable host bounds, longest prefix matches).

    2019, 2015, 2014, 2012

  • Recent 1-mark conceptual items assess precise protocol stack layering relationships through the IPv4 Protocol field (identifying direct IP encapsulation vs transport-layer encapsulation).

    2025

Difficulty notes

Easy items (1 mark) test direct definitions: scaling factors of HLEN/Offset, recognizing fields always changed by routers (TTL, Checksum), identifying direct vs indirect IP encapsulation, or counting networks in simple subnets. Medium items (2 marks) require multi-stage arithmetic: fragmenting large datagrams with MTU overhead, determining the n-th fragment fields, Longest Prefix Match binary conversions of ambiguous octets, allocating non-overlapping subnets from a CIDR pool, or calculating counter wrap-around periods.