IPv4 Packet Format Explained: Header Fields, Datagram & Fragmentation

COMPUTER NETWORKS • CHAPTER 26
IPv4 Packet Format Explained: Header Fields, Datagram & Fragmentation
An IPv4 packet may look like only a block of data, but before that data can travel across routers, the packet needs important instructions.

Where did the packet come from? Where should it go? How large is it? Which Transport Layer protocol is inside it? Can the packet be fragmented?

All this information is stored inside the IPv4 header.
Direct Answer

An IPv4 packet or IPv4 datagram contains an IPv4 header followed by payload data.

The minimum IPv4 header is 20 bytes and the maximum is 60 bytes.

Important header fields include Version, IHL, DSCP/ECN, Total Length, Identification, Flags, Fragment Offset, TTL, Protocol, Header Checksum, Source Address and Destination Address.

IPv4 also supports fragmentation when a packet is larger than the MTU of an outgoing link and fragmentation is allowed.

What Is an IPv4 Packet?

IPv4 Packet Format Explained: Header Fields, Datagram & Fragmentation

An IPv4 packet is the Network Layer data unit used by Internet Protocol version 4.

It carries data from a source IP address toward a destination IP address across interconnected networks.

Every IPv4 packet contains two main parts:

  • IPv4 Header
  • Payload or Data
Simple Definition: An IPv4 packet is a Network Layer packet containing an IPv4 header and the data being carried.

IPv4 Packet vs IPv4 Datagram

In IPv4 discussions, the words packet and datagram are often used for the same Network Layer unit.

You may therefore see:

IPv4 Packet ≈ IPv4 Datagram

In university questions, both terms normally refer to the complete IPv4 header plus payload.

Basic IPv4 Packet Structure

IPv4 HEADER
20 to 60 Bytes
PAYLOAD / DATA
TCP Segment, UDP Datagram or Other Data
Easy Trick: IPv4 Datagram = Header + Data

Complete IPv4 Header Format

The IPv4 header is organised in rows of 32 bits.

IPv4 Header — 32-Bit Format
0 4 8 12 16 20 24 31
Version 4 bits
IHL 4 bits
DSCP 6 bits
ECN 2 bits
Total Length 16 bits
Identification 16 bits
Flags 3 bits
Fragment Offset 13 bits
TTL 8 bits
Protocol 8 bits
Header Checksum 16 bits
Source IPv4 Address 32 bits
Destination IPv4 Address 32 bits
Options Variable length
Padding As required
Group 1 — Basic Packet Information Version, IHL, DSCP/ECN and Total Length.
Group 2 — Fragmentation Identification, Flags and Fragment Offset.
Group 3 — Delivery Control TTL, Protocol and Header Checksum.
Group 4 — Addressing Source and Destination IPv4 addresses.
Group 5 — Optional Information Options and Padding.
Best Header Memory Trick: Basic Info → Fragmentation → Delivery → Addresses → Options

IPv4 Header Size

The minimum IPv4 header is:

20 bytes

If options are present, the header can become larger.

The maximum IPv4 header size is:

60 bytes

1. Version Field

Version 4 bits

The Version field tells the receiver which IP version is being used.

For an IPv4 packet:

Version = 4

2. IHL — Internet Header Length

IHL tells us how large the IPv4 header is.

The field is 4 bits long.

But the IHL value does not directly store bytes.

It stores the number of:

32-bit words
IPv4 Header Size = IHL × 4 bytes
IHL = 5 5 × 4 = 20 bytes
Minimum Header
IHL = 6 6 × 4 = 24 bytes
IHL = 15 15 × 4 = 60 bytes
Maximum Header
IHL Trick: IHL × 4 = Header Bytes

3. DSCP and ECN Field

The 8-bit field after IHL was historically called the Type of Service field.

Modern use divides it into:

  • DSCP — 6 bits
  • ECN — 2 bits

DSCP

DSCP stands for Differentiated Services Code Point.

It can be used to classify traffic for different forwarding treatment.

ECN

ECN stands for Explicit Congestion Notification.

It can help compatible endpoints and routers signal congestion without depending only on packet loss.

4. Total Length Field

Total Length tells us the size of the complete IPv4 datagram.

Total Length = IPv4 Header + Payload

The field is 16 bits long.

Therefore the largest value it can represent is:

2^16 - 1
= 65,535 bytes
Important: Total Length includes both the IPv4 header and the data.

5. Identification Field

Identification is a 16-bit field used during IPv4 fragmentation.

When one original IPv4 datagram is fragmented, the fragments use the same Identification value so the destination can recognise that they belong to the same original datagram.

