jskfan
asked on
Math Formula to determine Network/Host subnet
Math Formula to determine Network/Host subnet
Let's say I have a subnet 192.168.10.0/24 , if I need to have 400 Hosts in the network , I can just change the subnet to 192.16.10.0/23.. this can stem from the formula (2^9) -2=510 ,this will be the correct one that covers 400 Hosts , because if I use (2^8)-2=254 , it will be less than 400
***2^9 means I already have 8 bits for the Host in the /24 and will just borrow 1 bit from the Network portion and will be /23
Sometimes the request is much more complex, for instance when they ask for 1113 hosts, then I will have to use the calculator and start from 2^1 and add each time 1 to the power to get closer to the desired number , ex: 2^10,2^11,etc.....
I wonder if there is a formula, like (2^x)-2= "a number close to 1113", and then I will just determine the value of x.
Thank you
Let's say I have a subnet 192.168.10.0/24 , if I need to have 400 Hosts in the network , I can just change the subnet to 192.16.10.0/23.. this can stem from the formula (2^9) -2=510 ,this will be the correct one that covers 400 Hosts , because if I use (2^8)-2=254 , it will be less than 400
***2^9 means I already have 8 bits for the Host in the /24 and will just borrow 1 bit from the Network portion and will be /23
Sometimes the request is much more complex, for instance when they ask for 1113 hosts, then I will have to use the calculator and start from 2^1 and add each time 1 to the power to get closer to the desired number , ex: 2^10,2^11,etc.....
I wonder if there is a formula, like (2^x)-2= "a number close to 1113", and then I will just determine the value of x.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You asked for maths, not counting ;-). As stated, ld(n) = log(n) / log(2).
n+2 is correct - n=510 hosts, you need to calculate for 512 addresses then.
n+2 is correct - n=510 hosts, you need to calculate for 512 addresses then.
We used this:
2^n -2 > #Hosts
the minus 2 because you have to remove the Network Address and the Broadcast address
So for 400 Hosts
testing for #host =400
n=1 => 2 -2 > 400 (not apply)
n=2 ....
...
n=8 => 256 -2 > 400 (still not apply)
n=9 => 512 -2 > 400 (woks)
(for #host = 1113)
n=10 => 1024 -2 > 1113 (not apply)
n=11 => 2048 -2 > 1113 (apply)
So this applies for n=9 (for 400) and n=11(for 1113)
then count from right to left 9 bits. from the 32 of a network
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ x . x x x x x x x x
And you turn on all the "_" bits for the submask:
255.255.253.0 so /23 for the 9 bits
Or count n=11 (for 11113)
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ _ _ x x x . x x x x x x x x
255.255. 248.0
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ----> this is the network part.
Now you can have as many subnets as you want to apply the same formula.
2^n -2 > #Subnets
and add them to the actual count of bytes, for example (15 subnets)
2^n -2 > 15
n=3 => 8 -2 > 15 (not apply)
n=3 => 16 -2 > 15 (not apply)
n=4 => 32 -2 > 15 (apply)
The would be 4 bits of network
So this applies to n=9 (for 400) and n=11(for 1113)
then count from right to left 9 bits. from the 32 of a network
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ s s s s x . x x x x x x x x
Where you do the math for each subnet
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
...
1 1 1 1
And for count n=11 (for 11113) it's the same 4 bits
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ s s s s x x x . x x x x x x x x
And the same logic
2^n -2 > #Hosts
the minus 2 because you have to remove the Network Address and the Broadcast address
So for 400 Hosts
testing for #host =400
n=1 => 2 -2 > 400 (not apply)
n=2 ....
...
n=8 => 256 -2 > 400 (still not apply)
n=9 => 512 -2 > 400 (woks)
(for #host = 1113)
n=10 => 1024 -2 > 1113 (not apply)
n=11 => 2048 -2 > 1113 (apply)
So this applies for n=9 (for 400) and n=11(for 1113)
then count from right to left 9 bits. from the 32 of a network
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ x . x x x x x x x x
And you turn on all the "_" bits for the submask:
255.255.253.0 so /23 for the 9 bits
Or count n=11 (for 11113)
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ _ _ x x x . x x x x x x x x
255.255. 248.0
--------------------------
Now you can have as many subnets as you want to apply the same formula.
2^n -2 > #Subnets
and add them to the actual count of bytes, for example (15 subnets)
2^n -2 > 15
n=3 => 8 -2 > 15 (not apply)
n=3 => 16 -2 > 15 (not apply)
n=4 => 32 -2 > 15 (apply)
The would be 4 bits of network
So this applies to n=9 (for 400) and n=11(for 1113)
then count from right to left 9 bits. from the 32 of a network
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ _ _ s s s s x . x x x x x x x x
Where you do the math for each subnet
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
...
1 1 1 1
And for count n=11 (for 11113) it's the same 4 bits
_ _ _ _ _ _ _ _ . _ _ _ _ _ _ _ _ . _ s s s s x x x . x x x x x x x x
And the same logic
Jose, that is what the OP does already, but wanted a direct method.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
Thanks, but in fairness, Qlemo deserved at a minimum the lion's share of the points to this. He did provide the solution, while I provided the additional detail of what was necessary to do it in Windows.
ASKER
log(n+2) / log(2) can be much more involved... than counting 1,2,4,8,16,32,64,128,256,5
using 1,2,4,8,16,32,64,128,256,5
Open in new window
So 400 hosts will be (2^9)-2 =510
then from the right of the subnet (the host portion) we'll use 9 bits for the hosts , and we'll be left with 23 bits for the Network portion
***in the calculator , I do not see the ld function.. where can I find it ?