4.3.11 · D3Computer Networks

Worked examples — IPv6 — address format, why needed, key differences

2,772 words13 min readBack to topic

Before touching a single address, let us re-anchor the three tools we will keep using, in plain words:

WHY hex and not decimal? Decimal digits don't line up with bits ( is not a power of ), so you can't cleanly say "this digit = these 4 bits". Hex does line up, so reading structure off the address is possible. That is the whole reason IPv6 chose it.


The scenario matrix

Every IPv6 address question is really one of these cells. The examples below are labelled by cell letter so you can see the coverage is complete.

Cell Scenario class The tricky part Covered by
A One long zero-run Where does :: go? Ex 1
B Two zero-runs, tie in length Which run wins? Ex 2
C Two zero-runs, one longer :: on the longer only Ex 3
D Zero-run of length 1 Is :: even allowed? Ex 4
E Degenerate / all-zero-ish (loopback, unspecified) Everything collapses Ex 5
F Expand a compressed address back to full Reverse the rules, count to 8 Ex 6
G Illegal address — spot & fix Two ::, over-long hextet Ex 7
H Real-world word problem (prefix / interface split, /64) Where is the boundary? Ex 8
I Exam twist (counting addresses in a prefix, powers of 2) Arithmetic, not just formatting Ex 9

Example 1 — Cell A: one long zero-run


Example 2 — Cell B: two zero-runs of equal length


Example 3 — Cell C: two zero-runs, one strictly longer


Example 4 — Cell D: a zero-run of length 1


Example 5 — Cell E: degenerate / special addresses


Example 6 — Cell F: expand a compressed address back to full


Example 7 — Cell G: spot the illegal address and fix it


Example 8 — Cell H: real-world word problem (prefix / interface split)


Example 9 — Cell I: exam twist (counting addresses in a prefix)


Recall Fast self-test (cover the answers)

:: may appear how many times per address? ::: Exactly once. Minimum zero-run length that :: should compress? ::: Two hextets (never a lone 0). On a tie between two equal zero-runs, which gets ::? ::: The leftmost (first) one. Max hex digits in one hextet, and why? ::: 4, because a hextet is 16 bits and . In 2001:db8::1428:57ab, how many zero hextets does :: hide? ::: . How many /64 subnets fit in a /48? ::: . How many addresses in a /48? ::: .


Connections

Concept Map

strip leading zeros

find longest zero run

length two or more

length one

count back to 8

split at slash 64

Full 128-bit address

shorter hextets

candidate for double-colon

apply double-colon once

keep as zero

canonical form

prefix plus interface ID