IAE Academy

GATE CS

IPv4

Addressing, CIDR, fragmentation and NAT

An IPv4 address is a 32-bit number split by a prefix length into a network part and a host part. GATE questions on it come down to a few mechanical skills: finding network, broadcast and host ranges from an address and mask, aggregating blocks with CIDR, choosing a route by longest-prefix match, and working out fragment sizes, offsets and flags for a given MTU. NAT and the helper protocols (ARP, DHCP, ICMP) complete the picture.

20 previous-year questions · 20 solved · 6 practice questions

Addresses, classes and masks

An IPv4 address has 32 bits, written as four bytes in dotted decimal, for example 192.168.10.37. A subnet mask (or prefix length ) says how many leading bits identify the network; the remaining bits identify the host. With all host bits 0 you get the network address; with all host bits 1 you get the directed broadcast address. Neither can be assigned to a host.

Classful addressing (older questions)

Class

Leading bits

First byte range

Default prefix

Use

A

0

0 to 127 (0 and 127 reserved; 127.x.x.x is loopback)

/8

Unicast

B

10

128 to 191

/16

Unicast

C

110

192 to 223

/24

Unicast

D

1110

224 to 239

none

Multicast

E

1111

240 to 255

none

Reserved

To find the class, look at the first byte only. Special addresses: 0.0.0.0 means "this host" (used as the source by a host that has no address yet), 255.255.255.255 is the limited broadcast (never forwarded by a router), and 127.x.x.x is loopback.

ADDRESSES IN A BLOCK

For a block with prefix length p, counting the network and broadcast addresses.

USABLE HOSTS IN A BLOCK

For a block with prefix length p. The two subtracted addresses are the network and broadcast addresses. Valid for p up to 30.

EXAM TIP

A /31 block has only 2 addresses and a /32 is a single host. The formula above gives 0 for /31 and -1 for /32, so use it only for unless the question says otherwise.

Subnetting and CIDR

Subnetting borrows host bits to create more, smaller networks. CIDR (Classless Inter-Domain Routing) drops the class rules: any prefix length from /0 to /32 is allowed and a block is written a.b.c.d/p. Convention used here: all-zeros and all-ones subnet numbers are allowed (as in CIDR). Older classful questions sometimes exclude them, which removes 2 subnets; read the question for which convention applies.

NUMBER OF SUBNETS (CIDR CONVENTION)

s is the number of host bits borrowed (new prefix length minus old prefix length). All-zeros and all-ones subnets are allowed.

NUMBER OF SUBNETS (OLDER CLASSFUL CONVENTION)

Only when the question excludes the all-zeros and all-ones subnet numbers.

BLOCK SIZE IN THE INTERESTING OCTET

The interesting octet is the one where the mask is neither 255 nor 0. Subnets start at multiples of the block size in that octet. If p is a multiple of 8 there is no such octet: the host part is whole octets.

Finding network and broadcast address from address/prefix

  1. Find the interesting octet (the one containing the boundary between 1s and 0s of the mask).

  2. Block size = 256 minus the mask value in that octet.

  3. Network address: round the address's octet down to a multiple of the block size; octets after it become 0.

  4. Broadcast address: network octet + block size - 1; octets after it become 255.

  5. First usable host = network + 1; last usable host = broadcast - 1.

VLSM (variable-length subnet masks): when subnets need different sizes, allocate the largest first, each starting at an address that is a multiple of its own size (its number of addresses). This keeps blocks aligned and unused space contiguous.

Supernetting / route aggregation: contiguous blocks of equal size can be advertised as one block with the prefix shortened by , provided the first block's address is a multiple of the combined size. Check: for four /24 blocks the third octet of the first block must be a multiple of 4. Aggregation into one block fails if the blocks are not contiguous, if the first is not aligned, or if the number of blocks is not a power of 2 (then more than one prefix is needed).

WORKED EXAMPLE

A /24 block 200.1.1.0/24 must be split among three LANs needing 100, 50 and 25 hosts. Give each LAN a block using VLSM.