Identification Trick: Same Original Packet → Same Identification Value

6. IPv4 Flags Field

The Flags field contains 3 bits.

Bit 0 Reserved
Normally 0
DF Don't Fragment
MF More Fragments

7. DF — Don't Fragment Flag

DF tells routers whether the IPv4 datagram may be fragmented.

DF = 0
Fragmentation is allowed.
DF = 1
The packet must not be fragmented by an IPv4 router.

If DF is set and the packet is too large for the outgoing MTU, the router cannot fragment it.

8. MF — More Fragments Flag

MF tells the destination whether more fragments are still expected.

MF = 1
More fragments follow.
MF = 0
This is the final fragment.

9. Fragment Offset

Fragment Offset tells the destination where a fragment's payload belongs in the original datagram.

The field contains 13 bits.

It is measured in:

8-byte units
Fragment Offset = Starting Byte Position / 8
Except for the final fragment, fragment payload sizes are normally chosen as multiples of 8 bytes so the offset can be represented correctly.

10. TTL — Time To Live

TTL is an 8-bit field used to prevent packets from circulating forever if a routing loop occurs.

Each router decreases the TTL value as the packet is forwarded.

Source
TTL = 64
Router
TTL = 63
Next Router
TTL = 62

If TTL reaches zero, the packet is discarded.

The router normally sends an ICMP Time Exceeded message toward the source.

TTL Trick: Every Router → TTL Goes Down TTL 0 → Packet Dies

11. Protocol Field

The Protocol field tells the destination which upper-layer protocol is carried inside the IPv4 payload.

1
ICMP
6
TCP
17
UDP
41
IPv6 Encapsulation
Very Important Exam Values: ICMP = 1
TCP = 6
UDP = 17

12. IPv4 Header Checksum

The IPv4 Header Checksum is used to detect corruption in the IPv4 header.

Important: The IPv4 Header Checksum checks the header only. It does not protect the complete IPv4 payload.
Sender
Calculates IPv4 Header Checksum
Router
TTL changes, so header changes
Router
Recalculates Header Checksum
Why does a router recalculate it? Because TTL changes at every router, so the IPv4 header changes.

13. Source IPv4 Address

The Source Address field is 32 bits long.

It identifies the IPv4 address of the packet's source.

Example:
192.168.1.20

14. Destination IPv4 Address

The Destination Address field is also 32 bits long.

Routers use the destination address when making forwarding decisions.

Source Address: Where packet came from.

Destination Address: Where packet should go.

15. IPv4 Options

Options are optional fields that can extend the IPv4 header beyond its normal 20-byte minimum.

Options have historically supported functions such as:

  • Timestamp information
  • Route recording
  • Special routing controls

Options are not normally present in ordinary IPv4 traffic.

16. Padding

Padding is added when required so the IPv4 header ends on a 32-bit boundary.

This is necessary because IHL measures the header length in 32-bit words.

IPv4 Encapsulation

At the Internet Layer, IPv4 takes data from an upper-layer protocol and adds an IPv4 header.

IPv4 Header
TCP Segment / UDP Datagram / Other Payload
Encapsulation: Upper-Layer Data + IPv4 Header = IPv4 Datagram

What Is IPv4 Fragmentation?

IPv4 fragmentation divides one large IPv4 datagram into smaller fragments.

This may be necessary when the packet is larger than the MTU of an outgoing link and fragmentation is allowed.

ORIGINAL IPv4 DATAGRAM
Large Packet
Cannot Fit Smaller MTU
Fragment 1
IPv4 Header
+
Data Part 1
Fragment 2
IPv4 Header
+
Data Part 2
Final Fragment
IPv4 Header
+
Remaining Data

Why Does IPv4 Fragmentation Happen?

Different network links can have different MTUs.

Suppose:

IPv4 Packet = 4000 bytes
Outgoing Link MTU = 1500 bytes

A 4000-byte packet cannot fit directly into a 1500-byte MTU.

If DF is not set, IPv4 fragmentation may be used.

How IPv4 Fragmentation Works

  1. Router receives an IPv4 datagram.
  2. Router checks the outgoing interface MTU.
  3. If packet size is less than or equal to MTU, it forwards the packet normally.
  4. If packet is too large, router checks the DF flag.
  5. If DF = 1, the router cannot fragment it.
  6. If DF = 0, the router may divide the datagram into fragments.
  7. Each fragment receives its own IPv4 header.
  8. Identification, MF and Fragment Offset help the receiver reassemble the original packet.
Identification Same value in fragments from the same original datagram.
MF Tells whether additional fragments follow.
Fragment Offset Shows where fragment data belongs.
Total Length Gives the size of each individual fragment.

