Back to the 2024 paper

Module 3: Network Layer & Routing

20247m

Draw IPv4 header format and explain each field of the header. Also explain the concept of fragmentation in detail.

Worked SolutionAI Assisted

IPv4 header format

The IPv4 header is 20 bytes minimum (up to 60 bytes with options), in 32-bit words:

 0       4       8              16      19                    31
+-------+-------+---------------+-----------------------------+
|Version|  IHL  | DSCP/ToS (8)  |        Total Length (16)     |
+-------+-------+---------------+-----+-----------------------+
|      Identification (16)      |Flags|   Fragment Offset (13) |
+---------------+---------------+-----+-----------------------+
|  TTL (8)      | Protocol (8)  |      Header Checksum (16)    |
+---------------+---------------+-----------------------------+
|                  Source IP Address (32)                      |
+--------------------------------------------------------------+
|                Destination IP Address (32)                   |
+--------------------------------------------------------------+
|                Options (variable) + Padding                  |
+--------------------------------------------------------------+

Fields

Field Size Description
Version 4 bits IP version = 4
IHL (Header Length) 4 bits Header length in 32-bit words (min 5 = 20 bytes, max 15 = 60 bytes)
DSCP / Type of Service 8 bits Priority and quality-of-service marking (DSCP + ECN)
Total Length 16 bits Length of the whole datagram (header + data) in bytes; max 65,535
Identification 16 bits Unique ID of the datagram; all fragments of one datagram carry the same ID, used for reassembly
Flags 3 bits Bit 0 reserved; DF (Don't Fragment); MF (More Fragments: 1 = more follow, 0 = last fragment)
Fragment Offset 13 bits Position of this fragment's data in the original datagram, in units of 8 bytes
TTL (Time To Live) 8 bits Hop limit, decremented by each router; the packet is discarded at 0 (prevents loops)
Protocol 8 bits Upper-layer protocol: 1 = ICMP, 6 = TCP, 17 = UDP
Header Checksum 16 bits Error check on the header only (recomputed at each router as TTL changes)
Source Address 32 bits IP address of the sender
Destination Address 32 bits IP address of the receiver
Options 0–40 bytes Optional: record route, timestamp, security, source routing
Padding variable Zeros to make the header a multiple of 32 bits

Fragmentation

Why: every link has a Maximum Transmission Unit (MTU), the largest frame payload it can carry (Ethernet = 1500 bytes). If a datagram is larger than the MTU of the outgoing link, the router splits it into smaller fragments.

Rules:

  1. Each fragment gets its own IP header (a copy of the original with changed fields).
  2. Identification is copied unchanged, so the destination can group fragments.
  3. MF = 1 for all fragments except the last (MF = 0).
  4. Fragment offset = (byte position of the fragment's data) / 8, so every fragment except the last must carry data that is a multiple of 8 bytes.
  5. Total length and checksum are recomputed for each fragment.
  6. If DF = 1 and fragmentation is required, the packet is dropped and an ICMP "Fragmentation needed" message is sent back.
  7. Reassembly happens only at the final destination, not at intermediate routers. If any fragment is lost, the whole datagram is discarded after a timeout.

Example

A datagram of 4000 bytes (20-byte header + 3980 data) crosses a link with MTU = 1500.

Max data per fragment = 1500 − 20 = 1480 bytes (1480 / 8 = 185, a whole number, good).

Fragment Data bytes Total length Offset (bytes) Fragment Offset field MF
1 1480 1500 0 0 1
2 1480 1500 1480 185 1
3 1020 1040 2960 370 0

Check: 1480 + 1480 + 1020 = 3980 data bytes.

Drawbacks: extra header overhead, extra router processing, and higher loss probability. IPv6 removes router fragmentation; only the source fragments, after Path MTU Discovery.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.