4.3.11 · D2Computer Networks

Visual walkthrough — IPv6 — address format, why needed, key differences

1,614 words7 min readBack to topic

Nothing here assumes you know hexadecimal, colons, or what :: means. We earn each symbol before we use it. If you want a refresher on the number systems, see Hexadecimal and Binary Number Systems.


Step 1 — What is a bit, and why 128 of them?

WHAT. A bit is a single box that holds one of two things: 0 or 1. Nothing else fits. An IPv6 address is just 128 of these boxes in a row.

WHY. Every box doubles how many different patterns you can make. One box → 2 patterns. Two boxes → 4. So boxes give patterns. IPv6 chose so that the number of distinct addresses is

That is a number with 39 digits — more addresses than there are grains of sand on Earth.

PICTURE. The blueprint below shows the 128 boxes as a strip. Notice how the count of patterns explodes as boxes are added (the amber curve).


Step 2 — Chop 128 bits into 8 groups of 16

WHAT. Reading 128 zeros and ones is impossible for a human. So we chop the strip into 8 equal chunks, each chunk being 16 bits. Each chunk is called a hextet (a "group").

WHY 8 × 16? Because — the chop is exact, no leftover bits. Eight is small enough to say out loud, sixteen is a natural half of thirty-two (the old IPv4 size doubled twice).

PICTURE. The strip from Step 1 now has 7 cut-lines splitting it into 8 labelled blocks.


Step 3 — Turn each 16-bit group into 4 hex digits

WHAT. Sixteen bits is still 16 boxes. We compress each group by writing it in hexadecimal — a way of counting where a single digit runs 0 1 2 3 4 5 6 7 8 9 a b c d e f (that's 16 symbols; a=10, ..., f=15).

WHY hex and not decimal? One hex digit stands for exactly 4 bits, because 4 bits make patterns and hex has exactly 16 symbols. The match is perfect. So:

Across all 8 groups: hex digits total. Decimal would not line up with bit boundaries (10 is not a power of 2), so hex wins.

PICTURE. One 16-bit group is sliced into four 4-bit nibbles; each nibble maps to one hex digit.


Step 4 — Glue the groups with colons: the full address

WHAT. Write the 8 hextets left to right, and put a ==colon :== between neighbours (7 colons for 8 groups). This is the uncompressed address.

WHY colons and not dots? IPv4 used dots for 4 groups. IPv6 deliberately uses a different separator (colon) so you can tell the two apart at a glance, and because hex digits already include letters.

PICTURE. The 8 groups laid out with their colon glue and the running bit-count checked underneath.


Step 5 — Rule 1: drop the leading zeros

WHAT. Inside each group separately, erase zeros that sit at the front. 0db8 → db8, 0000 → 0, 0042 → 42, ff00 stays ff00 (its zeros are at the back, they count).

WHY it's safe. A leading zero adds no value, exactly like 007 means 7. Because each group is a fixed 16-bit slot, the reader knows to re-pad the front later. You may never drop trailing zerosff00 and ff are different numbers.

Our address becomes:

PICTURE. Each group shows its front zeros struck through in amber, its kept digits in cyan.


Step 6 — Rule 2: collapse the longest zero-run with ::

WHAT. Find the longest run of groups that are entirely zero. Here groups 3, 4, 5 are all 0 — a run of length 3. Replace that whole run with a single ==double colon ::==.

WHY only once. :: is a promise: "insert as many all-zero groups as are needed to bring the total back to 8." A parser recovers the missing count by subtraction: it sees the groups you did write, and fills the gap. With two ::, that subtraction has more than one answer — the address becomes ambiguous. So :: is legal at most once.

Final compressed form:

PICTURE. The three zero-groups collapse into one amber ::; the arithmetic is shown as the recovery rule.


Step 7 — Edge case A: a tie between two zero-runs

WHAT. Take 2001:db8:0:0:1:0:0:1. Two separate zero-runs: groups 3–4 (length 2) and groups 6–7 (length 2). It's a tie.

WHY the rule. Since :: may appear only once (Step 6), you must pick one run. Convention: compress the first longest run, write the other explicitly as 0.

PICTURE. Both runs highlighted; the left run wins the ::, the right run stays as explicit 0s.


Step 8 — Edge case B: the degenerate all-zero addresses

WHAT. What if almost everything is zero?

  • All 8 groups zero → the whole thing collapses to :: (the "unspecified" address, meaning no address yet).
  • Seven zero-groups, last group 10000:0000:0000:0000:0000:0000:0000:0001::1, the loopback (talk to yourself).

WHY it still works. The recovery rule handles the extremes: for ::1 you wrote 1 group, so :: restores zeros. For :: you wrote 0 groups, so it restores all 8.

PICTURE. The two degenerate cases side by side, each with its recovery arithmetic.

Recall Check: expand

::1 back to full form How many zero groups does :: restore in ::1? ::: , giving 0000:0000:0000:0000:0000:0000:0000:0001.


The one-picture summary

Everything above, as a single pipeline: 128 bits → 8 hextets → hex digits → colons → drop leading zeros → collapse the longest run with ::.

Recall Feynman: tell the whole walkthrough to a 12-year-old

Picture a super-long light-switch board with 128 switches, each up or down. Reading all 128 is madness, so we cut the board into 8 chunks of 16 switches. Each chunk of 16 switches we write as 4 short "super-digits" (hex), because one super-digit is worth exactly 4 switches. We glue the 8 chunks with colons. Then we tidy up: inside each chunk we rub out the useless zeros at the front (like turning 007 into 7) — but never the ones at the back, because those change the number. Finally, if a whole stretch of chunks is nothing but zeros, we squash the longest such stretch into a tiny ::. We're allowed that squash only once, because :: secretly means "fill in as many zero-chunks as it takes to get back to 8," and if we used it twice nobody could tell how to split the zeros. That's how 2001:0db8:0000:0000:0000:ff00:0042:8329 becomes the neat 2001:db8::ff00:42:8329.


Connections

  • Parent: IPv6 — Address Format, Why Needed, Key Differences
  • Hexadecimal and Binary Number Systems
  • IPv4 Addressing & CIDR
  • Subnetting
  • DHCP and SLAAC
  • Multicast vs Broadcast vs Anycast
  • IP Header Structure
  • NAT (Network Address Translation)
  • OSI & TCP-IP Model — Network Layer

cut into 8

4 bits per digit

glue

rule 1

rule 2

once only

misuse

128 bits

8 hextets of 16 bits

4 hex digits each

colons between groups

drop leading zeros

collapse longest zero run

double colon

ambiguous illegal