IP Subnetting Class
2/27/01 By:
Christophor Ronk
Section 1: Theory
Computers use the
binary numbering system in everything that is done, even a task as simple as
pressing a key on your keyboard. For Example: when you press the letter A on
your keyboard, the keyboard controller sends a hex message with a series of 1s
and 0s. The computer then looks those 1s and 0s up on a chart to determine
which character was sent.
This same method is used
throughout the entire computer and IP subnetting is based on this system. A
binary digit (called a bit) can only be a 0 or a 1. If humans counted in this manner, and one counted from 1 to 10,
it would look like this: 1,10,11,100,101,110,111,1000,1001,1011. In computers
everything is sent in bytes; 1 byte contains 8 bits of data. In our previous
example, the letter A is sent through the computer using 8 bits of data:
01000001. All of this data combined is 1 byte of information. Any digits not
used, are sent regardless. For instance, the binary number 4 is expressed
as 00000100 so that all 8 bits within
the byte are used. Let us digress a bit and talk about storage. When a hard
drive is said to have a capacity of 20 Gigabytes, (20,000,000,000 bytes) in
reality that hard drive stores 160 billion 1s and 0s; even CD rom drives use
lasers to determine 1s and 0s. This is the essence of digital. Any digital
signal contains a mark or a space, which is just another term in radio for 1
and 0.
Now with basic binary
out of the way, let us look more closely at IP addressing:
You see: Computer
Sees:
63.199.71.1 00111111.11000111.01000111.00000001
255.255.255.0
11111111.11111111.11111111.00000000
In the
example above you see that the subnet mask lines up perfectly with each bit in
the preceding IP address.
A subnet mask will always be
consecutive 1s followed by consecutive 0s, never mixed. For example, let us
look at the binary equivalent of a different subnet mask.
255.255.255.0 11111111.11111111.11111111.00000000
255.255.255.240
11111111.11111111.11111111.11110000
As you can see, the
1s and 0`s are segregated and never mix. A subnet is a group of IP addresses.
Due to the fact that we will only deal with a class C address, the first 3
octets will ALWAYS be 1s (on a class C). For simplicity we will drop the first
3 octets and only deal with the last.
Because there are
only 8 bits per octet, and the 1s and 0s never mix, there are only 8 possible
numbers for a subnet mask. They are as follows:
0


00000000

128


10000000

192


11000000

224


11100000

240


11110000

248


11111000

252


11111100

254


11111110

255


11111111

Picture a subnet like
a cucumber. Every time you add a 1 to the subnet mask, you slice every subnet
in half. And create two new subnets. For Example: The subnet mask 00000000
means that there are 256 possible binary numbers with those 8 available digits (because
11111111 = 255 in binary + 1 because 0 is also valid). This means there is 1
subnet containing 256 valid numbers. Lets assign one of those 0s as a subnet
ID using the subnet mask. Instead of
the subnet mask being 00000000 we are going to change it to 10000000. That means one of the digits is being used
to separate the class C into 2 groups, group 0 and group 1 (because it can only
be a 0 or a 1). To figure out how many valid numbers per group, you see how many
possible numbers exist. We have 7 bits to work with so we have 0000000 through
1111111. 1111111 in binary is 127 so
there are 128 valid numbers per subnet.
Lets break it down even
further. Lets add another 1 to the
subnet mask making it 11000000. This has taken our two groups, and broken them
in half making 4 groups: group 00,01,10,11. Now we can figure out how many
valid numbers per group there are. Out of 8 bits, two have been taken for
subnetting, leaving us 6 additional bits to work with. With 6 bits, the highest
that can be counted in binary is 63 + 1 (accounting for 0) meaning 64 valid
numbers per subnet. As you can see, adding 1s to the subnet mask simply
further divides the groups of Ips into equal parts.
Section 2: Application
Now that we have
studied the theory behind IP Subnetting, we can now learn how to apply that
theory to IP subnetting. Let us further examine the nature of the bits.
Because of the nature of binary code, each bit can be assigned a value. For
this we start with the first bit. In
binary the first bit is the bit farthest to the right. That bit has 2 possible
values (0, and 1) and there are no bits to the right of it, so the value of
that bit is 2^0. The second bit has 2 possible values and there is 1 bit to the
right of it so its value is 2^1 and so on until one gets to the last bit which
is 2^7.
0 0 0 0 0 0 0 0
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
If
one does the math, the bits values are as follows:
0 0 0 0 0 0 0 0
128 64 32 16 8 4 2 1
With this knowledge,
you can now count in binary as computers do.
Look at the binary
number: 00000001
According to the chart, the 1st
bit has a value of 1.Therefore, the decimal equivalent to 00000001 is 1.
Now let us look at
the binary number: 10000000
According to the chart, the 8th
bit has a value of 128. Therefore, the decimal equivalent to 10000000 is 128.
Finally, lets look at
the binary number 10010101
According to the chart, the 8^{th}
bit has a value of 128 so we add 128. The 5^{th} bit has a value of 16
so we add 16. The 3^{rd} bit has a value of 4 so we add that. The first
bit has a value of 1 so we add that as well. Add all of it up and you get
128+16+4+1 = 149. Therefore, the binary
equivalent to 10010101 is 149.
Lets take this the
other way. Lets say you are given 149 and asked the binary equivalent. In order
to do this one must start with the bit that holds the greatest value. This is
the eighth bit. It is worth 128. Is 128 < 149? Yes it is, so assign a 1 to
the eighth bit and subtract it from the total. Ok, we now know that the eighth bit is a 1 and the remainder is
21. Now lets move to the 7^{th} bit. The value of this bit is 64. Is 64
< 21? No it is not so this bit is a 0. We now know that the 8th and 7th bits
are 1 and 0. Lets continue to the sixth bit. Is 32 < 21? No it is not, the 6^{th}
bit is a 0. Is 16 < 21? Yes it is, so we make the 5^{th} bit a 1 and
subtract 16 from the remainder leaving 5. We have now constructed the last 4
digits of this binary number (1001) and if you continue you will find that the
end result is indeed 10010101. (note that this will only work for numbers up to
255. In order to count higher, a ninth bit would be required).
Section 3: To top it off
For each subnet two
valid numbers are used in overhead. The first IP address is used for subnet ID
and the last IP is used for broadcast. Lets look at the class C 63.199.71.x . If the subnet mask is 00000000 then that means all 256 valid
numbers (0255) are in the same group. The first number is 0 and is used for
the subnet ID. The last number is 255 and it is used for the broadcast leaving
1254 as valid IP addresses.
If we break that
group into 2 subnets by changing the subnet mask to 10000000 that breaks the
256 numbers into two groups, 0127 and 128255. In each subnet, the first and
last numbers are used. This means the two subnets have usable ip addresses
1126 and 129254. Lets break it down by IP address.
63.199.71.0 Subnet
ID for first subnet
63.199.71.1 63.199.71.126 Usable IP address first subnet
63.199.71.127 Broadcast
IP address for first subnet
63.199.71.128
Subnet ID for second subnet
63.199.71.12963.199.71.254 Usable IP address second subnet
63.199.71.255
Broadcast IP address for
second subnet
The further you
subnet, the more IP addresses are used for subnet ID and broadcast. It is a
number that doubles every time you further subnet the class C. The following is a chart in relation to the
number of IP addresses lost to overhead:
Subnet Mask IP
addresses lost
00000000 2
10000000 4
11000000 8
11100000 16
11110000 32
11111000 64
11111100 128
11111110 256
As you can tell, the last
subnet mask is never used and 11111100 is rarely used due to the gross waste of
IP addresses.
Now that we have
learned the core of IP subnetting, we can express the subnet mask in its
decimal counterpart to save space. (Refer to page 2).
Lets look at the ever
important bit chart (originally on page 3).
128 64 32 16 8 4 2 1
This chart is the
base of subnetting. If you have a class C available and a customer wants 4
consecutive IP addresses we want to see if this is possible. If you start on
the first bit and count over to 4, you move two spaces to the left. This means
the first two bits in the mask are 0s and the rest are 1s. The mask is now 1111100 or 252. That means four IP addresses? No, that means
4 valid binary numbers. Remember, the
first and last numbers are used for subnet id/broadcast. This leaves 2 usable
IP addresses. We have to go to the next subnet mask, which is 248. 248 is
11111000. The first 3 bits are zero so
start at 1 and count over 3 spaces. You land on 8. This means there are 8 valid numbers. Subtract 2 to get the total
valid IP addresses per subnet. The total is 6 usable. In this case, the
customer would have to pay for 6 ip addresses as apposed to the 4.
Now lets see the subnets in
relationship to each other. If you took
the 63.199.71.x class C and subnetted it with a 224 subnet mask, how many
subnets would there be? The binary equivalent of 224 is 11100000. Using the
table we count over 4 spaces and that takes us to 32. That means that the subnet ID for each subnet is separated by 32
ip addresses. The subnets would be as
follows:
63.199.71.0
63.199.71.32
63.199.71.64
63.199.71.96
63.199.71.128
63.199.71.192
There are a total of six subnets
with 30(322) usable IP addresses per subnet.
Useful Tables:
Subnet Mask Binary Equivalent
0


00000000

128


10000000

192


11000000

224


11100000

240


11110000

248


11111000

252


11111100

Bit
Chart:
128 64 32 16 8 4 2 1