Solution
  1. Smallest block with at least 100 usable hosts: 128 addresses (/25, 126 usable).

  2. For 50 hosts: 64 addresses (/26, 62 usable). For 25 hosts: 32 addresses (/27, 30 usable).

  3. Allocate largest first: LAN 1 gets 200.1.1.0/25 (addresses 0 to 127).

  4. LAN 2 gets the next multiple of 64: 200.1.1.128/26 (128 to 191).

  5. LAN 3 gets the next multiple of 32: 200.1.1.192/27 (192 to 223). Addresses 224 to 255 remain free.

Answer: 200.1.1.0/25, 200.1.1.128/26, 200.1.1.192/27.

Forwarding and longest-prefix match

A router's forwarding table holds entries of the form (prefix, next hop or interface). For a destination address the router finds every entry whose prefix matches the leading bits of the destination, then picks the one with the longest prefix (most specific). The default route 0.0.0.0/0 matches everything but has length 0, so it is chosen only when nothing else matches.

Procedure to choose a route

  1. For each entry, find the address range its prefix covers (network address to broadcast address).

  2. Keep the entries whose range contains the destination (the default route 0.0.0.0/0, if present, always matches with length 0).

  3. Among those, choose the one with the largest prefix length.

  4. If no entry matches (no default route either), the packet is dropped and the router normally sends ICMP destination unreachable to the source.

EXAM TIP

Do not choose the entry that merely looks closest numerically. Always test containment in the range. Two overlapping entries are legal; the longer one wins for addresses it covers, and the shorter one still handles the rest of its range.

IPv4 header fields

Fields that matter for GATE

Field

Size

Meaning and convention

Version

4 bits

Value 4 for IPv4.

Header length (HLEN)

4 bits

Counted in 4-byte words. Minimum 5 (20 bytes), maximum 15 (60 bytes).

Type of service

8 bits

Priority and service class; not used in fragmentation or routing calculations.

Total length

16 bits

Header plus data, in bytes. Maximum 65535.

Identification

16 bits

Same value in all fragments of one datagram; used for reassembly.

Flags

3 bits

