Link to home
Start Free TrialLog in
Avatar of nawaf
nawaf

asked on

Subnetting

Hi

I wanted to understand TCP/IP so I bout a book called teach yourself TCP/IP in 24 hours . I am trying hard to understand subnetting wich is not explained well in that book. Any way in assigning subnet mask we use 255.255.255.0 for class c for example but why 255 not 256 because 2**8 is 256.

Also if you know an easy way to understand subnetting please let me know thanks


nawaf
Avatar of ADSaunders
ADSaunders

Hi nawaf,
 It's 255 because that is the largest value that you can fit into 8 bits. The calculation is actually 2**8 - 1.

Regards .. Alan
Dear nawaf,

Check if this makes any sense

http://www.j51.com/~sshay/tcpip/ip/ip.htm

Thanks,
Sunray
Avatar of sunnycoder
Hi nawaf,
> Any way in assigning subnet mask we use 255.255.255.0 for class c for example
> but why 255 not 256 because 2**8 is 256.

but you have only 8 bits and the biggest number you can represent using 8 bits is 1111 1111 which is 255
the range is 0-255 (total 256 different values)

Cheers!
Sunny:o)
This because the net adress is 0. Since 0 is a valid number you have the highest number beeing 255. 0-255 = 256 numbers.
Not long ago the same question was posted. Look at this:
https://www.experts-exchange.com/questions/20815009/Subnetting.html
Avatar of nawaf

ASKER

in the https://www.experts-exchange.com/questions/20815009/Subnetting.html 

Somebody mentioned this formula to find the number of hosts.
But can some body please give me an example.
1. give an IP address
2.subnet mask
3.find number of hosts

Just apply this formula to find the number of hosts.
Please I increase points t0 200 to understand it

Thanks

and I will double points
>
>The formula for figuring out the number of 'host' bits in a subnet mask is
         2^n=(number of nodes )          (2^n  means '2' to the power of 'n')
practically formula should be (2^n) - 2

you cannot use all 0s and 1s ... they are supposed to be reserved but theoretically, they do exist

http://www.umesc.usgs.gov/http_data/w3_class/subnet.htm
http://web.tic.ac.uk/cisco/download/CCNA/Subnetting%20Class%20B%20Example%202.pdf
A bit tricky but i'll try.

I would like to turn the question. First define how many hosts you want, then calculate the subnet mask. For example you want, for some peculiar reson, two hosts on your subnet.

You also need to reserve 2 addresses beside the hosts. The lowest address is always reserved for the "network" and the highest for broadcast. To have two possible hosts you need to reserve 2+2=4 addresses.

To be able to represent 4 in binary value you need to reserve three bits.
00000100 binary = 4 decimal
To reserve(enable) three bits in the subnet mask you set them to 0 giving you
11111000 binary = 252 decimal

Thus subnet mask will be 255.255.255.252
Hi nawaf,
You might find the free subnet calculators at these addresses useful for determining subnets, host counts and masks :

http://www.wildpackets.com/support/downloads
http://support.solarwinds.net/updates/New-customerFree.cfm

 .. Alan
OOPS sorry!
I lost brainpower there for a moment. Discard my last, its not qiute correct.
To represent 4 numbers you will need 0,1,2,3.
Thus 00000011 binary is the highest = 2 reserved bits
This gives subnet mask
11111100 = 252
Now i hope my brain is turned on again....
Avatar of nawaf

ASKER

Alan

No calulator ! I want to understand it then do the calculation myself.

Thanks
Avatar of nawaf

ASKER

MaB

Thanks !

Step1

>To represent 4 numbers you will need 0,1,2,3.
>Thus 00000011 binary is the highest = 2 reserved bits

Step1 is ok no problem here but
 

Step 2
>This gives subnet mask
>11111100 = 252
>
How did you get from step1 1 to step 2

I cant see the relationship b/w step 1 and 2

Thanks
If you split a class C (255.255.255.0) net into subnets with two hosts in every subnet you would think thatyou would have the first subnet with X.X.X.0 as the network adress, X.X.X.1 and X.X.X.2 as host addresses and X.X.X.3 as the broadcast address for that subnet. The next subnet starting with X.X.X.4 as the network address and so on....

But here's a catch. Since X.X.X.0 is reserved as network adress for the class C net you cant use that in a subnet. Same for the X.X.X.255 that is reserved ass the class C net broadcast address so you cant use that either. That leads to the first subnetaddress being X.X.X.4 and the last subnetaddress being X.X.X.248 (with X.X.X.251 as the broadcast for that subnet).

You lose 8 adresses by doing the subnetting (or 6 host addresses if you dont count network and broadcast addresses)

What you get is 256/4 -2 = 62 subnets
From step 1 to step 2 you have to do a little mind bungling.

As said to represent 4 possible numbers (0 being a number) you need two bits.
00000011=3

When you set a subnet mask you reverse the thinking.
1 means this bit is "locked" 0 mens the bit is "free"

Having need of 2 bits to represent 4 possible numbers you need two set the two least significant bits free.
this gives you
11111100
Free in this case means free for the subnet to use as host addresses.
If you have a network address that is, say, 192.168.131.4 with a subnet mask of 255.255.255.252 that will make the first 30 bits in the IP address locked telling the computer that it has two bits that describes hosts on the network (since the total address is 32 bits long). That leaves the network looking like this:
192.168.131.4 (Network)
192.168.131.5 (Host 1)
192.168.131.6 (Host 2)
192.168.131.7 (Broadcast)
Avatar of nawaf

ASKER

MaB

I really appreciate the help.

I got u but
Just to clarify.
So With is I am going to get 62 subnets and 4 hosts for each subnet? right ?

Thanks again
Yep. You got it!
Accept for that it will be two hosts (two possible network addresses) since 2 addresses in each 4 address subnet is reserved for that subnets network address and broadcast address.
Avatar of nawaf

ASKER

sunray_2003:-

In the site you mentioned :

http://www.j51.com/~sshay/tcpip/ip/ip.htm

In the "example of a class C subnet "

Why they got 30 hosts ? they should be 32 host 2**5 right?

and  how did they get 6 subnet from ?

111 gives 7 (decimal)
11100000 give 224 (decimal )

how the y get 6 please

Thanks

>Why they got 30 hosts ? they should be 32 host 2**5 right?

Because the first address is reserved for the network and the last for broadcast as the following cut from the same site states:
--------------------------------------------------
Question: What happened to 198.53.147.32 and 198.53.147.63 why can't these be IP addresses ?

198.53.147.32 - Is the subnet's Network Id which is revserved for the physical segment (00100000).
198.53.147.63 - Is the subnet's Broadcast Address (00111111)

As stated above every network or subnet has a IP address for the Physical segment and a Broadcast Address.
-------------------------------------------------
Avatar of nawaf

ASKER



MaB my friend

Why you divided 256 by 4 and why divide by 2 (these are the reserverd addresses)

What you get is 256/4 -2 = 62 subnets
>and  how did they get 6 subnet from ?

Same here as example with 4 addresses on subnet.
With 32 addresses on subnet (Leaving 30 for hosts since network and broadcast addresses are "taken") you will have 256/32=8 subnets.
But as with the other example the first address (198.53.147.0) is reserved for the class C network address this cant be used. Same for 198.53.147.255 which is the broadcast address for the class C network. This makes the first and last address space unuseable as subnet.(When subnetting the first and last subnet always disappears)
Thus 256/32=8-2=6
ASKER CERTIFIED SOLUTION
Avatar of MaB
MaB
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nawaf

ASKER

Thanks a lot. Ok 300 points u deserve

THX!
This isn't easy. Hope you've "seen the light".
Avatar of nawaf

ASKER

just one last question in the example:

http://www.j51.com/~sshay/tcpip/ip/ip.htm

what was the question to that example?

I mean the question was find the number of hosts and number of subnets or the number ?

or the number  6 segments/subnets is given and they want to find the subnet mask ?

Thanks

It all goes back to the binary code.  255 in binary is 11111111.  Since an IP address is a 32 bit binary address divided into 4 sets of 8 in base 10 instead of 2 for ease of use to people.  256 would be 100000000 not 11111111.  This probably confused everyone more,, but this is the mathmatically correct answer.  
>I mean the question was find the number of hosts and number of subnets or the number ?

>or the number  6 segments/subnets is given and they want to find the subnet mask ?

I believe the second assumption is right here. 6 subnets are given and the corresponding subnetmask is derived from that by using this method.
----------------------------------------------------------------------
Determine the number of Physical segments required in your network and covert to binary format. In the example below 6 segments are required

Count the number of bits required to represent the number of physical segments in binary. With 6 required subnets (Binary value is 110). Representing 6 in binary requires 3 bits

Convert the required number of bits to decimal format in high order (left to right).

Configure the 3 required bits as the first bits of the host id. The decimal value for binary 11100000 is 224. Representing a subnet mask of 255.255.255.224
---------------------------------------------------------------------
The key here is that 6 is represented by 110 binary i.e three bits is needed. You can obviously use this information to directly set the subnet mask by "locking" the highest three bits (leftmost) in the last 8 bit charachter of the subnetmask giving:
11111111.11111111.11111111.11100000
    255    .     255    .    255     .    224

This would mean that if you want 10 subnets you would use the binary value for 10 which is 1010 i.e four bits are requiered thus giving the subnet:
11111111.11111111.11111111.11110000
    255     .    255    .    255     .    240

If you look at the example you will see that this actually provides you with 14 subnets but the calculation persumes that you want AT LEAST 10 subnets. You will recieve the nearest higher number of subnets with this method. The next step down is 6 subnets and that is not enough for this last example. You will always need to accept the next larger number of subnets. Meaning if you want 18 subnets you would have to accept 30, wanting 40 gives you 62 and so on...