The IPv4 (RFC 791) and IPv6 (RFC 8200) headers, with a toggle between them and the full writeup in deep-dive.md.
The IP header is layer 3 - it hands off to a transport header above and rides inside a link-layer frame below. Hover a row for the layer's own byte layout and a code snippet.
| IPv4 | IPv6 | |
|---|---|---|
| Header size | 20-60 bytes, variable (options) | 40 bytes, fixed - extensions are separate chained headers |
| Address length | 32 bits | 128 bits |
| Header checksum | yes - recomputed every hop | none - integrity pushed to upper layers |
| Fragmentation | routers may fragment in flight | source only, via a Fragment extension header |
| "next protocol" field | Protocol (byte 9) | Next Header (byte 6) - same IANA registry, same numbers |
| Broadcast | yes | none - multicast only |
| Address autoconfig | DHCP (or static) | SLAAC or DHCPv6 |
| Defining spec | RFC 791 (1981) | RFC 8200 (2017) |
First word (version, traffic class, flow label) is bit-packed, so it's drawn bit by bit. Everything after it is byte-aligned - payload length, next header, hop limit, then the two 128-bit addresses drawn byte by byte.
Version+IHL+DSCP+ECN pack into the first 2 bytes, so they're drawn bit by bit; Total Length and Identification are byte-aligned; Flags+Fragment Offset pack into 2 more bits; TTL, Protocol, Checksum, and both addresses are byte-aligned.
2001:db8::/32 for IPv6 (RFC 3849) and 192.0.2.0/24 / 203.0.113.0/24 for IPv4 (RFC 5737) - so nothing here is a real routable host.