Friday, April 18, 2008

IP Addressing/Subnetting : Chapter 1

Charter 1 : IP Address

1.0 Introduction

IP, Internet Protocol, address is a unique identifier for a host or host connection on an IP Network. IPv4 is a combination of a 32-bits numbers usually presented in a 4 decimal values. Each decimal value representing 8 bits from range 0 to 255 ( known as octet ) separated by decimal points.

EXAMPLE 1

IP Address : 192.168.0.1

This number is also view the values in binary form as below : IP01

Q : How to "translate" the 192.168.0.1 ( decimal IP ) value into binary format ?

Referring to the table shown below, we can "separate" the individual decimal value into :

  • 192 = 128 + 64 which is 1100 0000
  • 168 = 128 + 32 + 8 which is 1010 1000
  • 0 = 0 which is 0000 0000
  • 1 = 1 which is 0000 0001

IP02

Every IP address consists of two parts, one is identifying the node and the other one is identifying the network. The class of the address and the subnet mask determine which part belongs to the network address and which part belongs to the host address.

1.1 Address Classes for IPv4

For IPv4, there are 5 different address classes, in which you may identify it thru the first 4 bits of the first portion of decimal IP address.

  • Class A addresses begin with 0xxx, or 1 to 126 decimal.
  • Class B addresses begin with 10xx, or 128 to 191 decimal.
  • Class C addresses begin with 110x, or 192 to 223 decimal.
  • Class D addresses begin with 1110, or 224 to 239 decimal.
  • Class E addresses begin with 1111, or 240 to 254 decimal.

classes

Please also note that addresses beginning with 0111 1111, or 127 decimal, are reserved for loopback and internal testing for local machine ( a.k.a. 127.0.0.1 or also known as localhost ). Class D and class E are also not used as addresses as Class D addresses are reserved for multicasting and Class E is reserved for future use.

All the IP addresses from Class A, B and C are unique assignment in the public network. Anyhow, there are three IP network are reserved for private network :

  1. 10.0.0.0, Subnet Mask 255.0.0.0 ( 10/8 prefix )
  2. 172.16.0.0, Subnet Mask 255.240.0.0 ( 172.16/12 prefix )
  3. 192.168.0.0, Subnet Mask 255.255.0.0 ( 192.168/16 prefix )

These group of private network can be used in the private internal address anywhere in the network, in which it will not be route-able in the Public Network as it will not be forwarded in router by default as define in RFC1918.

1.2 Subnet Masking

When you apply a subnet mask to an IP address, it would allows you to identify the network address and the host part of the addresses by using the bitwise logical AND operation between IP address and subnet mask.

  • The network bits are represented by 1s in the mask.
  • The host bits are represented by 0s in the mask.

EXAMPLE 2

192.168.1.20 with subnet mask 255.255.255.0. 192.168.1 is representing the network while 20 is representing the host uniquely.

1100 0000. 1010 1000. 0000 0001. 0001 0100 = 192.168.1.20

1111 1111. 1111 1111. 1111 1111. 0000 0000 = 255.255.255.0

-----------------------------------------------------------------------------------------

1100 0000. 1010 1000. 0000 0001. 0000 0000 = 192.168.1.0

Therefore, 192.168.1.0 is the network address.

EXAMPLE 3

10.133.0.188 with subnet mask 255.255.224.0. 10.133.0 is representing the network while 0.188 is representing the host uniquely.

0000 1010. 1000 0101. 0000 0000. 1011 1100 = 10.133.0.188

1111 1111. 1111 1111. 1110 0000. 0000 0000 = 255.255.224.0

-----------------------------------------------------------------------------------------

0000 1010. 1000 0101. 0000 0000. 0000 0000 = 10.133.0.0

0000 1010. 1000 0101. 0001 1111. 1111 1111 = 10.133.31.255

Thus, the network address is 10.133.0.0.

In the case to get the broadcast address, you may change the subnet mask hosts bit to 1 and perform the bitwise logical AND operation between IP address and subnet mask. Thus, you may get the broadcast address of 10.133.31.255.

1.3 How logical AND works ?

The logical AND compares 2 digits, if both "1" then results "1", otherwise it is "0".

If you really still confusing on the logical AND, there is a simple trick to bypass the binary calculations but it is highly not advisable. :p

  1. Open your calculator. ( Click START->Accessories->Calculator )
  2. Select "Dec" ( decimal ).
  3. Punch in "133" and followed by "AND" ( as shown in the picture )
  4. Punch the netmask "133" and ENTER.
  5. You will get the result "133" as per Example 3 above.

calc

In the IP Addressing : Chapter 2, I will continue with more details' calculations to determine :

  1. Number of hosts for a network based on subnet mask or host bit length.
  2. How to "chop" a network based on subnet mask.

No comments: