IPv4 and IPv6 Headers
The IP header is the control panel of Layer 3. Every field exists for a reason, and the exam expects you to know the exact bit widths of both the IPv4 and the IPv6 header — including the fact that IPv6 uses a fixed 40-byte header with no checksum.
Why the header matters
An IP packet is a header plus a payload. The payload is the transport-layer segment that IP carries without looking inside it; the header is the metadata routers need to do their job. Fields such as the source and destination address tell a router where the packet is from and where it is going. The protocol number tells the receiving host which upper-layer protocol should get the payload. TTL/hop limit stops packets looping forever, and the checksum (in IPv4) detects corruption of the header.
Because the header format is fixed and public, two routers from different vendors on different continents can read each other’s packets. That interoperability is exactly why the layout is standardised in an RFC and why exam questions test the field widths so heavily: change a field width and every device on Earth stops understanding the packet.
The IPv4 header layout
IPv4 is defined in RFC 791. Its header is drawn as five rows of 32 bits (four bytes). The first byte contains two four-bit halves: the Version and the Internet Header Length (IHL). When no options are present the header is exactly 5 words × 4 bytes = 20 bytes, the minimum.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version| IHL | DSCP ECN | Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification | Flg | Fragment Offset | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL | Protocol | Header Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options + Padding (0-40 bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
IPv4 fields, field by field
Learn this table exactly. The widths are the single most commonly tested numbers in this lesson.
| Field | Width | Purpose |
|---|---|---|
| Version | 4 bits | IP version number; = 4 for IPv4. |
| IHL (Internet Header Length) | 4 bits | Header length in 32-bit words; minimum 5 (= 20 bytes). |
| DSCP + ECN (Type of Service) | 8 bits | DSCP (6 bits): QoS marking. ECN (2 bits): congestion signalling. |
| Total Length | 16 bits | Whole packet size, header + payload, in bytes; maximum 65,535. |
| Identification | 16 bits | Tags all fragments that came from one original packet. |
| Flags | 3 bits | Bit 1 reserved; DF (Don’t Fragment); MF (More Fragments). |
| Fragment Offset | 13 bits | Position of this fragment in 8-byte units. |
| Time to Live (TTL) | 8 bits | Decremented by 1 at every router; at 0 the packet is dropped. |
| Protocol | 8 bits | Payload type: 1 = ICMP, 6 = TCP, 17 = UDP. |
| Header Checksum | 16 bits | Error check over the header only; recomputed at every hop. |
| Source Address | 32 bits | The sender’s IPv4 address. |
| Destination Address | 32 bits | The final receiver’s IPv4 address. |
| Options + Padding | 0–40 bytes | Optional features; padding aligns the header to a 4-byte boundary. |
The IPv6 header layout
IPv6 is defined in RFC 8200. It was designed to be simpler and faster for routers. The address grew from 32 to 128 bits, but the header stayed small because fields that were optional or per-hop were removed from the base header. Its layout is exactly two rows of 32 bits, then the two large address rows:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Vers | Traffic Class | Flow Label | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Payload Length | Next Hdr | Hop Limit | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address (128 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address (128 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
IPv6 fields, field by field
| Field | Width | Purpose |
|---|---|---|
| Version | 4 bits | IP version number; = 6 for IPv6. |
| Traffic Class | 8 bits | DSCP (6 bits) + ECN (2 bits) — same role as IPv4 ToS. |
| Flow Label | 20 bits | Labels a packet flow for special handling; rarely used in practice. |
| Payload Length | 16 bits | Size of everything that follows the 40-byte base header. |
| Next Header | 8 bits | Type of the next header: an extension header or an upper-layer protocol (TCP = 6, UDP = 17, ICMPv6 = 58). |
| Hop Limit | 8 bits | IPv6’s version of TTL: decremented by 1 at every router. |
| Source Address | 128 bits | The sender’s IPv6 address. |
| Destination Address | 128 bits | The final receiver’s IPv6 address. |
Add the widths: 4 + 8 + 20 = 32 bits on the first row, and 16 + 8 + 8 = 32 bits on the second, for 8 bytes of control fields. The two addresses add 32 bytes, giving the famous 40-byte IPv6 base header.
IPv4 vs IPv6, and extension headers
| Feature | IPv4 | IPv6 |
|---|---|---|
| Header size | 20–60 bytes (variable) | 40 bytes (fixed) |
| Address size | 32 bits | 128 bits |
| Header checksum | Yes, 16-bit, per hop | None |
| Header length field | IHL (4 bits) | None (fixed length) |
| Fragmentation | Routers may fragment | Routers never fragment — source uses Path MTU Discovery |
| Protocol / Next Header | Protocol (8 bits) | Next Header (8 bits) |
| Lifetime field | TTL (8 bits) | Hop Limit (8 bits) |
| Options | Inside the base header | Separate extension headers |
| Broadcast | Yes | No — uses multicast and anycast |
| Address configuration | Manual or DHCP | SLAAC, DHCPv6, or manual |
Extension headers
IPv4 puts rarely used options into the same header, which forces every router to check the IHL and slow down when options are present. IPv6 instead chains optional features as extension headers placed between the base header and the payload. The base header’s Next Header field says which one comes first, and each extension header has its own Next Header field, forming a linked list.
Examples include the Hop-by-Hop Options header, Routing header, Fragment header, and Destination Options header. This design keeps the fixed 40-byte base header fast: a router processes only the extension headers it is required to inspect.
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 791: Internet Protocol (1981), Section 3.1 (header format and all IPv4 field widths). rfc-editor.org/rfc/rfc791.
- Deering, S. & Hinden, R. RFC 8200: Internet Protocol, Version 6 (IPv6) Specification (2017), Section 3 (IPv6 header format). rfc-editor.org/rfc/rfc8200.
- Postel, J. RFC 768: User Datagram Protocol (1980) — protocol number 17. rfc-editor.org/rfc/rfc768.
- Postel, J. RFC 793: Transmission Control Protocol (1981) — protocol number 6. rfc-editor.org/rfc/rfc793.
- Postel, J. RFC 792: Internet Control Message Protocol (1981) — protocol number 1. rfc-editor.org/rfc/rfc792.
- Cisco. CCNA (200-301) Exam Topics, Network Fundamentals. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.