Showing posts with label portion. Show all posts
Showing posts with label portion. Show all posts

Mar 13, 2013

Lesson 56 - Introduction to IPv6 - Address Structure



After a very short introduction to IPv6 types of addresses and the header presentation, let's dig deeper and find out more about IPv6 addresses.

Hexadecimal Address Notation
I have already mentioned that IPv6 global space begins with 2000::/3. This means that all public IPv6 addresses now use three bits which amount to value 2 in hex.

Look at this notation of global address one more time:

2000::/3
This is a shortcut for:

2001:0000:0000:0000:0000:0000:0000:0000/3

And just like in IPv4 addresses this '/3' tells us to pay attention to the three most significant bits. Hexadecimal to binary conversion is simple. Two digits in hex (for instance: 20) is a one byte value (eight bits). One character stands for four bits (called a nibble). They need to be converted as two separate entities.

Pic. 1 - Hex-to-Binary Conversion.


This way, the hexadecimal 20 becomes 00100000.

In the global IPv6 address scope the first three bits ('/3') will always be set like shown below (as of writing this post):

Pic. 2 - IPv6 Global Address Sequence of Bits.

Okay. What about the hierarchy in IPv6 address?

IPv6 Hierarchy
It is not very different from what we used in IPv4 classes! Do you remember these bits settings in IPv4? If not, look at the below numbers:

Class A - 0xxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx /8
Class B - 10xxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx /16
Class C - 110xxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx /24

The blue color denotes the network portion of the address in these classes. For instance, the '/24' means that 24 most significant bits are the network bits. The remaining ones (eight of them left) are the host bits. This way we create the hierarchy in IPv4 addresses. 


What does it look like in IPv6 then? It is much simpler. See for yourself:

2001:acbd:1234:a1b2:0000:0000:0000:0001/64

The first sixty four bits (blue) are network bits, the remaining ones are the host's interface identifier (host bits). But this, we already know based on the previous post. The network portion is going to be given to us either by the ISP or by the registry (ARIN in the US, RIPE in Europe etc.) if we're a big organization. 

We're told that the length of the prefix assigned to different organizations looks like this:
  • Registries will be assigned /23
  • ISP will be assigned /32
  • Sites will be assigned /48
Say, you are the organization that receives /48 prefix like this:
2001:1234:5678:0000:0000:0000:0000:0000/48.

This gives you two bytes (shown in red) in the network portion to create different networks (red portion: 2^16=65536 different numbers). By the way, get used to the shortcuts:

2001:1234:5678:0000:0000:0000:0000:0000/48 = 2001:1234:5678:0000::/48
IPv6 Interface Identifier (host bits)
How do we get the host portion then? 

In terms of creating the host portion of IPv6 address, if DHCP is not used, we have two options. One way is to do this by hand like presented below (the red color is the interface identifier or the host bits if you will):

2001:1234:5678:1000::1
(abbreviated address which could be expanded to 2001:1234:5678:1000:0000:0000:0000:0001)

But this approach seems somewhat tedious. I mean, who wants to assign addresses on 500 hosts this way?

Another way is to use EUI-64 method which creates the host portion of IPv6 address based on the MAC address of the first Ethernet interface which, at least in theory, should be unique!

Because the MAC address has only 48 bits and not 64, a special procedure has been developed to fill in the gap. Check it out the MAC address of the interface on the router:

Pic. 3 - MAC address of F1/0 Interface.

In the EUI-64 method the operating system takes the MAC address (highlighted) and uses it to create the host bits for the link-local address by default (you can also do this manually). And the same method can be used to assign the host bits in the global address.

Here is the detailed description of how 48 bits of MAC address becomes 64 bit host portion of IPv6 address in EUI-64 method (operating system takes care of these details itself).

Step 1
Flip the 7th bit (counting from left to right) in the MAC address (if it's 1 change it to 0, if it's 0, change it to 1).

In order to do that, operating system must first convert the hexadecimal number of the first byte to the binary form. MAC address used in the example is (as per pic. 3):

CC00.19BA.0010.

(Hex) CC ==> (Bin) 11001100
C=1100

Counting from left to right the 7th bit is: 11001100. This one must be flipped like shown below:
11001110. This gives us the hexadecimal value of: CE.

Step 2
Use the MAC address after modifying the 7th bit in step 1 and inject the FFFE between OUI (first three bytes on the left) and the serial number of the adapter (first three bytes on the right). I will use the colon (:) as the delimiter and blocks of 2-bytes to make it compliant with the IPv6 convention. Look at the result below:

CE00:19FF:FEBA:0010

This way we get 64-bit host portion of the IPv6 address. So my link-local address which uses this method to create the host bits will look like this:

CE00:19FF:FEBA:0010, which is abbreviated to this form:
CE00:19FF:FEBA:10

Step 3
Add the network portion to this construct calculated in step 2. For instance, we know that link-local's network bits are always FF80::/10. So, the whole link-local address is going to be (abbreviated as per Lesson 55's explanation):

FF80::CE00:19FF:FEBA:10
(again, the full 128-bit version is: FF80:0000:0000:0000:E00:19FF:FEBA:0010)

Let's see if this is true when I enable IPv6 support on F1/0 interface. Pay attention to link local address value.

Pic. 4 - IPv6-enabled F1/0 Interface.

Note that just by enabling IPv6 support on the interface IOS automatically creates link-local address using EUI-64, allowing this interface to communicate with hosts residing on this local subnet/network. However, in order to communicate with hosts outside this link-local network, the interface needs a global address as well. This leads us to a correct conclusion that each interface will have two addresses: link-local and global in order to fully operate in IPv6 domain.
IPv6 Global Address Configuration
There are two major methods of configuring IPv6 addresses on our devices:
  • Manual method - You will configure them like we sometimes do with IPv4 right now.
  • Dynamic method - This one offers us IPv6 DHCP servers or the hosts can obtain the network portion of the IPv6 address from their local router (special message is sent called 'Router Solicitation'). In the latter situation the host portion will be generated automatically using the EUI-64 method described above.
Since this post has enough information for one sitting, I'll show you the manual and router solicited methods of configuring IPv6 addresses in my next post. I will also explain what happened to our IPv4 ARP request since broadcast does not exist in IPv6 world anymore!

Mar 12, 2013

Lesson 28 - IPv4 Address Dissected - Part 2



In my previous post I have talked about the hierarchy in IPv4 address. It is the network mask that tell us which bits form a network address and which ones denote the host in the network. But there is more to it ...

You already know that IP address and its network mask create a unique layer 3 identifier of a host. This allows devices to communicate. When a computer sends a packet, it will put the address of the recipient in the IP header as the destination. It also puts its own address (sender), so the recipient knows who sent the packet and to whom a reply should be sent.

After reading my previous post it may seem clear what a network and a host in the network are. But you may still ask: "What is a network anyway?". As strange as it sounds, the answer to the question may not be as simple as one might think.

We tend to divide our networks into multiple pieces that are uniquely identified with the network portion of the address (masked by network mask bits set to 1). Individual hosts placed in those networks will also have unique host portion of the IP address (network mask bits set to 0). They are unique in their network.

Why do we break down the company's infrastructure into multiple chunks called networks?

There are many reasons we do it.  Larger networks are harder to maintain and become very inefficient as the hosts receive too many broadcast transmissions (broadcast=one packet to everyone). Also, it is easier to control traffic and tighten the security when dealing with multiple networks rather than doing so in one single organism. So, we separate hosts using layer 3 devices called routers and address them uniquely, thus creating multiple interconnected networks. The routers that connect networks become the gateways between them allowing unicast communication (one-to-one). At the same time they do not allow broadcast traffic (one-to-everyone) to go through. They also are equipped with many mechanisms to control the traffic traversing through them.

How we divide our system into multiple networks may be depended on numerous factors. For instance, a network in the building can be divided based on the floors. First floor is the first network, second floor is the second network etc. Other division could be made based on the departments in the corporation. HR is going to be one network, Legal Dept. another etc. Either way, computers will belong to one of these networks, but all of them together will still belong to the same company.

So, what is a network? A network is a group of devices that share the same network portion of the address. That portion is dictated by the length of the network mask. These bits mask the corresponding bits in the address. But this you already know. However, there are a few more things you need to know.

Consider this picture.

Pic. 1 - IP Networks.
Icons designed by: Andrzej Szoblik - http://www.newo.pl

What do we see in the picture?

In the middle sits a layer 3 device called a router (R1). I will devote a whole post on what it is and what its functions are. Meanwhile, let's carry on with our description.

The router (R1) connects two different networks. It becomes the gateway between them. This means it allows communication between them (unicast by default). The two networks in the picture have the following addresses:

  1. The network on the left-hand side has the address of 192.168.1.0/24.
  2. The network on the right-hand side has the address of 192.168.2.0/24.
The switches (SW1 and SW2) are transparent in terms of layer 3 communication. Remember? They are layer 2 devices, and do not have a clue what IP addresses are.

Finally we have two computers. PC1 belongs to the network 192.168.1.0/24, PC2 belongs to the network 192.168.2.0/24. Both have the same host identifier in the last byte of their IP address: 1. But their network portion of IP address is different. As a result of that the belong to two different networks. Just like two Mr. Smiths who live in two different houses on two different streets of the same town.

PC1192.168.1.1/24
PC2192.168.2.1/24

Have you noticed that the third octed (from the left) has different number? That makes the network portions of these two addresses unique.

What does this /24 mean in the address?

As you already know the netmask separates a network from a host portion of the address. Both IP addresses and their network mask are presented in the decimal notation with the length of network mask (/24). Yes, the shortcut /24 means, that the network mask is twenty four bits in length. This in turn, means that the first twenty four bits of the IP address is the network portion. The remaing eight bits are the host address in the network. Check it out below.

Pic. 2 - PC1 address with the netmask 24 bits (/24).



Looking at the binary, we see that /24 = 255.255.255.0.
If we convert 255.255.255.0 into binary we get twenty four 1s in the network mask, giving us three bytes of the network address. The remaining eight bits in the network mask are all 0s. This way, the last byte (8 bits) becomes the host identifier int the network 192.168.1.0.

Interestingly enough, many moons ago, there were no networks mask in use. So, how on Earth, did the devices know which bits of IP address were network bits and which were the host bits? The designers of IP addresses divided IP addresses into five different classes. The first byte of any IP address (on the left) determined which class an IP belonged to and how many bits of the address were network bits. Today, this is known as the first octet rule.

IP Address Classes
The value of the first byte in the IP address determines its class (the first byte on the left-hand side).

  • Class A - values 0 through 127
  • Class B - values 128 through 191
  • Class C - values 192 through 223
  • Class D - (multicast) - values 224 through 239
  • Class E - (experimental) - values 240 through 255
This stems from the fact that some assumptions have been made regarding the most significant bits in the first octet (byte). The below table shows (in red) these bit reservations. They are fixed in the class and cannot be changed.
Pic. 3 - IP Address Classes.
As the result of such reservations in class A, class B and class C, one two and three bits respectively, the decimal values of the first octet are as follows (pic. 4).
Pic. 4 - IP Adress Classes and First Octet Rule.

This way, devices could easily determine which class of IP address the deal with by looking at its first byte (Pic. 4). Knowing which class the IP address belonged to help them determine which bits described network address, and which bits denoted a host in the network (Pic. 3 highlighted in green).

Fast forward to the present day. We still use the concept of IP address classes. And as such we refer to the so called: natural network mask (length).

  • Class A - Natural network mask length = 8 bits (/8) or, 255.0.0.0
  • Class B - Natural network mask length = 16 bits (/16) or, 255.255.0.0
  • Class C - Natural network mask length = 24bits (/24) or, 255.255.255.0
I would like to finish this post with one last observation. If your IP address uses the natural network mask length given the class (A, B, or C), we call this address a network address.

If your IP address uses the network mask length longer than the natural network mask used by this class, we call this IP address a subnet.

In my next post, I will show you how you can create subnets and how to calculate those given the host requirements.