Wednesday, February 23, 2011

It's time for IPv6!

There is a very cool dude called himself Beej (see: beej.us), but according to his resume his name is Brian E. Hall, I guess. He has a funny homepage www.beej.us designed like a Commodore 64 terminal. Anyway, I was looking for a good tutorial about IPv6 and after googling a while I didn't find some good tutorials. So after a while beej.us came into my mind, as I once read his tutorial about network programming in C language, especially based on Linux.


I really enjoy reading his tutorials, as there is a lot of funny jokes he makes between the lines. So enough talking let's start getting in action. As about the whole world is using IPv4, bit by bit more people is experimenting with IPv6. Some internet providers already provides IPv6 addresses for experimental usage. So what's so creepy about IPv6? Well not much, but the problem is that a lot of devices like DHCP servers, routers and internet providers don't support IPv6 yet. Another problem is that most network applications running on a computer don't support IPv6.


With IPv6 practically every piece of hair of all creatures on the planet earth can have its own ip address. Wait a minute, plus some thousands of planet earths more :P. Am I exaggerating? Maybe yes, nut we are talking about a number of 2^128. And that's a lot my dear readers. This means, that every device on the planet, from dog trackers to magnetrons to watches to all electronic devices can have it's own static ip address. Cool, but now I want to see something about IPv6.


So how does IPv6 look like? Below you see an example of two types of IP versions:
IPv4: "192.0.2.1"
IPv6: "2001:db80:63b3:1001:0000:0000:0000:3490"


IPv4 address has, as you already might know, 4 bytes separated by dots. While an IPv6 version has 16 bytes, with every pair bytes separated by double dots! Damn, so if I ask my collegae which IPv6 address he has, he would response to me like "Well Nordin, I have two zero zero one double dots D B eight zero double dots ....". Sorry, can you repeat it again?


But as Beej explained in his article, you can shrink the IPv6 address if there is a lot of zeroes in it, for example:
Uncompressed: "2001:0db8:63b3:0001:0000:0000:0000:3490"
Compressed: "2001:db8:63b3:1::3490"


That's much better, right :)
Another cool thing is the loopback addres, also known as the localhost, the equivalent of IPv4's 127.0.0.1:
"0000:0000:0000:0000:0000:0000:0000:0001"
Compress it and you get:
"::1"


Again another cool thing to know is to get your IPv4 address embedded in IPv6 address. That is if you want to represent your IPv4 address as an IPv6 address, check this out:
IPv4: "192.168.1.100"
IPv6: "::FFFF:192.168.1.100", which is actually "0000:0000:0000:0000:0000:0000:FFFF:192.168.1.100"


So if I have received an IPv4 address from the DHCP server and I want to connect to an IPv6 network device, than that should be possible by doing something like that: ::FFFF:192.168.1.101". This way, you convert your provided IPv4 address into an IPv6 ipaddress, so you can talk to an IPv6 type host.


Well that's it for now, there'll be more soon...

NSNotification example