A field-by-field walkthrough of the IPv4 datagram header, covering each field's purpose and the 40-byte overhead (20-byte IP + 20-byte TCP) before any payload. Explains fragmentation and MTU: how a 4,000-byte datagram gets split into fragments of up to 1,480 bytes each over a 1,500-byte Ethernet link, with reassembly handled at the destination. Addresses why both IP and TCP carry checksums — they protect different scopes and must remain layer-independent. Concludes with IPv6's design decisions: 128-bit addresses, removal of fragmentation, elimination of the header checksum, fixed 40-byte header length, and replacement of broadcast with multicast and anycast.

10m read timeFrom newsletter.francofernando.com
Post cover image
Table of contents
The IPv4 Datagram FormatFragmentation and MTUWhy a Checksum at Two Layers?IPv6: What They Fixed

Questions this post answers

Why does IP have its own checksum if TCP already has a checksum?

The two checksums cover different data. The IP checksum protects only the 20-byte IP header — fields like destination address and TTL — while the TCP checksum covers the entire segment including payload. Because TTL decrements at every hop, the IP checksum must be recalculated at every router, but only over 20 bytes. Keeping them separate also preserves layer independence: IP can carry non-TCP payloads, and TCP can run over non-IP networks. Engineers reasoning about protocol design trade-offs find the deeper networking context on daily.dev.

How does IPv4 fragmentation work when a packet is too large for the link MTU?

A router splits the payload into fragments, each becoming a full IP datagram with its own header. For a 4,000-byte datagram (20-byte header, 3,980-byte payload) crossing a 1,500-byte MTU Ethernet link, each fragment carries up to 1,480 bytes of data. The result is two 1,480-byte fragments and one 1,020-byte fragment. All fragments share the original identifier; the offset field records each fragment's position; a flag bit marks the last fragment. Reassembly happens at the destination. Developers working on network-layer code track fragmentation edge cases and protocol updates on daily.dev.

What did IPv6 remove compared to IPv4 and why?

IPv6 eliminated fragmentation (routers drop oversized packets and return an ICMP 'packet too big' message instead), the header checksum (link and transport layers handle error detection), and variable-length options (the header is always a fixed 40 bytes, with extension headers appended separately). Broadcast was also removed in favour of multicast and anycast. Each removal targets a specific IPv4 pain point: fragility, per-hop recalculation cost, and unpredictable router processing time. Keeping up with protocol evolution and networking fundamentals is easier when daily.dev surfaces the relevant posts for you.

510 Impressions