Saturday, November 13, 2010

Lesson 27 - IPv4 Address Dissected - Part 1

If you already feel comfortable with binary-to-decimal and decimal-to-binary conversions you're up to this post's challenge: learning more about IP version 4 address (IPv4). If you need to brush upon the numeral conversions, check my previous post.

In one of the earlier posts on TCP/IP traffic flow, I briefly described the importance of the addresses. In order for devices to communicate they must be uniquely identified in the network after all. There are typically three such identifiers we use to distinguish between devices:
  1. Names - These are used by humans. Applications use addresses not names. Hence, DNS services out there (DNS service is used to resolve names-to-ip, and ip-to-names).
  2. Layer 3 addresses - logical and hierarchical unique identifiers of devices in the network. All layer 3 protocols such as IPX, Apple-Talk, IP etc. use different forms of layer 3 addresses. 
  3. Layer 2 addresses - flat and most often fixed identifiers of devices (see lesson 6).
DNS Names
Names are used to simplify communication between devices for people. Instead of typing something like this in your web browser: http://72.163.4.161/, which will open the Cisco web server's main page, you prefer to type something like that: http://www.cisco.com/, don't you? If you do the latter, before your web browser sends the request to the Cisco's web server, it will need to ask your local DNS server about the IP address that is associated with the name www.cisco.com. 

Layer 2 addresses 
Since the communication between computers is loosely based on well known OSI model (TCP/IP model is based on it which I described in lesson 4), all upper layers are ultimately encapsulated in a layer 2 header which uses flat form of the address. Such addresses are Ethernet MAC addresses, Frame-Relay DLCI numbers, ATM VCI/VPI pair of numbers etc. What these are depends on what layer 2 technology you use.

Layer 3 addresses
Layer 3 addresses are logical and hierarchical. This post is about IP addresses, but keep in mind that in the past we used to use other routed protocols as well (such as Apple-Talk, IPX and others). These other protocols also used layer 3 addresses that were logical and hierarchical.

IP address (which in OSI terminology is an example of layer 3 address ) is logical. This means, that you can easily change it either manually or using dynamic address assignment (DHCP) service. Consider your private laptop that you use at home. It, most likely, gets an IP address from the DHCP server configured on your broadband router. Then, the following day you take it to work with you. The moment you hook it up to your corporate network its current IP address will be replaced by a new one provided by the corporate DHCP server. It is almost for sure going to be different than IP address your computer uses at home. So the word: logical, describes the volatile nature of the address. The same device can use a different layer 3 address (identifier in the network) depending which network it resides on.

IP address is hierarchical. It is a bit similar to a telephone number as it has a structure. In telephony we use similar concept of hierarchy. Consider this phone number:
001 201 555 1234.

The structure of this phone number has the hierarchy which looks as follows:
00 - the number identifying an international call
1 - the prefix denoting country. Here: it is USA.
201 - number denoting the state in the US. Here: it is New Jersey.
555 - number of the telephone exchange in New Jersey (here it is a fictitious one)
1234 - number of the subscriber connected to this fictitious exchange. 

The reason I show you this, is that what seems to be a simple and flat 13-digit phone number, in fact has a hierarchy built in it. The numbers carry special meaning. The same is true about layer 3 addresses in computer networks.

IP address structure consists of two components:
  1. Network or subnet address (identifier).
  2. Host address (identifier) in the network or subnet.
Let us dissect both components using your computer's IP address as an example. Open the command line window and type in the following command:

in Microsoft Windows:
c:\ipconfig

in Linux/Unix/Mac OS:
$ifconfig eth0

Look at my computer's address below.

Pic. 1 - Output of 'ifconfig eth0' command.

Can you find MAC address, IP address and Netmask in the above output?

MAC address: 00:1e:4f:b0:b2:fc
IP address: 192.168.1.2
Netmask: 255.255.255.0

An IP address uses four numbers and dots as the delimiter. Each number is a one byte number which means that it must be in the range of 0 through 255 using decimal notation.

IP address uses another four byte number that follows it called: network mask (aka netmask). It is the netmask that creates the hierarchy in the IP address. It separates the bits in the address to tell us which ones denote the address of the network/subnet and which ones denote the host address in the network/subnet. In order to see that, check my IP address in the pic. 2 below. The first three bytes (24 bits) denote the address of the network, and the remaining byte (8 bits) denotes the host address in the network.

Pic. 2 - IP address in decimal notation.

In order to actually see the hierarchy presented in pic. 2, let us convert the IP address into binary first.

Pic. 3 - IP address decimal-to-binary conversion.

Now, convert the decimal netmask we use in the example (255.255.255.0) into its binary equivalent. What is it going to be?

 Pic. 4 - Network mask decimal-to-binary conversion.


Network mask bits correspond to the IP address bits. The bits in the IP address which are masked by the network mask bits (1s) denote the network portion of the address. The bits in the IP address that are not masked (corresponding bits in the netmask are 0s), are denoting the host address in the network. Let us combine the IP address bits with the netmask bits to see the hierarchy now.

Pic. 5 - IP address and the network mask create hierarchy.


Clearly, the first three bytes (192.168.1) in the IP address are masked (255.255.255). Those twenty four bits are the NETWORK bits, the remaining eight bits in the address (2) are not masked (netmask bits are all 0) and become the HOST bits in the address.

The hierarchy in my computer's IP address could be depicted like this:

Pic. 6 - IP address Hierarchy.


There is a bit more we need to know about IP addresses.

In my next post I will continue on explaining what IP address classes are and how they are used today. Also, I will describe the concept of network and subnet and the difference between them. I will finish IP address description by telling you about certain reservations in the IP address range we must be aware of. This and the next post will be the pre-requisites for the upcoming lesson about calculating subnets.

Cisco Is Easy - Main

  Cisco Basics (CCNA level)  Lessons: Watch Video Tutorials on Youtube 01 - Connecting to Cisco Console Port with MINICOM 02 - Navigatin...