I am using the .NET Framework classes to get the ip addresses for my machine.
Dns.GetHostAddresses(Dns.GetHostName())
I have a VirtualBox adapter which has both an ipv4 and ipv6 address. Using the .NET code i am getting the ipv6 address as fe80::71a3:2b00:ddd3:753f%16
Notice the %16 at the end?
However, if I query the same using WMI, I am getting the address as 'fe80::71a3:2b00:ddd3:753f'
So, does the %16 have any special significance?
Edit:
I just had some more observations about this. And they match pretty well with what Stephen Jennings said in his answer.
I installed Vmware to see what ipv6 address it issued. The addresses were : fe80::3dd0:7f8e:57b7:34d5%19
fe80::b059:65f4:e877:c40%20
Clearly, the numbers after % are not some hex representation. I checked all the properties available for a network adapter using Wmi and found that the numbers are exactly same as the InterfaceIndex property of each network adapter. As per MSDN, it uniquely identifies each network adapter and this property was introduced in Vista.
What still confused me was why would the IPAddress class allow you to create an ip address in that format unless it was valid. The answer was provided by Stephen. The number is the scope id. IPAddress has a constructor that accepts the address AND a scope id.
Oh, and all these three network adapters were link local. Confirmed it via ipconfig
Cool. That was interesting!!
fe80:10(the0x0010being 16). I use that in my browser when working with link-local IPv6 addresses, but I am not 100% sure this is according to the standards. (Using the percent in URLs is messy in browsers; in fact I could not get that to work at all.) – Arjan Feb 6 '11 at 17:49