Friday, May 6, 2011

Subnetting Part 2 - Subnet Mask, Magic Number


Class
Host address range
Network address
Default mask
A
    0.0.0.0 - 127.255.255.255
x.0.0.0
255.0.0.0
B
128.0.0.0 - 191.255.255.255
x.x.0.0
255.255.0.0
C
192.0.0.0 - 223.255.255.255
x.x.x.0
255.255.255.0


(from http://compnetworking.about.com/od/workingwithipaddresses/l/aa042900a.htm)

Class D and any others are reserved or not really in use.

These are the general subnet masks for each IP address.

Now you want to get more specific.

You have an IP address of 192.16.32.0 (a class C address) and you want to get a subnet it for 8 subnets and 25 hosts. (Note: you will always want enough, or more than enough subnets or hosts, more is never bad)

Subnets (number of one's)
2n  (The n here is denoting the number of one's needed in the last octet) = 2n = 23=  8 subnets

Hosts (number of zeros)
2-2 (The n here is denoting the number of zero's needed in the last octet) = 2n-2 = 25-2 30 hosts

So from those two equations we see that we need 3 one's and 5 zeros to give us 11100000 in binary and if we convert that to decimal we get (128+64+32) = 224 so our subnet mask for 192.16.32.0 is

192.16.32.224

With that we can break our network into subnetworks. Just take 256 (256 is called the "magic" number, we always use it for the purpose of finding the steps between subnets) so
256-224 = 32. So we now know that there is 32 steps between each network. So we can get the network addresses as follows:

(8 subnetworks)
192.16.32.0
192.16.32.32
192.16.32.64
192.16.32.96
192.16.32.128
192.16.32.160
192.16.32.192
192.16.32.224

Each of these are a network address. With these you can tell the range, network address, and broadcast address of any IP address that comes your way.

For example a router pulls up 192.16.32.37
We as humans can see that that would fall on the table above between 32 and 64. Meaning that the network address of that IP is 192.16.32.32, the broadcast is 192.16.32.63 (64 is the network address of the next subnet), and the range would be 192.16.32.33 - 192.16.32.62.

CITER and more coming your way.

If you want to practice subnetting the best thing I've found is: http://faculty.valleycollege.net/rpowell/jscript/subnet2.htm
It will automatically generate a problem and let you input the solution.


Subneting Part 1 - Binary/Decimal Conversion

Before you even attempt subnetting please be overly confident in your ability to convert binary to decimal and vice versa. The easiest way I've found is this method.

So you have the number 76 in decimal and you want it in binary, well binary is broken into 8 bits of ones and zeros. Each one or zero represents whether that number is turned on or not. The following numbers never change. The easiest way for me to remember these numbers is to just add 1+1=2, 2+2=4, 4+4=8, 8+8=16, 16+16=32, 32+32=64, 64+64-128


128
64
32
16
8
4
2
1










They always fall largest to smallest like above.

So you have the number 76 and you want it in binary. The easiest way to do this is look at the table above. Can you take 128 out of 76 (76-128)? No. That means there is a 0 in that bracket. You can follow along with the table below. Can you take 64 out of 76 (76-64)? Yes. So that number is turned on. 76-64=12.
With twelve left over we continue down the number path. 12 out of 32 (12-32)? No. 12 out of 16 (12-16)? No.  12 out of 8 (12-8)? Yes. Which leaves us with 4 and the next would be 4-4, so yes. With a remainder of 0's.


128
64
32
16
8
4
2
1
 0
 1
 0
 0
 1
 0
 0


Our final binary is 01001100.

Alright so say instead we have a binary number of 11110000 (NOTE: 4 one's, and 4 zero's to total 8 bits).
Plug that number into our chart.


128
64
32
16
8
4
2
1
 1
 1
 1
 1
 0
 0
 0
 0


Every number with a one is "turned on" so you just add those numbers together.

128+64+32+16 = 240. So our decimal version of 11110000 is 240!

A great place to practice is http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/binquiz.html

The quiz there automatically generates a random number and lets you input your answer and check if it's right!

Well, I hope this helps on your quest to figure out subnetting. The next part will be a little more indepth.