IPv4 Fragment Reassembly

IPv4 fragments are reassembled at the destination host.

F1
F2
F3
ORIGINAL IPv4 DATAGRAM
Reassembled at Destination
Important Exam Point: IPv4 routers may fragment packets, but intermediate routers do not normally reassemble them. Reassembly is performed at the final destination.

Important IPv4 Fragmentation Formulas

Original Data = Original Total Length - Original Header
Maximum Fragment Data = MTU - Header Size
Non-Final Fragment Data = Largest Multiple of 8 ≤ Maximum Fragment Data
Fragment Offset = Starting Data Position / 8
Fragment Total Length = Fragment Header + Fragment Data
Fragmentation Order: Remove header → Find available payload per MTU → Make it multiple of 8 → Divide data → Calculate offsets → Set MF.

Solved IPv4 Fragmentation Numerical

An IPv4 datagram has:

Total Length = 4000 bytes
IPv4 Header = 20 bytes
Outgoing MTU = 1500 bytes

Step 1: Find Original Payload

Data = 4000 - 20
Data = 3980 bytes

Step 2: Maximum Data Per Full Fragment

MTU - Header
= 1500 - 20
= 1480 bytes

1480 is already divisible by 8.

Step 3: Divide Payload

Fragment 1 Data = 1480 bytes
Fragment 2 Data = 1480 bytes
Remaining = 3980 - 2960
Fragment 3 Data = 1020 bytes

Step 4: Fragment Offsets

Fragment 1 Offset = 0 / 8 = 0
Fragment 2 Offset = 1480 / 8 = 185
Fragment 3 Offset = 2960 / 8 = 370

Final Fragmentation Table

Fragment Data Size Total Length Offset MF
1 1480 bytes 1500 bytes 0 1
2 1480 bytes 1500 bytes 185 1
3 1020 bytes 1040 bytes 370 0
Final Answer: 3 fragments
Offsets = 0, 185, 370
MF = 1, 1, 0

Solved IHL Numerical

Suppose an IPv4 packet has:

IHL = 7

Find header size.

Header Size = IHL × 4
= 7 × 4
= 28 bytes
Answer = 28 bytes

Solved Total Length Numerical

Suppose:

IPv4 Header = 20 bytes
Payload = 1200 bytes
Total Length = Header + Payload
= 20 + 1200
= 1220 bytes
Answer = 1220 bytes

IPv4 + TCP Overhead Numerical

Assume:

Application Data = 1000 bytes
TCP Header = 20 bytes
IPv4 Header = 20 bytes
TCP Segment = 1000 + 20
= 1020 bytes
IPv4 Packet = 1020 + 20
= 1040 bytes
Answer = 1040-byte IPv4 packet

Segment vs Packet vs Frame

TCP Segment Transport Layer data unit containing TCP header and data.
IPv4 Packet Network Layer data unit containing IPv4 header and payload.
Frame Data Link Layer unit used for delivery across a local link.
Easy Encapsulation Order: Data → Segment → Packet → Frame → Bits

IPv4 vs IPv6 Fragmentation

Point IPv4 IPv6
Router Fragmentation Allowed when required and DF permits it Transit routers do not fragment
Source Fragmentation Possible Performed by source when required
Fragment Fields Identification, Flags and Offset are in IPv4 header Uses Fragment extension header
Reassembly Destination Destination

IPv4 Packet Format Remember Tricks

Header Groups: Basic Info → Fragmentation → Delivery → Addresses → Options
IHL: IHL × 4 = Header Size in Bytes
Fragmentation: ID = Which original packet?
MF = More fragments?
Offset = Where does this data belong?
TTL: Every router reduces TTL.
Protocol Numbers: ICMP = 1
TCP = 6
UDP = 17
Packet Formula: Total Length = Header + Data

Common IPv4 Packet Format Exam Mistakes

1. IHL directly gives the header size in bytes.

Wrong. IHL gives the number of 32-bit words. Multiply it by 4 to get bytes.
2. Minimum IPv4 header is 32 bytes.

Wrong. Minimum IPv4 header is 20 bytes.
3. IPv4 Total Length contains payload only.

Wrong. It contains header plus payload.
4. IPv4 Header Checksum checks the complete payload.

Wrong. It checks only the IPv4 header.
5. TTL represents time in seconds only.

In normal forwarding behaviour, routers reduce the TTL value as packets cross router hops.
6. DF = 1 means fragmentation is allowed.

Wrong. DF = 1 means Don't Fragment.
7. MF = 0 always means the packet was never fragmented.

