Calculating number of bits for host reservation

errorkenerrorken Posts: 21Member ■□□□□□□□□□
My question is about calculating the number of bits to be able to represent a required number of hosts (its a basic questionicon_smile.gif.

I was following the explanation at nugget lab (Subnetting Examples.pdf - "Great Exception")

I'll be quoting this to make it easy:
There is a similar rule for finding the number of bits to reserve for hosts. For example, if I wanted to break a range into 25 hosts per network, I know that I'll need to save 5 bits as host bits to satisfy the requirement. This rule works fine, but does not account for the two hosts that are unusable from every range: the network IP address and the broadcast IP address. The fact that binary counting starts from zero helps us with one of those IP addresses, but we can still come up one short in certain cases. For example, if we were asked to break a network into subnets that can hold up to 31 hosts, you would assume it would take 5 bits since 31 in binary is:
0 0 0 1 1 1 1 1
However, when you work out the problem you'll find that you only get 30 hosts per subnet (1 IP address short). The same thing happens with every “full” binary number: 3, 7, 15, 31, 63, 127. So how do you avoid this issue? You can always add 1 to the number of hosts required. For example, if you're asked to break a range into 25 hosts per subnet, figure it out for 26. If you're asked to break a range into 63 subnets, figure it out for 64…and so on.
I realize this exception gets somewhat technical… so to summarize:
When subnetting based on the number of networks, SUBTRACT 1 from the number
When subnetting based on the number of hosts per network, ADD 1 to the number

The way they explain it, is by searching the first exponent of 2, that represents a number lower than the number of hosts you are searching. For example, if you search 100 hosts, '64' is the first number that gets a binary '1' (since 128 is higher then 100).

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


x = don't care, since we allready found the highest bit. So, we will need 7 bits for the hosts.


This approach is ok, but there is a problem when you need for example 8 hosts, you'll endup with 4 bits since '1000' is binary for '8'. However, you are looking for 8 combinations, so the correct number of bits is 3, since 2³ = 8.

Now, I find my approach simpler, and it takes care of everything: just add '2' to the number of hosts you are searching, and then figure out how many bits you need to represent all the combinations (hosts).

So, if I would be ask to give the number of bits required to represent 3 hosts, then I would say 3 bits. 3 hosts + 2 hosts = 5 host, 2 bits is not enough since 2² = 4. 3 bits is enough since 2³ = 8.

Is my approach also fine ? Which is the common approach ?

Comments

  • dynamikdynamik Posts: 12,314Banned
    I really didn't like the way the Nuggets did subnetting. I think they made it a bit more complicated than it had to be with the calculator and converting to binary tricks (the 291 MS Press book was far worse though).

    It seems easy enough to do in your head. Take whatever the required hosts are and add two. You don't need to do that for the subnet bits (in most cases - research subnet zero for more).

    I do exactly what you do. It's easier and faster (at least for me). Nearly every trick I've seen just seems to make things more complicated.

    Probably the best tip to keep in mind is that each subsequent bit is twice the value while each previous bit is half that value. By simply remembering that the 10th bit is 1024 and the fifth bit is 32, you can get to pretty much any reasonable value by doubling or halving that value a few times (i.e. What's the 12th bit worth? 1024*2*2 = 4096).

    I think the best subnetting instruction I got was from Chris Bryant. His CCNA guide or his CCNA Trainsignal videos are great.
  • darkerosxxdarkerosxx Posts: 1,343Banned
    errorken: If you read the entire guide, he says to add 2.

    I've searched and read tons of subnetting guides. The guide from Jeremy Cioara(latest cbt nuggets instructor for ccna/ccent) has been the very fastest. After much practice with his guide and doing lots of examples, it's very easy to do complete subnetting back and forth in less than 10 seconds, in my head.

    I really can't say enough about his video and pdf subnetting guides.
Sign In or Register to comment.