Reserved, DF (don't fragment), MF (more fragments).

Fragment offset

13 bits

Position of the fragment's data in the original data, in units of 8 bytes.

TTL

8 bits

Each router decrements it by 1; if it reaches 0 the packet is discarded and ICMP time exceeded is sent to the source.

Protocol

8 bits

Upper-layer protocol: 1 ICMP, 6 TCP, 17 UDP.

Header checksum

16 bits

Covers the header only; recomputed at every router because TTL changes.

Options

0 to 40 bytes

Present only when HLEN is more than 5.

The header checksum is the 16-bit one's-complement of the one's-complement sum of the header's 16-bit words. The data is not covered. Source and destination addresses are 32 bits each. Limits that follow from the field sizes: a datagram with a 20-byte header carries at most bytes of data, and the largest offset value is , which is byte position .

Fragmentation

Each link has an MTU, the largest IP datagram (header included) it can carry. If a datagram is larger than the MTU and DF is 0, the sending host or router splits it into fragments. Each fragment carries a piece of the data and its own IP header: Identification, source and destination stay the same; total length, MF, offset and checksum are set for the fragment; options are copied only if their copy flag is set. Fragments are reassembled only at the destination. If DF is 1 and the datagram does not fit, it is dropped and ICMP "destination unreachable (fragmentation needed)" is sent.

MAXIMUM DATA PER FRAGMENT

H is the header length in bytes (20 without options). Data in every fragment except the last must be a multiple of 8 bytes.

NUMBER OF FRAGMENTS

L is the original total length in bytes, H the header length. Assumes a single fragmentation at one link and the same header length H in every fragment.

FRAGMENT OFFSET FIELD

Measured from the start of the original datagram's data. MF = 1 for every fragment except the last.

DATA BYTES CARRIED BY A FRAGMENT

Byte positions in the original data, numbered from 0. Total length is in bytes; HLEN is in 4-byte words.

WORKED EXAMPLE

A datagram of total length 4000 bytes (20-byte header, no options) with DF = 0 enters a link of MTU 1500 bytes. Give the length, offset and MF of each fragment.

Solution
  1. Data = 4000 - 20 = 3980 bytes.

  2. bytes.

  3. Number of fragments .

  4. Fragment 1: data 1480, total length 1500, offset 0, MF = 1.

  5. Fragment 2: data 1480, total length 1500, offset 1480/8 = 185, MF = 1.

  6. Fragment 3: data 3980 - 2960 = 1020, total length 1040, offset 2960/8 = 370, MF = 0.

Answer: Three fragments: (1500, offset 0, MF 1), (1500, offset 185, MF 1), (1040, offset 370, MF 0).

EXAM TIP

Reading a fragment: offset 0 and MF = 1 means the first fragment; MF = 0 and offset above 0 means the last; offset above 0 and MF = 1 means a middle one; offset 0 and MF = 0 means the datagram was not fragmented. From the last fragment, the original data length is .

EXAM TIP

If a fragment meets a smaller MTU later, it is fragmented again. Offsets stay relative to the original data, and the last piece of a fragment that already had MF = 1 keeps MF = 1. Only the true final piece of the datagram has MF = 0.

EXAM TIP

Every fragment carries a full header, so the total IP bytes sent exceed the original by H per extra fragment (20 bytes when there are no options).

NAT, ARP, DHCP and ICMP

Private (non-routable on the public Internet) ranges

Block

Range

Prefix

Class A private

10.0.0.0 to 10.255.255.255

10.0.0.0/8

Class B private

172.16.0.0 to 172.31.255.255

172.16.0.0/12

Class C private

192.168.0.0 to 192.168.255.255

192.168.0.0/16

NAT (Network Address Translation) lets many hosts with private addresses share one or a few public addresses. The most common form, port address translation (PAT, often just called NAT), rewrites the source address and source port of outgoing packets and records the mapping in a NAT table: (private IP, private port) to (public IP, public port). Replies are matched against the table and rewritten back. Because the table is keyed on port numbers, a single public address can support many simultaneous connections, limited by the 16-bit port space per transport protocol. An inbound packet with no table entry is dropped unless a static mapping (port forwarding) has been set up for it. NAT must update the IP header checksum, and also the TCP or UDP checksum, because that checksum covers a pseudo-header containing the IP addresses as well as the ports. Addresses 169.254.0.0/16 are link-local, not part of the private ranges above.

Helper protocols at GATE level

Protocol

Job

Key facts

ARP

Find the MAC address for a known IP on the same network

Carried directly in the link-layer frame, not inside IP. Request is broadcast; reply is unicast. For an off-network destination the host ARPs for its default gateway.

DHCP

Give a host an IP address, mask, gateway and DNS server

Runs over UDP (server port 67, client port 68). Steps: Discover, Offer, Request, Acknowledge. The client starts with source 0.0.0.0 and destination 255.255.255.255.

ICMP

Error and control messages for IP

Carried inside IP with protocol 1. Echo request (type 8) and reply (type 0); destination unreachable (3); time exceeded (11).

Traceroute uses TTL. It sends probes with TTL = 1, 2, 3, ... The first router discards the TTL-1 probe and returns an ICMP time-exceeded message, revealing its address; the next probe goes one hop further. When a probe finally reaches the destination, the destination replies (for UDP probes, ICMP port unreachable; for ICMP probes, echo reply), which ends the trace.

PREVIOUS-YEAR QUESTIONS

20 questions from the CS papers

Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE CSE 2026 Set 1 · GATE CSE 2026 Set 2 · GATE CSE 2025 Set 1 · GATE CSE 2025 Set 2 · GATE CSE 2024 Set 1 · GATE CSE 2024 Set 2 · GATE CSE 2023 · GATE CSE 2022 · GATE CSE 2020 · GATE CSE 2018

GATE 2026 CS1 Q.56

GATE 2026 · CS1Q.56 · 2 marks · MSQ

An ISP having an address block 202.16.0.0/15 assigns a block of 6000 IP addresses to a client, using the classless internet domain routing (CIDR) super-netting approach. Which of the following address blocks can be assigned by the ISP?

  1. (A)

    202.16.0.0/19

  2. (B)

    202.17.64.0/19

  3. (C)

    202.16.32.0/19

  4. (D)

    202.17.24.0/19

Answer and solution
See the question in the paper
GATE 2026 CS1 Q.56: answer and solution

GATE 2025 CS1 Q.40

GATE 2025 · CS1Q.40 · 2 marks · MCQ

A packet with the destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to?

GATE 2025 CS1 question 40: A routing table with columns Subnet Address, Subnet Mask (in CIDR notation), Interface.Tap to open full size
Figure from the GATE 2025 CS1 paper. It is part of the question.
Figure description

A routing table with columns Subnet Address, Subnet Mask (in CIDR notation), Interface. Rows: 145.36.0.0 /16 E1; 145.36.128.0 /17 E2; 145.36.64.0 /18 E3; 145.36.255.0 /24 E4; Default -- E5.

  1. (A)

    E3

  2. (B)

    E1

  3. (C)

    E2

  4. (D)

    E5

Answer and solution
GATE 2025 CS1 Q.40: answer and solution

GATE 2025 CS1 Q.57

GATE 2025 · CS1Q.57 · 2 marks · NAT

Suppose a message of size 15000 bytes is transmitted from a source to a destination using IPv4 protocol via two routers as shown in the figure. Each router has a defined maximum transmission unit (MTU) as shown in the figure, including IP header. The number of fragments that will be delivered to the destination is ________ . (Answer in integer)

GATE 2025 CS1 question 57: A left-to-right chain of boxes joined by arrows: Source, then Router-1 (MTU=5000 bytes), then Router-2 (MTU=3000 bytes)…Tap to open full size
Figure from the GATE 2025 CS1 paper. It is part of the question.
Figure description

A left-to-right chain of boxes joined by arrows: Source, then Router-1 (MTU=5000 bytes), then Router-2 (MTU=3000 bytes), then Destination.

Answer and solution
GATE 2025 CS1 Q.57: answer and solution

GATE 2025 CS2 Q.18

GATE 2025 · CS2Q.18 · 1 mark · MCQ

A machine receives an IPv4 datagram. The protocol field of the IPv4 header has the protocol number of a protocol X.

Which ONE of the following is NOT a possible candidate for X?

  1. (A)

    Internet Control Message Protocol (ICMP)

  2. (B)

    Internet Group Management Protocol (IGMP)

  3. (C)

    Open Shortest Path First (OSPF)

  4. (D)

    Routing Information Protocol (RIP)

Answer and solution
See the question in the paper
GATE 2025 CS2 Q.18: answer and solution

GATE 2025 CS2 Q.23

GATE 2025 · CS2Q.23 · 1 mark · MCQ

Consider a network that uses Ethernet and IPv4. Assume that IPv4 headers do not use any options field. Each Ethernet frame can carry a maximum of 1500 bytes in its data field. A UDP segment is transmitted. The payload (data) in the UDP segment is 7488 bytes.

Which ONE of the following choices has the CORRECT total number of fragments transmitted and the size of the last fragment including IPv4 header?

  1. (A)

    5 fragments, 1488 bytes

  2. (B)

    6 fragments, 88 bytes

  3. (C)

    6 fragments, 108 bytes

  4. (D)

    6 fragments, 116 bytes

Answer and solution
See the question in the paper
GATE 2025 CS2 Q.23: answer and solution

GATE 2024 CS1 Q.58

GATE 2024 · CS1Q.58 · 2 marks · NAT

Consider the entries shown below in the forwarding table of an IP router. Each entry consists of an IP prefix and the corresponding next hop router for packets whose destination IP address matches the prefix. The notation "/N" in a prefix indicates a subnet mask with the most significant N bits set to 1.

This router forwards 20 packets each to 5 hosts. The IP addresses of the hosts are 10.1.1.16, 10.1.1.72, 10.1.1.132, 10.1.1.191, and 10.1.1.205. The number of packets forwarded via the next hop router R2 is ______

GATE 2024 CS1 question 58: A two-column table with header Prefix | Next hop router.Tap to open full size
Figure from the GATE 2024 CS1 paper. It is part of the question.
Figure description

A two-column table with header Prefix | Next hop router. Rows: 10.1.1.0/24 | R1; 10.1.1.128/25 | R2; 10.1.1.64/26 | R3; 10.1.1.192/26 | R4.

Answer and solution
GATE 2024 CS1 Q.58: answer and solution

GATE 2024 CS1 Q.65

GATE 2024 · CS1Q.65 · 2 marks · NAT

Consider sending an IP datagram of size 1420 bytes (including 20 bytes of IP header) from a sender to a receiver over a path of two links with a router between them. The first link (sender to router) has an MTU (Maximum Transmission Unit) size of 542 bytes, while the second link (router to receiver) has an MTU size of 360 bytes. The number of fragments that would be delivered at the receiver is ______

Answer and solution
See the question in the paper
GATE 2024 CS1 Q.65: answer and solution
Show the other 10 questions

GATE 2024 CS2 Q.23

GATE 2024 · CS2Q.23 · 1 mark · MSQ

Node X has a TCP connection open to node Y. The packets from X to Y go through an intermediate IP router R. Ethernet switch S is the first switch on the network path between X and R. Consider a packet sent from X to Y over this connection.

Which of the following statements is/are TRUE about the destination IP and MAC addresses on this packet at the time it leaves X?

  1. (A)

    The destination IP address is the IP address of R

  2. (B)

    The destination IP address is the IP address of Y

  3. (C)

    The destination MAC address is the MAC address of S

  4. (D)

    The destination MAC address is the MAC address of Y

Answer and solution
See the question in the paper
GATE 2024 CS2 Q.23: answer and solution

GATE 2024 CS2 Q.28

GATE 2024 · CS2Q.28 · 1 mark · MSQ

Which of the following statements about IPv4 fragmentation is/are TRUE?

  1. (A)

    The fragmentation of an IP datagram is performed only at the source of the datagram

  2. (B)

    The fragmentation of an IP datagram is performed at any IP router which finds that the size of the datagram to be transmitted exceeds the MTU

  3. (C)

    The reassembly of fragments is performed only at the destination of the datagram

  4. (D)

    The reassembly of fragments is performed at all intermediate routers along the path from the source to the destination

Answer and solution
See the question in the paper
GATE 2024 CS2 Q.28: answer and solution

GATE 2023 CS Q.65

GATE 2023 · CSQ.65 · 2 marks · NAT

The forwarding table of a router is shown below.

A packet addressed to a destination address 200.150.68.118 arrives at the router. It will be forwarded to the interface with ID ______.

GATE 2023 CS question 65: A forwarding table with columns Subnet Number, Subnet Mask, Interface ID and five rows: (200.150.0.0, 255.255.0.0, 1)…Tap to open full size
Figure from the GATE 2023 CS paper. It is part of the question.
Figure description

A forwarding table with columns Subnet Number, Subnet Mask, Interface ID and five rows: (200.150.0.0, 255.255.0.0, 1), (200.150.64.0, 255.255.224.0, 2), (200.150.68.0, 255.255.255.0, 3), (200.150.68.64, 255.255.255.224, 4), (Default, blank mask, 0).

Answer and solution
GATE 2023 CS Q.65: answer and solution

GATE 2022 CS Q.22

GATE 2022 · CSQ.22 · 1 mark · MCQ

Consider an enterprise network with two Ethernet segments, a web server and a firewall, connected via three routers as shown below.

What is the number of subnets inside the enterprise network?

GATE 2022 CS question 22: Network topology.Tap to open full size
Figure from the GATE 2022 CS paper. It is part of the question.
Figure description

Network topology. A firewall (top left) has an arrow 'To Internet' leaving it on the left. The firewall has two links: one down to the left Router (R1) and one horizontal line to the top-centre Router (R2). R2 connects down to a Web Server and, by a line going right and down, to the right Router (R3). R1 connects down to a left Ethernet segment (a bus/switch) with several hosts attached, shown with a dashed line for 'more hosts'. R3 connects down to a right Ethernet segment with several hosts attached, also with dashed continuation. Labels: Firewall, Router (three times), Web Server, Ethernet (twice).

  1. (A)

    3

  2. (B)

    12

  3. (C)

    6

  4. (D)

    8

Answer and solution
GATE 2022 CS Q.22: answer and solution

GATE 2022 CS Q.55

GATE 2022 · CSQ.55 · 2 marks · MSQ

Consider routing table of an organization's router shown below:

Which of the following prefixes in CIDR notation can be collectively used to correctly aggregate all of the subnets in the routing table?

  1. (A)

    12.20.164.0/20

  2. (B)

    12.20.164.0/22

  3. (C)

    12.20.164.0/21

  4. (D)

    12.20.168.0/22

Answer and solution
See the question in the paper
GATE 2022 CS Q.55: answer and solution

GATE 2020 CS Q.15

GATE 2020 · CSQ.15 · 1 mark · MCQ

Consider the following statements about the functionality of an IP based router.
I. A router does not modify the IP packets during forwarding.
II. It is not necessary for a router to implement any routing protocol.
III. A router should reassemble IP fragments if the MTU of the outgoing link is larger than the size of the incoming IP packet.
Which of the above statements is/are TRUE?

  1. (A)

    I and II only

  2. (B)

    I only

  3. (C)

    II and III only

  4. (D)

    II only

Answer and solution
See the question in the paper
GATE 2020 CS Q.15: answer and solution

GATE 2020 CS Q.38

GATE 2020 · CSQ.38 · 2 marks · MCQ

An organization requires a range of IP addresses to assign one to each of its 1500 computers. The organization has approached an Internet Service Provider (ISP) for this task. The ISP uses CIDR and serves the requests from the available IP address space 202.61.0.0/17. The ISP wants to assign an address space to the organization which will minimize the number of routing entries in the ISP's router using route aggregation. Which of the following address spaces are potential candidates from which the ISP can allot any one to the organization?

I. 202.61.84.0/21
II. 202.61.104.0/21
III. 202.61.64.0/21
IV. 202.61.144.0/21

  1. (A)

    I and II only

  2. (B)

    II and III only

  3. (C)

    III and IV only

  4. (D)

    I and IV only

Answer and solution
See the question in the paper
GATE 2020 CS Q.38: answer and solution

GATE 2018 CS Q.54

GATE 2018 · CSQ.54 · 2 marks · NAT

Consider an IP packet with a length of 4,500 bytes that includes a 20-byte IPv4 header and a 40-byte TCP header. The packet is forwarded to an IPv4 router that supports a Maximum Transmission Unit (MTU) of 600 bytes. Assume that the length of the IP header in all the outgoing fragments of this packet is 20 bytes. Assume that the fragmentation offset value stored in the first fragment is 0.

The fragmentation offset value stored in the third fragment is ________.

Answer and solution
See the question in the paper
GATE 2018 CS Q.54: answer and solution

OTHER EXAMS

ISRO: 2 questions

From ISRO's Scientist/Engineer written test: ISRO CS 2025. They are not counted in the GATE numbers on this page.

ISRO CS 2025 Q.41

ISRO 2025 · CSQ.41 · 1 mark · MCQ

Computer A is assigned with IP address 10.0.0.126 and computer B is assigned with IP address 10.0.0.131. Network mask is 255.255.255.192 in both cases. Which of the following statements is true?

  1. (A)

    10.0.0.x addresses have to be allocated by IANA and cannot be used by hosts

  2. (B)

    The given network mask cannot be assigned to class A IP addresses

  3. (C)

    A router will be required to communicate between A and B

  4. (D)

    Computer A and B form part of a multicast group

Answer and solution
See the question in the paper
ISRO CS 2025 Q.41: answer and solution

PRACTICE

6 questions to test yourself

PRACTICE 11 mark · MCQ

A host has the address 172.16.37.200 with prefix length /21. What is its network address?

  1. (A)

    172.16.32.0

  2. (B)

    172.16.36.0

  3. (C)

    172.16.37.0

  4. (D)

    172.16.40.0

Answer and solution

Answer: (A)

  1. /21 means mask 255.255.248.0, so the interesting octet is the third and its block size is 256 - 248 = 8.

  2. Third octet 37 rounded down to a multiple of 8 is 32.

  3. Network address = 172.16.32.0 (broadcast would be 172.16.39.255).

PRACTICE 22 marks · MSQ

Which of the following addresses lie in the private ranges reserved for use behind NAT?

  1. (A)

    10.255.0.9

  2. (B)

    172.32.0.1

  3. (C)

    172.31.255.1

  4. (D)

    172.15.4.4

Answer and solution

Answer: (A), (C)

  1. The 10.0.0.0/8 block covers 10.0.0.0 to 10.255.255.255, so A is private.

  2. The 172.16.0.0/12 block covers 172.16.0.0 to 172.31.255.255. 172.32.0.1 and 172.15.4.4 lie outside, so B and D are public.

  3. 172.31.255.1 is inside that range, so C is private.

PRACTICE 32 marks · NAT

An IPv4 datagram of total length 5000 bytes (header 20 bytes, no options, DF = 0) is sent over a link with MTU 1220 bytes. What is the value of the fragment offset field in the last fragment?

Answer and solution

Answer:

  1. Data = 5000 - 20 = 4980 bytes.

  2. Each fragment can carry bytes of data (1200 is a multiple of 8).

  3. Number of fragments = ; the first four carry 4800 bytes, the last carries 180.

  4. Offset of the last fragment = 4800 / 8 = 600.

PRACTICE 41 mark · NAT

An organisation owns four contiguous blocks 200.10.0.0/24, 200.10.1.0/24, 200.10.2.0/24 and 200.10.3.0/24. They are advertised as a single aggregated block. What is the prefix length of that block?

Answer and solution

Answer:

  1. Four blocks means , so the prefix shortens by 2 bits: 24 - 2 = 22.

  2. Check alignment: the first block's third octet is 0, a multiple of 4, so 200.10.0.0/22 covers exactly third octets 0 to 3.

PRACTICE 52 marks · MCQ

A router has the forwarding table: 10.0.0.0/8 to R1; 10.20.0.0/16 to R2; 10.20.64.0/18 to R3; 0.0.0.0/0 to R4. A packet arrives for 10.20.100.5. To which next hop is it forwarded?

  1. (A)

    R1

  2. (B)

    R2

  3. (C)

    R3

  4. (D)

    R4

Answer and solution

Answer: (C)

  1. The /18 block 10.20.64.0/18 covers third octets 64 to 127 (block size 64), so 100 is inside it.

  2. Entries matching the destination are /8, /16, /18 and /0.

  3. Longest prefix is /18, so the packet goes to R3.

PRACTICE 61 mark · NAT

An IPv4 fragment has fragment offset 100, header length field (HLEN) 5 and total length 300 bytes. Numbering the bytes of the original datagram's data from 0, what is the number of the last data byte in this fragment?

Answer and solution

Answer:

  1. Header length = 5 x 4 = 20 bytes, so this fragment carries 300 - 20 = 280 bytes of data.

  2. First data byte = 100 x 8 = 800.

  3. Last data byte = 800 + 280 - 1 = 1079.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE CS

IPv4 - Fragmentation, CIDR Notation, Network Address Translation

Preparing in Kolkata? IAE Academy's course for GATE CSE.