## Monday, 2 July 2012

### Internetwork IP addressing and Subnetting

1. IP addresses are written using decimal numbers separated by decimal points. This is called dotted decimal notation of expressing IP addresses.
The different classes of IP addresses are as below:
Class Format Leading Bit pattern Network address Range Maximum networks Maximum hosts/ nodes
A N.H.H.H 0 0-126 127 16,777,214
B N.N.H.H 10 128-191 16,384 65,534
C N.N.N.H 110 192 -223 2,097,152 254

- Network address of all zeros means "This network or segment".
- Network address of all 1s means "all networks", same as hexadecimal of all Fs.
- Network number 127 is reserved for loop-back tests.
- Host (Node) address of all zeros mean "This Host (Node)".
- Host (Node) address of all 1s mean "all Hosts (Nodes)" on the specified network.
2. The range of numbers from 224.0.0.0 to 239.255.255.255 is used for multicast packets. This is known as Class D address range.
3. Subnetting is nothing but creating networks within a network. Subnetting allows an organization with a single IP address (Class A /Class B /Class C) to have multiple subnetworks, thus allowing several physical networks within the organization.
4. How to maximize the number of subnets for a given number of hosts:
Let us take a network ID of 168.8.0.0, and find the maximum number of possible subnets and the corresponding subnet mask that can accommodate at least 500 hosts. The steps involved are outlined below:
I. Find the Class of the IP address, in this case it is a class B network. Class B network has the form N.N.H.H. Therefore, we have a total of 16 bits (two octets) for assigning to internal networks and hosts. The minimum number of host addresses required is 500. The last octet corresponds to 2^8 = 256 hosts which is still less than 500 Hosts. Therefore, you have to borrow one more bit from the third octet to make it 256*2 = 512 Hosts. This leaves 7 bits in the third octet for assigning subnet addresses. This is equal to 2^7=128 subnets.
II. Write the 7 bits available for subnetting in third octet in the form 11111110 (last bit being the Host bit). The decimal equivalent of the first seven bits is 2^7+2^6+2^5+2^4+2^3+2^2+2^1 = 128 + 64 +32 + 16 + 8 + 4 + 2 = 254.
III. Therefore, the subnet mask required is 255.255.254.0.
5. How to maximize the number of hosts for a given number of subnets:
Determining the subnet mask that allows maximum number of hosts:
Let us consider an IP address 196.202.56.0 with four subnets and maximize the number of host for the given subnets. The steps involved are as below:
I. The number of subnets required are four. We need to add subnets of all ones and all zeros to this. This is because all zeros and all ones subnets belong to "this subnet" and "all subnets" broadcasts and can not be used. Therefore, the total number of subnets to be reserved is 4+2 = 6.
II. We want to implement maximum possible Hosts. Therefore, we need to minimize the number of subnets. This minimum number is 6 here. If we reserve 2 bits, it results in only 2^2=4 subnets which is less than 6. Therefore, we have to reserve 3 bits for implementing subnets, resulting in 2^3=8 subnets. This is now optimized for maximum number of Hosts (as we have optimized for minimum number of subnets).
III. Write the 3 bits available for subnetting in fourth octet in the form 11100000 (Five 0s being Host bits). The decimal equivalent is 2^7+2^6+2^5
= 128 + 64 +32 = 224.
IV. Therefore, the subnet mask required is 255.255.255.224.
6. 127.0.0.1 is the local loop back address.
7. In an internetwork, the number of distinct IPs' required are
1. One each per client computer
2. One each per server computer
3. One each per router interface
For example, your network has 2 servers, 26 clients machines, and 2 router interfaces the total number of IP addresses required are 30.
8. Finding the number of Hosts and subnets available for a given subnet mask: For example, let us find the number of hosts and subnets available for an IP 156.233.42.56 with a subnet mask of 7 bits.
a. Class B network has the form N.N.H.H, the default subnet mask is 16 bits long. There is additional subnet mask of 7 bits long.
b. 7 bits of subnet mask corresponds to (2^7-2)=128-2 = 126 subnets.
c. 9 bits (16-7) of host addresses corresponds to (2^9-2)=512-2 = 510 hosts.
Some times, the subnet mask is specified with the bits available in the default subnet mask. In this case the bits available in default subnet mask is 16. Therefore, total number of bits available in the subnet mask are 16+7=23. If you are given a subnet mask of 23 bits long for a class B address, it is understood that it contains the bits from the default subnet mask as well.
Hence, 126 subnets and 510 hosts are available.
9. The directed broadcast should reach all Hosts on the intended network (or subnet, if sub netted). For example, the directed broadcast address for an IP network 196.233.24.15 with default subnet mask is 196.233.24.255. This is arrived by putting all 1s for the host potion of the IP address.
10. To find valid hosts given an IP address (say 156.16.3.52) and a subnet mask (sat a 12-bit subnet). The valid hosts are determined as below:
A 12-bit subnet mask gives us 255.255.255.240; 4094 subnets, each with 14 hosts. (Host addresses of all zeros and all 1s can't be assigned). The 156.16.3.52 is in the 48 subnet range. The valid range is through 49 - 62. 63 is a broadcast address.
Here is how you get the subnet range: