wire / wire-format / ipv4-header
The IPv4 datagram header is at least 20 bytes: version/IHL, DSCP/ECN, total length, identification/flags/fragment-offset for fragmentation, TTL, protocol, header checksum, and the 32-bit source and destination addresses, followed by optional options. The IHL field gives the header length in 32-bit words.
aka: IP header · Internet Protocol v4 header
spec: RFC 791
Minimum 20-byte header. Carries addressing, fragmentation, a TTL hop limit, a protocol selector pointing at the next header (6 = TCP, 17 = UDP, 1 = ICMP), and a header-only checksum.
| field | size | meaning |
|---|---|---|
| Version | 4 bits | IP version, 4 for IPv4. |
| IHL | 4 bits | Internet Header Length in 32-bit words (5 = 20 bytes minimum, up to 15 = 60 bytes). |
| DSCP | 6 bits | Differentiated Services Code Point (QoS class); originally the Type of Service field. |
| ECN | 2 bits | Explicit Congestion Notification. |
| Total Length | 16 bits | Entire datagram size (header + data) in bytes, up to 65535. |
| Identification | 16 bits | Fragment group id, used to reassemble fragments of one datagram. |
| Flags | 3 bits | Bit 0 reserved (0), DF (Don't Fragment), MF (More Fragments). |
| Fragment Offset | 13 bits | Position of this fragment in the original datagram, in 8-byte units. |
| Time to Live (TTL) | 8 bits | Hop limit; decremented by each router, datagram dropped at 0. |
| Protocol | 8 bits | Next-layer protocol (per IANA): 1 ICMP, 6 TCP, 17 UDP, 41 IPv6-in-IPv4. |
| Header Checksum | 16 bits | Ones-complement checksum over the header only; recomputed at each hop (TTL changes). |
| Source Address | 32 bits | Sender IPv4 address. |
| Destination Address | 32 bits | Receiver IPv4 address. |
| Options | variable | Optional (record route, timestamp, etc.), padded to a 32-bit boundary; present only when IHL > 5. |
example:
45 00 00 3C ...
First byte 0x45 = version 4, IHL 5 (20-byte header, no options). 0x00 = DSCP/ECN 0. 0x003C = total length 60 bytes.
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/ipv4-header
or /wire-format/ipv4-header.json