Skip to content

Instantly share code, notes, and snippets.

@vasturiano
Last active June 10, 2023 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vasturiano/ba0bdc27ddc2b13012e85b2a0b7a1c43 to your computer and use it in GitHub Desktop.
Save vasturiano/ba0bdc27ddc2b13012e85b2a0b7a1c43 to your computer and use it in GitHub Desktop.
Hilbert Map of IPv6 address space
license: mit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hilbert IPv6 Address Map</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.2.0/d3.min.js"></script>
<script src="//unpkg.com/ip.js@0.4.0"></script>
<script src="//unpkg.com/hilbert-chart"></script>
<style>
body {
margin: 0;
text-align: center;
}
#ipv6-chart { display: inline-block; }
.info-note {
font-size: 11px;
font-family: Sans-serif;
opacity: 0.5;
position: absolute;
bottom: 10px;
left: 50%;
transform: translate(-50%);
}
</style>
</head>
<body>
<div id="ipv6-chart"></div>
<div class="info-note">(use mouse-wheel/drag to zoom/pan)</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Get the whole IPv6 data
d3.csv('./ipv6-address-space.csv', function(globalData) {
// Get the IPv6 unicast data
d3.csv('./ipv6-unicast.csv', function(unicastData) {
data = globalData.concat(unicastData);
data.forEach(function(row) {
// Downsize to 32 bit space to prevent overflow
row.prefix = shiftPrefix(new Ip.Prefix(row.Prefix || row['IPv6 Prefix']), -96).toString();
row.name = row.Designation || row.Allocation;
});
HilbertChart()
.hilbertOrder(32 / 2)
.data(parseIpData(data))
.rangePadding(0.03)
.valFormatter(ipFormatter)
.rangeTooltipContent(d => `<b>${d.name}</b>: ${prefixFormatter(d)}`)
(document.getElementById("ipv6-chart"));
});
});
});
//
function parseIpData(ipData) {
var prefixes = [],
ignoreNames = ['global unicast'];
ipData.map(function(row) {
var pref = new Ip.Prefix(row.prefix);
return {
start: pref.firstIp().toNum(),
length: Math.max(1, Math.pow(2, 128 - pref.cidr)),
name: getName(row.name),
infos: [row]
};
}).filter(function(prefix) {
// Remove unicast placeholder
return ignoreNames.indexOf(prefix.name.toLowerCase()) === -1;
}).forEach(function(prefix) {
var last;
if (prefixes.length
&& (last = prefixes[prefixes.length - 1])
&& last.name === prefix.name
&& (last.start + last.length === prefix.start)) {
last.length += prefix.length;
last.infos.push(prefix.infos[0]);
} else {
prefixes.push(prefix);
}
});
return prefixes;
//
function getName(designation) {
var name = designation;
if (name.indexOf('Administered by') > -1) {
name = "Various Registries";
}
return name;
}
}
function ipFormatter(d) {
return shiftIp(new Ip.Addr(d), 96).toString();
}
function prefixFormatter(d) {
var ipRange = new Ip.Range(d.start, d.start + d.length - 1),
prefixes = ipRange.toPrefixes();
if (ipRange.isIPv4()) {
// Move CIDR to v6 range for low number prefixes
prefixes[0].cidr += 96;
}
return (prefixes.length===1
? shiftPrefix(prefixes[0], 96)
: shiftRange(ipRange, 96)
).toString();
}
// bits: positive shifts up, negative shifts down
function shiftIp(ip, bits) {
var bin = ip.toBin();
if (bits < 0) {
bin = bin.slice(0, bin.length + bits);
if (!bin.length) bin = '0';
} else {
for (;bits;bits--) { bin += '0'; }
}
return new Ip.Addr(parseInt(bin, 2));
}
function shiftPrefix(pref, bits) {
return new Ip.Prefix(shiftIp(pref.firstIp(), bits), pref.cidr - bits);
}
function shiftRange(pref, bits) {
return new Ip.Range(shiftIp(pref.firstIp(), bits), shiftIp(pref.lastIp(), bits));
}
</script>
</body>
</html>
IPv6 Prefix Allocation Reference Notes
0000::/8 Reserved by IETF [RFC4291] [1] [2] [3] [4] [5]
0100::/8 Reserved by IETF [RFC4291] 0100::/64 reserved for Discard-Only Address Block [RFC6666]. Complete registration details are found in [IANA registry iana-ipv6-special-registry].
0200::/7 Reserved by IETF [RFC4048] Deprecated as of December 2004 [RFC4048]. Formerly an OSI NSAP-mapped prefix set [RFC4548].
0400::/6 Reserved by IETF [RFC4291]
0800::/5 Reserved by IETF [RFC4291]
1000::/4 Reserved by IETF [RFC4291]
2000::/3 Global Unicast [RFC4291] The IPv6 Unicast space encompasses the entire IPv6 address range with the exception of ff00::/8, per [RFC4291]. IANA unicast address assignments are currently limited to the IPv6 unicast address range of 2000::/3. IANA assignments from this block are registered in [IANA registry ipv6-unicast-address-assignments]. [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]
4000::/3 Reserved by IETF [RFC4291]
6000::/3 Reserved by IETF [RFC4291]
8000::/3 Reserved by IETF [RFC4291]
a000::/3 Reserved by IETF [RFC4291]
c000::/3 Reserved by IETF [RFC4291]
e000::/4 Reserved by IETF [RFC4291]
f000::/5 Reserved by IETF [RFC4291]
f800::/6 Reserved by IETF [RFC4291]
fc00::/7 Unique Local Unicast [RFC4193] For complete registration details, see [IANA registry iana-ipv6-special-registry].
fe00::/9 Reserved by IETF [RFC4291]
fe80::/10 Link-Scoped Unicast [RFC4291] Reserved by protocol. For authoritative registration, see [IANA registry iana-ipv6-special-registry].
fec0::/10 Reserved by IETF [RFC3879] Deprecated by [RFC3879] in September 2004. Formerly a Site-Local scoped address prefix.
ff00::/8 Multicast [RFC4291] IANA assignments from this block are registered in [IANA registry ipv6-multicast-addresses].
Prefix Designation Date WHOIS RDAP Status Note
2001:0000::/23 IANA 1999-07-01 whois.iana.org ALLOCATED 2001:0000::/23 is reserved for IETF Protocol Assignments [RFC2928]. 2001:0000::/32 is reserved for TEREDO [RFC4380]. 2001:1::1/128 is reserved for Port Control Protocol Anycast [RFC7723]. 2001:2::/48 is reserved for Benchmarking [RFC5180]. 2001:3::/32 is reserved for AMT [RFC7450]. 2001:4:112::/48 is reserved for AS112-v6 [RFC7535]. 2001:5::/32 is reserved for EID Space for LISP [draft-ietf-lisp-eid-block]. 2001:10::/28 is deprecated (previously ORCHID) [RFC4843]. 2001:20::/28 is reserved for ORCHIDv2 [RFC7343]. 2001:db8::/32 is reserved for Documentation [RFC3849]. For complete registration details, see [IANA registry iana-ipv6-special-registry].
2001:0200::/23 APNIC 1999-07-01 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2001:0400::/23 ARIN 1999-07-01 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED
2001:0600::/23 RIPE NCC 1999-07-01 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:0800::/23 RIPE NCC 2002-05-02 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:0a00::/23 RIPE NCC 2002-11-02 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:0c00::/23 APNIC 2002-05-02 whois.apnic.net https://rdap.apnic.net/ ALLOCATED 2001:db8::/32 reserved for Documentation [RFC3849]. For complete registration details, see [IANA registry iana-ipv6-special-registry].
2001:0e00::/23 APNIC 2003-01-01 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2001:1200::/23 LACNIC 2002-11-01 whois.lacnic.net https://rdap.lacnic.net/rdap/ ALLOCATED
2001:1400::/23 RIPE NCC 2003-02-01 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:1600::/23 RIPE NCC 2003-07-01 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:1800::/23 ARIN 2003-04-01 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED
2001:1a00::/23 RIPE NCC 2004-01-01 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:1c00::/22 RIPE NCC 2004-05-04 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:2000::/20 RIPE NCC 2004-05-04 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:3000::/21 RIPE NCC 2004-05-04 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:3800::/22 RIPE NCC 2004-05-04 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:3c00::/22 IANA RESERVED 2001:3c00::/22 is reserved for possible future allocation to the RIPE NCC.
2001:4000::/23 RIPE NCC 2004-06-11 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:4200::/23 AFRINIC 2004-06-01 whois.afrinic.net https://rdap.afrinic.net/rdap/http://rdap.afrinic.net/rdap/ ALLOCATED
2001:4400::/23 APNIC 2004-06-11 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2001:4600::/23 RIPE NCC 2004-08-17 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:4800::/23 ARIN 2004-08-24 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED
2001:4a00::/23 RIPE NCC 2004-10-15 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:4c00::/23 RIPE NCC 2004-12-17 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:5000::/20 RIPE NCC 2004-09-10 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2001:8000::/19 APNIC 2004-11-30 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2001:a000::/20 APNIC 2004-11-30 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2001:b000::/20 APNIC 2006-03-08 whois.apnic.net https://rdap.apnic.net/ ALLOCATED
2002:0000::/16 6to4 2001-02-01 ALLOCATED 2002::/16 is reserved for 6to4 [RFC3056]. For complete registration details, see [IANA registry iana-ipv6-special-registry].
2003:0000::/18 RIPE NCC 2005-01-12 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED
2400:0000::/12 APNIC 2006-10-03 whois.apnic.net https://rdap.apnic.net/ ALLOCATED 2400:0000::/19 was allocated on 2005-05-20. 2400:2000::/19 was allocated on 2005-07-08. 2400:4000::/21 was allocated on 2005-08-08. 2404:0000::/23 was allocated on 2006-01-19. The more recent allocation (2006-10-03) incorporates all these previous allocations.
2600:0000::/12 ARIN 2006-10-03 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED 2600:0000::/22, 2604:0000::/22, 2608:0000::/22 and 260c:0000::/22 were allocated on 2005-04-19. The more recent allocation (2006-10-03) incorporates all these previous allocations.
2610:0000::/23 ARIN 2005-11-17 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED
2620:0000::/23 ARIN 2006-09-12 whois.arin.net https://rdap.arin.net/registryhttp://rdap.arin.net/registry ALLOCATED
2800:0000::/12 LACNIC 2006-10-03 whois.lacnic.net https://rdap.lacnic.net/rdap/ ALLOCATED 2800:0000::/23 was allocated on 2005-11-17. The more recent allocation (2006-10-03) incorporates the previous allocation.
2a00:0000::/12 RIPE NCC 2006-10-03 whois.ripe.net https://rdap.db.ripe.net/ ALLOCATED 2a00:0000::/21 was originally allocated on 2005-04-19. 2a01:0000::/23 was allocated on 2005-07-14. 2a01:0000::/16 (incorporating the 2a01:0000::/23) was allocated on 2005-12-15. The more recent allocation (2006-10-03) incorporates these previous allocations.
2c00:0000::/12 AFRINIC 2006-10-03 whois.afrinic.net https://rdap.afrinic.net/rdap/http://rdap.afrinic.net/rdap/ ALLOCATED
2d00:0000::/8 IANA 1999-07-01 RESERVED
2e00:0000::/7 IANA 1999-07-01 RESERVED
3000:0000::/4 IANA 1999-07-01 RESERVED
3ffe::/16 IANA 2008-04 RESERVED 3ffe:831f::/32 was used for Teredo in some old but widely distributed networking stacks. This usage is deprecated in favor of 2001::/32, which was allocated for the purpose in [RFC4380]. 3ffe::/16 and 5f00::/8 were used for the 6bone but were returned. [RFC5156]
5f00::/8 IANA 2008-04 RESERVED 3ffe::/16 and 5f00::/8 were used for the 6bone but were returned. [RFC5156]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment