0:0:0:0:0:0:ffff:192.168.0.0/120
::ffff:192.168.0.0
netmask address: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00
::ffff:192.168.0.255
count: 256
0.0.0.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
0.0-255.0-255.0-255
10.0-255.0-255.0-255
100.64-127.0-255.0-255
127.0-255.0-255.0-255
169.254.0-255.0-255
172.16-31.0-255.0-255
192.0.0.0-255
192.0.0.0-7
192.0.2.0-255
198.18-19.0-255.0-255
198.51.100.0-255
192.88.99.0-255
192.168.0-255.0-255
203.0.113.0-255
224-239.0-255.0-255.0-255
240-255.0-255.0-255.0-255
240-255.0-255.0-255.0-255
::
::1
::ffff:0-255.0-255.0-255.0-255
64:ff9b::-ffff:-ffff
100::-ffff:-ffff:-ffff:-ffff
2001:-1ff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
2001:0:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
2001:2:0:-ffff:-ffff:-ffff:-ffff:-ffff
2001:db8:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
2001:10-1f:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
2002:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
fc00-fdff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
fe80-febf:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff:-ffff
inet64_aton(string)
inet6_aton(string)
inet64_ntoa(number)
inet6_ntoa(number)
inet6_mask(h)
inet6_ntoa_reverse(number)
string
- IPv6 address stringnumber
- IPv6 address numberh
- shift-left count
inet64_aton
returns 8 elements of 16-bit integer value of IPv4-mapped IPv6 address if string
is "::ffff:*.*.*.*"
, otherwise inet6_aton
.inet6_aton
returns 8 elements of 16-bit integer value of IPv6 address.inet64_ntoa
returns string of IPv4-mapped IPv6 address if number
is [ 0, 0, 0, 0, 0, 0xffff, 0-0xffff, 0-0xffff ]
, otherwise inet6_ntoa
.inet6_ntoa
returns string of IPv6 address.inet6_mask
returns 8 elements of 16-bit integer value of IPv6 netmask address.inet6_ntoa_reverse
returns domain name of IPv6 address for reverse lookup.
inet64_aton("::ffff:255.255.255.255"); // [ 0, 0, 0, 0, 0, 65535, 65535, 65535 ]
inet64_ntoa([ 0, 0, 0, 0, 0, 65535, 65535, 65535 ]); // "::ffff:255.255.255.255"
inet6_aton("fe80::").map(e => e.toString(16)); // [ "fe80", "0", "0", "0", "0", "0", "0", "0" ]
inet6_ntoa([ "fe80", "0", "0", "0", "0", "0", "0", "0" ].map(e => parseInt(e, 16))); // "fe80::0:"
inet6_mask(16).map(e => e.toString(16)); // [ "ffff", "ffff", "ffff", "ffff", "ffff", "ffff", "ffff", "0" ]
inet6_ntoa_reverse([ "fe80", "0", "0", "0", "0", "0", "0", "0" ].map(e => parseInt(e, 16))); // "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa"
To get the network address ::ffff:192.168.0.0
and the broadcast address ::ffff:192.168.0.255
from ::ffff:192.168.0.1/120
, the 8 elements of 16-bit integer value \(w\) such as
\[
\begin{aligned}
w &= \underbrace{\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}:\underbrace{\text{ffff}_{(16)}}_{16\text{-bit}}}_{128\text{-bit}}\\
&= \left(\underbrace{\lnot 0 \land \text{ffff}_{(16)}, \lnot 0 \land \text{ffff}_{(16)}, ...}_{i=0, 1, 2, \cdots, 7}\right).
\end{aligned}
\]
The network address \(n\) and the broadcast address \(b\) are obtained as follows:
\[
\begin{aligned}
n &= a \land (w \ll (128 - l) \land w) = \text{::ffff:192.168.0.0},\\
b &= a \lor \lnot(w \ll (128 - l) \land w) = \text{::ffff:192.168.0.255},
\end{aligned}
\]
where \(\ll\) means logical shift left, \(a = \text{::ffff:192.168.0.1}\), \(l = 120\) and \(w\ll (128 - l) \land w = \text{ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00}\) means the netmask address, generally obtained by
\[
\begin{aligned}
h &= 128 - l,\\
j &= \lfloor h/16\rfloor,\\
k &= h\mod 16,\\
w\ll h \land w &= \left(\underbrace{\text{ffff}_{(16)}, \cdots\text{or }\emptyset, }_{i=0,\cdots\;(i < 7-j)}\underbrace{\text{ffff}_{(16)}\ll k\land\text{ffff}_{(16)}, }_{\phantom{(}i = 7-j\phantom{)}}\underbrace{\,\emptyset\text{ or }\text{0000}_{(16)}, \cdots}_{(7-j < i)\;i=\cdots, 7}\right).
\end{aligned}
\]
The address \(a\) is represented by the network part and the host part as follows:
\[
\begin{aligned}
a &= \text{::ffff:192.168.0.1},\\
&= \underbrace{\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{0000}_{(16)}:\text{ffff}_{(16)}:\text{11000000}_{(2)}.\text{10101000}_{(2)}.\text{00000000}_{(2)}}_{l(120)\text{-bit network part}}.\underbrace{{\text{00000001}_{(2)}}}_{h(8)\text{-bit host part}}.\\
\end{aligned}
\]
The number of addresses \(N\) is clearly \[ \begin{aligned} N &= 2^{128 - l} = 2^h\\ &= 2^8 = 256. \end{aligned} \]
Reverse lookup .ip6.arpa
domain name is a 128-bit address with 4 bits each in reverse order and join them with a period in hexadecimal such as
\[
\begin{aligned}
&\text{``1.0.0.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa''}.
\end{aligned}
\]