Wrong. MF = 0 also appears on the final fragment.
8. Fragment Offset is measured directly in bytes.

Wrong. It is measured in units of 8 bytes.
9. Every fragment has a different Identification value.

Wrong. Fragments belonging to the same original datagram use the same Identification value.
10. Routers reassemble fragments before every next hop.

Wrong. IPv4 fragments are reassembled at the destination.
11. Protocol field contains a port number.

Wrong. It identifies the upper-layer protocol, such as TCP or UDP.
12. Source and Destination IPv4 fields are 16 bits each.

Wrong. Each IPv4 address field is 32 bits.

40 Important IPv4 Packet Format Questions With Answers

1. What is an IPv4 packet?
An IPv4 packet is a Network Layer data unit containing an IPv4 header and payload data.
2. What are the two main parts of an IPv4 datagram?
IPv4 header and payload.
3. What is the minimum IPv4 header size?
20 bytes.
4. What is the maximum IPv4 header size?
60 bytes.
5. What is the size of the Version field?
The Version field is 4 bits.
6. What value is stored in the Version field for IPv4?
The value is 4.
7. What does IHL stand for?
Internet Header Length.
8. How is IPv4 header length calculated from IHL?
Header length in bytes equals IHL multiplied by 4.
9. What does IHL = 5 mean?
It means the header contains 5 × 4 = 20 bytes.
10. What is the maximum possible IHL value?
15, producing a 60-byte IPv4 header.
11. What is DSCP used for?
DSCP can classify traffic so network devices may apply differentiated forwarding treatment.
12. What is ECN?
ECN stands for Explicit Congestion Notification and can signal congestion through packet marking when supported.
13. What does Total Length represent?
It represents the complete IPv4 datagram size, including both header and payload.
14. What is the maximum IPv4 Total Length value?
65,535 bytes.
15. What is the Identification field used for?
It helps group IPv4 fragments that belong to the same original datagram.
16. What is the size of the Identification field?
16 bits.
17. How many bits are present in the IPv4 Flags field?
3 bits.
18. What does DF mean?
DF means Don't Fragment.
19. What does DF = 1 mean?
The packet must not be fragmented by an IPv4 router.
20. What does MF mean?
MF means More Fragments.
21. What does MF = 1 mean?
More fragments follow after the current fragment.
22. What does MF = 0 mean in a fragmented datagram?
It indicates the final fragment.
23. What is Fragment Offset?
It tells the destination where a fragment's data belongs inside the original datagram.
24. In what units is Fragment Offset measured?
In units of 8 bytes.
25. What is TTL?
TTL means Time To Live and limits how long a packet can continue across routers.
26. What happens to TTL at each router?
The router decreases the TTL value before forwarding the packet.
27. What happens when TTL reaches zero?
The packet is discarded and an ICMP Time Exceeded message is normally generated.
28. What is the purpose of the Protocol field?
It identifies the upper-layer protocol contained in the IPv4 payload.
29. What Protocol number represents TCP?
6.
30. What Protocol number represents UDP?
17.
31. What Protocol number represents ICMP?
1.
32. What is the IPv4 Header Checksum used for?
It is used to detect errors in the IPv4 header.
33. Does the IPv4 Header Checksum protect the payload?
No. It protects only the IPv4 header.
34. Why must routers update the IPv4 Header Checksum?
Because fields such as TTL change during forwarding, so the header checksum must be recalculated.
35. What is the size of the Source IPv4 Address field?
32 bits.
36. What is the purpose of Padding?
Padding makes the IPv4 header length end on a 32-bit boundary when options are present.
37. Where are IPv4 fragments reassembled?
At the final destination host.
38. A packet starts with TTL 10 and crosses three routers. What TTL remains?
10 - 3 = 7.
39. If IHL = 8, what is the IPv4 header size?
8 × 4 = 32 bytes.
40. Give the easiest IPv4 header memory method.
Remember the header in groups: Basic Information, Fragmentation, Delivery Control, Addresses and Optional Information.

20 IPv4 Packet Format MCQs With Answers

1. Minimum IPv4 header size is:

A. 8 bytes
B. 20 bytes
C. 32 bytes
D. 64 bytes

Answer: B — 20 bytes
2. Maximum IPv4 header size is:

A. 40 bytes
B. 48 bytes
C. 60 bytes
D. 64 bytes

Answer: C — 60 bytes
3. IPv4 Version field contains:

A. 4
B. 6
C. 8
D. 32

Answer: A — 4
4. IHL is measured in:

A. 32-bit words
B. Bytes directly
C. Kilobytes
D. Seconds

Answer: A
5. IHL = 5 means header size is:

A. 5 bytes
B. 10 bytes
C. 20 bytes
D. 40 bytes

Answer: C — 20 bytes
6. Total Length includes:

A. Header only
B. Payload only
C. Header + Payload
D. MAC header only

Answer: C
7. Maximum IPv4 Total Length is:

A. 1500 bytes
B. 65,535 bytes
C. 4096 bytes
D. 255 bytes

Answer: B — 65,535 bytes
8. DF means:

A. Data Fragment
B. Don't Fragment
C. Destination Flag
D. Direct Frame

Answer: B — Don't Fragment
9. MF means:

A. More Fragments
B. Main Frame
C. Maximum Fragment
D. Multiple Format

Answer: A — More Fragments
10. MF = 0 on a fragmented packet means:

A. More fragments follow
B. Final fragment
C. Fragment corrupted
D. Fragment offset zero

Answer: B — Final fragment
11. Fragment Offset is measured in:

A. 8-byte units
B. 16-byte units
C. Bits only
D. Seconds

Answer: A
12. TTL is reduced by:

A. Routers
B. Browsers only
C. DNS only
D. Switches only

Answer: A — Routers
13. TCP Protocol number in IPv4 is:

A. 1
B. 6
C. 17
D. 32

Answer: B — 6
14. UDP Protocol number is:

A. 1
B. 6
C. 17
D. 41

Answer: C — 17
15. ICMP Protocol number is:

A. 1
B. 6
C. 17
D. 20

Answer: A — 1
16. IPv4 Header Checksum protects:

A. IPv4 header only
B. Entire Ethernet frame
C. Application payload only
D. TCP payload only

Answer: A
17. Source IPv4 Address field is:

A. 8 bits
B. 16 bits
C. 32 bits
D. 64 bits

Answer: C — 32 bits
18. IPv4 fragments are reassembled at:

A. Final destination
B. Every router
C. First switch
D. DNS server

Answer: A
19. Which field identifies the upper-layer protocol?

A. Protocol
B. TTL
C. IHL
D. Identification

Answer: A — Protocol
20. If IHL = 10, header length is:

A. 10 bytes
B. 20 bytes
C. 32 bytes
D. 40 bytes

Answer: D — 40 bytes

Frequently Asked Questions

What is an IPv4 packet?

An IPv4 packet is a Network Layer data unit containing an IPv4 header followed by payload data.

What is the minimum IPv4 header size?

The minimum IPv4 header size is 20 bytes.

What is the maximum IPv4 header size?

The maximum IPv4 header size is 60 bytes.

What does IHL mean?

IHL means Internet Header Length. Its value represents the number of 32-bit words in the IPv4 header.

What does the Total Length field contain?

It contains the complete IPv4 datagram length, including the header and payload.

What is the purpose of TTL?

TTL prevents packets from circulating forever by being reduced as packets cross routers.

What is the IPv4 Protocol field?

It identifies the protocol carried in the IPv4 payload, such as TCP, UDP or ICMP.

What is IPv4 fragmentation?

IPv4 fragmentation divides a large datagram into smaller fragments so it can cross a link with a smaller MTU.

What is Fragment Offset?

Fragment Offset indicates where a fragment's payload belongs within the original datagram and is measured in units of 8 bytes.

What is the difference between DF and MF?

DF controls whether fragmentation is allowed, while MF indicates whether more fragments follow the current fragment.

Where are IPv4 fragments reassembled?

They are reassembled at the final destination host.

Does IPv4 Header Checksum check the payload?

No. IPv4 Header Checksum protects only the IPv4 header.

Quick IPv4 Packet Format Revision

IPv4 Packet: Header + Payload.
Minimum Header: 20 bytes.
Maximum Header: 60 bytes.
Version: 4.
IHL: Header length in 32-bit words.
Total Length: Header + Payload.
Maximum Total Length: 65,535 bytes.
Identification: Groups fragments of one original datagram.
DF: Don't Fragment.
MF: More Fragments.
Fragment Offset: 8-byte units.
TTL: Reduced by routers.
Protocol 1: ICMP.
Protocol 6: TCP.
Protocol 17: UDP.
Header Checksum: Protects IPv4 header only.
Source Address: 32 bits.
Destination Address: 32 bits.

Final Memory Trick:

Version tells which IP.
IHL tells header size.
Total Length tells packet size.
ID + Flags + Offset handle fragmentation.
TTL stops endless loops.
Protocol tells what comes next.
Checksum checks the header.
Source and Destination tell where the packet comes from and where it has to go.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources