This article is a small follow up on the IPv6 Link-Local address article some time ago and based on a question in one of the comments:
How you will convert 0008.209a.081b in link-local address. First step is ok where u insert FFFE i.e. 0008.20FF.FE9a.081b
issue is 2nd step, how to convert 0008 to binary?
I have done reverse engineering from link-local address
link-local address is FE80::208:20FF:FE9A:81B
when u convert 208 to binary it comes 10000001000. So my question is how to convert 0008 to 10000000000 (this comes to 400 in HEX)
To get from the BIA 0008.209a.081b to the link-local address FE80::208:20FF:FE9A:81B we should recap the rules for the modified EUI-64 addressing first:
- FFFE will be put in between the vendor-id (3 most significant bytes) and the extension-id (3 least significant bytes)
- Thereafter the seventh bit, known as universal/local bit, gets inverted.
- At last, change all points ‘.’ to colons ‘:’ and delete all leading zeros
In this case we first insert FFFE into the BIA which leads to 0008.20FFFE9a.081b
Then we have to invert the seventh bit, which means we first change from hex 0008 to binary which leads to 00000000 00001000.
Even though, 0008 in hex only gives out a value of 1000, we must not forget that its still two bytes which means that the leading zeros have to be put in front of 1000 to get a total of 16 (2×8) bits.
If we invert the 7th bit (out of 16) now leads to 00000010 00001000 in hex: 0208. All together its now 0208.20FFFE9a.081b.
Calculators tend to not show the leading zeros if you convert something like 0008 from hex to binary since for them, it does not make sense but in that case it is still important to keep them in mind, they are still there, just set to zero.
A calculator will give you 1000 in binary for 0008, but in that case it has to be 00000000 00001000.
Now delete al leading zeros, change points ‘.’ to colons ‘:’ and put FE80:: in front of it and then we got your link-local address of FE80::208:20FF:FE9A:81B.
To get back to the issues you had while calculating the link-local, never forget to use all bits while doing this calculation.
A BIA always uses all 6 bytes (or 48 bits), Cisco itself does show the BIAs in three groups of 2 Bytes separated by a point ‘.’
Also 208 does not give 10000001000 (this is Hex 408, there is one zero too much) it is actually 1000001000 or even better 00000010 00001000.
But still to go with your example, you did not invert the 7h bit, it was actually the 13th bit.