IPv6 address representation in Python -
i converting ipv6 addresses textual representation , noticed behavior not explain:
in[38]: socket.inet_ntop(socket.af_inet6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x7f\x00\x00\x01') out[38]: '::ffff:127.0.0.1' in[39]: socket.inet_ntop(socket.af_inet6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x7f\x00\x00\x00') out[39]: '::ff:ffff:7f00:0'
i surprised see ::ffff:127.0.0.1
, i'd expect ::ffff:7f00:0
. standard or @ least common? ipv6 addresses represented way? wikipedia article doesn't mention @ all. confused.
the posix page inet_ntop
specifies format 1 of options (slightly paraphrased):
a third form more convenient when dealing mixed environment of ipv4 , ipv6 nodes
x:x:x:x:x:x:d.d.d.d
,x
characters hexadecimal values of 6 high-order 16-bit pieces of address, ,d
characters decimal values of 4 low-order 8-bit pieces of address (standard ipv4 representation).
Comments
Post a Comment