Tuesday, March 18, 2008

Manual Subnetting Arithmatic

Continuing in the network administration vein that I began last post, I'll mention my latest struggle. For one of my certification exams (one I took and failed), I have to manual perform the math to figure out what subnet a computer is in, how many subnets are on a given network, and how many computers can be on those subnets.


Computers are identified on a network by an address. Every public address is unique. Under the most commonly used addressing scheme, the address is designated as follows: (I'll use BYU's web server for the example:)
The name we call www.byu.edu translates to an address. In this case, it's 128.187.16.242. All addresses have four octets of 8 bits. That's why address can never go above 255. You can't count above 255 in binary with 8 digits. So, you could have up to 255.255.255.255, but you can't that address is reserved. Addresses have been further divided into classes. ISPs (and entities acting as their own ISP) are assigned address blocks belonging to either a Class A, B or C address.
  1. Class A networks range from 0.0.0.0 to 127.255.255.255. The network is defined by the first octet in the address, and the individual host (computer) is defined after (like 15.X.X.X).
  2. Class B networks range from 128.0.0.0 to 191.255.255.255. a Class B network is defined by the first two octets (128.187.X.X in our case)
  3. Class C networks go from 192.0.0.0 to 223.255.255.255. They take the first three octets to define their network address (208.154.32.X is a class C network)
  4. There are several special reserved address: 10.X.X.X is reserved as a private Class A that anyone can use internally only, 192.168.X.X is a private Class B, etc.
From this example, you should be able to see BYU is a Class B network, because it is a 129.187 network. This basic definition creates one network with 65,534 possible addresses on it.
You don't want a single network with sixty-five thousand hosts (computers) on it. It's a BAD thing. In fact, such a network probably wouldn't even work at modern speeds due to the way ethernet (the current networking technique) is designed. Instead, you divide your network up into several subnets.

These subnets are logical divisions of your network. and are represented by a subnet mask. Subnet masks designate which part of the address are part of the host address, and which are part of the network. For example: 128.187.16.242, with a subnet mask of 255.255.255.0, would be a member of the 128.187.16.0 subnet, which reaches from 128.187.16.1 to 128.187.16.254 (255 is reserved in all cases). 128.187.25.247 with the 255.255.255.0 subnet mask would be part of the 128.187.25.0 subnet, which reaches from 128.187.25.0 to 128.187.25.254. Everyone with me here? Good

Up to this point, it's been rather simple. Sort of all or nothing. An octet is either entirely part of the network ID or the host ID. Beginning here is where it gets confusing:
Taking our imaginary computer with the address 128.187.25.247, if we change the subnet mask to 255.255.254.0, we've created a MAJOR change. We have now created a subnet that spans two of the third octets. The address is now a member of 128.187.24.0, which spans from 128.187.24.1 to 128.187.25.254. So, you have one subnet with space for 508 (254*2) computers. Now things aren't so clear, are they?
Actually, they (kind of) are. What we've done is created a decimal
representation of a binary object. The subnet mask that WAS 11111111.11111111.11111111.00000000 is now 11111111.11111111.11111110.00000000. See that? We changed one byte, and made two networks! this happens because the bytes in the subnet mask aren't really there as numbers, they're a binary yes/no for whether that digit is part of the mask or not.
If you can count in binary, you can figure out what the next subnet mask is. We subtracted one, so the next digit is worth, yes! 2!, creating 255.255.252.0.
This sort of hilarity can continue, in BYU's case, up to 255.255.0.0, with a binary representation of 11111111.11111111.00000000.00000000 which is the default designation for their Class B network. Beyond that, they have no authority. However, what if I have a Class C network, or I've run out of subnets, and want to divide something even smaller that my standard three octet subnets? I simply go into the fourth octet. 255.255.255.128 will create two subnetworks. I'll leave the binary representation of this one as homework for you.

Now for the truly tricky third part of this post.
Let's go back to my imaginary BYU computer, the one with the address 128.187.25.247. Let's give it a new subnet mask: 255.255.240.0. Now, give the computer name and subnet mask, you have to tell what subnet it is on. here's wher things get fun. Step one: convert the subnet mask and address to binary:
11111111.11111111.11110000.00000000. Step two: convert the address to binary: 10000000.10111011.00011001.11110111 Step Three, AND the whole thing:10000000.10111011.00010000.00000000. Step four, convert it back to decimal: 128.187.16.0.

There it is, 128.187.25.247/255.255.240.0 belongs to the subnet 128.187.16.0

There's one more requirement in the test. Be able to tell how many hosts can be in a subnet. Some of it is simple. A subnet mask 255.255.255.0 can have 254 computers. how do I know? Well, because I know; but really it's (2^8)-2 computers. The entire thing is (2^x)-2 where x is the number of bits in the host ID of the network. Okay, technically, it's 2^(32-n)-2 where n is the number of network bits instead of host bits.

simple, huh? And I was worried for when I retake the test.

6 comments:

Tracy said...

Ouch, that really hurt! Joe just explained it to me in "dummy" langauage, and that hurt even worse!

Emily said...

I can't believe I read the whole thing! (right...)

Margaret said...

You lost me at "subnet."

Shannon said...

I admit it, these are the kinds of post I skip. Sorry Joe. They're just WAY too...intense.

I vote to hear more about how Tracy's last month of pregnancy is going and your thoughts about the anticipation of shortly becoming new parents!

Joe said...

"I can't believe I read the whole thing! (right...)" Nice flashback to grade school, Em!

Margaret said...

By the way, isn't there something instrinsically wrong with being able to spout all that computer geekiness, but not being able to spell "arithmetic"?