
The IPv4 header is a variable Layer 3 header (RFC 791, 20–60 bytes) containing everything a router uses to forward, fragment and deliver IPv4 packets.
Facts / key topics
- Standard / RFC: RFC 791 · OSI layer: Layer 3 (Network)
- Header length: 20–60 bytes (20 bytes without options)
- Checksum: ✔ yes (header only) · Broadcast: ✔ yes
- CCNA vs CCNP: CCNA – fields, length, fragmentation, TTL; CCNP – performance, checksum impact, MTU/fragmentation in designs
- Where: LAN, WAN, Internet (still dominant)
Field-by-field
- Version (4 bits): IPv4 = 0100, IPv6 = 0110
- IHL (4 bits): Internet Header Length, 5–15 × 32-bit words
- TOS / DS field (8 bits): 6-bit DSCP (prioritize delay-sensitive traffic) + 2-bit ECN
- Total Length (16 bits): min 20 – max 65,535
- Identification (16 bits): fragment ID, max 2¹⁶−1 = 65,535
- Flags (3 bits): bit 0 reserved (0) · bit 1 = Don’t Fragment · bit 2 = More Fragments
- Fragment Offset (13 bits): position of the fragment in the original packet (min 0, max 320 words / 40 bytes scaling)
- TTL (8 bits): loop prevention, standard 64
- Protocol (8 bits): L4 protocol (TCP=6, UDP=17)
- Header Checksum (16 bits): recomputed at every hop
- Source IP / Destination IP (32 bits each)
- Options + Padding: variable, rarely used
How it works, step by step
- Packet created: host builds the IPv4 header (min 20 bytes).
- Forwarding: router checks destination IP, decrements TTL by 1, recomputes the header checksum.
- Fragmentation (if needed): if the MTU is too small the router fragments, setting MF + Fragment Offset.
- Error/recovery: TTL = 0 → drop + ICMP Time Exceeded; DF set + MTU too small → ICMP Fragmentation Needed.
Fields (exam critical)
| Field | Size | Explanation |
|---|---|---|
| Version | 4 bits | Always 4 |
| IHL | 4 bits | Header length |
| DSCP / ECN | 8 bits | QoS |
| Total Length | 16 bits | Header + data |
| Identification | 16 bits | Fragment ID |
| Flags | 3 bits | DF / MF |
| Fragment Offset | 13 bits | Fragment position |
| TTL | 8 bits | Loop prevention |
| Protocol | 8 bits | L4 protocol (TCP=6, UDP=17) |
| Header Checksum | 16 bits | Error detection |
| Source IP | 32 bits | Sender |
| Destination IP | 32 bits | Receiver |
| Options | variable | Rarely used |
| Padding | variable | Alignment |
Key terminology
| Term | Explanation |
|---|---|
| IHL | Internet Header Length |
| TTL | Time To Live |
| DF | Don’t Fragment |
| MF | More Fragments |
| Fragment Offset | Position in the original packet |
| Header Checksum | Recomputed at every hop |
Elements table
| Element | Description | CCNA | CCNP |
|---|---|---|---|
| Variable header | 20–60 bytes | ✔ | ✔ |
| Fragmentation | Router-based | ✔ | ✔ |
| TTL | Loop prevention | ✔ | ✔ |
| Checksum | CPU load | ✔ | ✔ |
| Options | Advanced use | ✖ | ✔ |
Dependencies & special considerations
- MTU-dependent fragmentation
- Checksum = performance hit on routers
- Options can cause slow-path forwarding and drops by hardware routers
- NAT breaks the end-to-end model
Design & best practices
- Avoid fragmentation (use PMTUD) · use the DF bit actively · avoid IPv4 options · understand ICMP’s role (must not be blindly blocked)
Exam tips ⚠️
- Minimum IPv4 header? → 20 bytes
- TTL decremented where? → on every router
- Fragmentation in IPv4? → routers MAY fragment
- Checksum covers what? → header only
- Protocol field vs Next Header? → IPv4 vs IPv6
30-second summary
- Variable 20–60 bytes · supports fragmentation and checksum · TTL prevents loops · options exist but are problematic · less efficient than IPv6
| Level | Expectation |
|---|---|
| CCNA | Header fields, TTL, fragmentation |
| CCNP | MTU design, performance, ICMP errors, IPv6 comparison |