BuildTheNet

Opening your workspace

Your learning content and tools are loading.

Learning paths › CCNA › 1. Network Fundamentals

IPv4 Header

Inspect every field of the IPv4 packet header: Version, IHL, DSCP, ECN, Packet Length, Fragmentation flags, TTL, and Protocol numbers.

About 11 minutes

Why it matters

Fields like TTL and the protocol number explain what you see in ping, traceroute and packet captures. Knowing the header makes those tools readable.

Anatomy of an IPv4 Packet Header

The standard IPv4 header is 20 bytes (up to 60 bytes with optional fields).

Internet Header Length (IHL) is 4 bits: it divides the header byte count by 4 (minimum value is 5, meaning 20 bytes).

Time to Live (TTL) is decremented by 1 at every router hop to prevent packets from looping infinitely.

Protocol numbers identify the encapsulated Layer 4 payload: 1 for ICMP, 6 for TCP, 17 for UDP, 89 for OSPF.

Header Size and IHL Word Calculation

Because options can be added, the IPv4 header is variable length (20 to 60 bytes).

• The IHL field is 4 bits (maximum decimal value 15). • To fit up to 60 bytes into 4 bits, IHL measures header length in 4-byte (32-bit) words. • When receiving an IPv4 packet, the router multiplies the IHL value by 4 to get the header length in bytes (e.g. IHL 5 * 4 = 20 bytes).

Packet Fragmentation & MTU

Standard Ethernet MTU (Maximum Transmission Unit) is 1500 bytes. If a router receives a packet larger than the outgoing interface's MTU: 1. If DF bit = 0: The router splits the payload into fragments, assigns them the same Identification number, and sets the Fragment Offset to specify where each piece fits. 2. If DF bit = 1 (Don't Fragment): The router drops the packet and sends an ICMP 'Fragmentation Needed and DF set' error back to the sender.

Time to Live (TTL) & Routing Loops

TTL prevents packets from circulating forever in a routing loop: • Default TTL values are typically 64, 128, or 255. • Each router that forwards the packet decrements TTL by 1. • When a router receives a packet with TTL = 1, it decrements it to 0, drops the packet, and sends an ICMP Time Exceeded (Type 11) message back to the source. • Traceroute utilities intentionally send packets with increasing TTLs (1, 2, 3...) to discover each router hop along a path.

IPv4 Header Fields Layout

Bit Offset: Bits 0 - 3 · Field Name: Version · Field Length: 4 bits · Primary Function: Identifies IP version (always 0100 for IPv4)

Bit Offset: Bits 4 - 7 · Field Name: IHL (Internet Header Length) · Field Length: 4 bits · Primary Function: Length of header in 4-byte words (min 5 = 20 bytes)

Bit Offset: Bits 8 - 13 · Field Name: DSCP · Field Length: 6 bits · Primary Function: Quality of Service priority classification

Bit Offset: Bits 14 - 15 · Field Name: ECN · Field Length: 2 bits · Primary Function: Explicit Congestion Notification without dropping packets

Bit Offset: Bits 16 - 31 · Field Name: Total Length · Field Length: 16 bits · Primary Function: Total length of packet (header + payload) in bytes

Bit Offset: Bits 32 - 47 · Field Name: Identification · Field Length: 16 bits · Primary Function: Unique ID to link fragmented packets together

Bit Offset: Bits 48 - 50 · Field Name: Flags · Field Length: 3 bits · Primary Function: Bit 0: Reserved (0), Bit 1: DF (Don't Fragment), Bit 2: MF (More Fragments)

Bit Offset: Bits 51 - 63 · Field Name: Fragment Offset · Field Length: 13 bits · Primary Function: Position of the fragment within the original packet

Bit Offset: Bits 64 - 71 · Field Name: TTL (Time to Live) · Field Length: 8 bits · Primary Function: Hop count limiter to prevent endless routing loops

Bit Offset: Bits 72 - 79 · Field Name: Protocol · Field Length: 8 bits · Primary Function: Layer 4 protocol (1 ICMP, 6 TCP, 17 UDP, 89 OSPF)

Bit Offset: Bits 80 - 95 · Field Name: Header Checksum · Field Length: 16 bits · Primary Function: Error detection checksum for the IPv4 header

Bit Offset: Bits 96 - 127 · Field Name: Source IP Address · Field Length: 32 bits · Primary Function: IPv4 address of the original sender

Bit Offset: Bits 128 - 159 · Field Name: Destination IP Address · Field Length: 32 bits · Primary Function: IPv4 address of the intended recipient

Bit Offset: Bits 160+ · Field Name: Options (if IHL > 5) · Field Length: 0 - 320 bits · Primary Function: Optional debugging/security parameters (rarely used)

The words you need

IHL — Internet Header Length (4 bits). Specifies the header size in 32-bit (4-byte) words. Minimum is 5 (5 * 4 = 20 bytes); maximum is 15 (60 bytes).

DSCP — Differentiated Services Code Point (6 bits). Used by Quality of Service (QoS) to prioritize delay-sensitive traffic like voice and video.

ECN — Explicit Congestion Notification (2 bits). Provides end-to-end notification of network congestion without having to drop packets.

Total Length — 16-bit field showing the entire length of the packet in bytes (Layer 3 header + Layer 4 payload). Maximum size is 65,535 bytes.

Identification — 16-bit number assigned to a packet to help reassemble fragments if the packet is split across a lower MTU.

DF Bit — Don't Fragment flag (1 bit). If set to 1, routers are forbidden from fragmenting the packet and must drop it if it exceeds the MTU.

MF Bit — More Fragments flag (1 bit). Set to 1 if more fragments follow; set to 0 for the last fragment or unfragmented packets.

TTL (Time to Live) — 8-bit field decremented by 1 at every router hop. When TTL reaches 0, the router discards the packet and sends an ICMP Time Exceeded message.

Header Checksum — 16-bit error-checking field that protects only the IPv4 header (recalculated at every hop because TTL changes).

Takeaways

Next: Wireless RF & Frequencies

More free lessons in 1. Network Fundamentals