Solved

Subnetting

Posted on 2003-12-04
31
1,790 Views
Last Modified: 2010-03-19
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
0
Comment
Question by:nawaf
  • 16
  • 8
  • 3
  • +3
31 Comments
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9873665
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
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 9873668
Dear nawaf,

Check if this makes any sense

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

Thanks,
Sunray
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9873673
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)
0
 
LVL 7

Expert Comment

by:MaB
ID: 9873680
This because the net adress is 0. Since 0 is a valid number you have the highest number beeing 255. 0-255 = 256 numbers.
0
 
LVL 7

Expert Comment

by:MaB
ID: 9873690
Not long ago the same question was posted. Look at this:
http://www.experts-exchange.com/Networking/Q_20815009.html
0
 

Author Comment

by:nawaf
ID: 9873875
in the http://www.experts-exchange.com/Networking/Q_20815009.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')
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9873909
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
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9873915
0
 
LVL 7

Expert Comment

by:MaB
ID: 9873975
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
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9873999
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
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874002
OOPS sorry!
I lost brainpower there for a moment. Discard my last, its not qiute correct.
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874013
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....
0
 

Author Comment

by:nawaf
ID: 9874024
Alan

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

Thanks
0
 

Author Comment

by:nawaf
ID: 9874056
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
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874101
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
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 7

Expert Comment

by:MaB
ID: 9874144
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
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874180
Free in this case means free for the subnet to use as host addresses.
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874234
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)
0
 

Author Comment

by:nawaf
ID: 9874271
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
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874318
Yep. You got it!
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874331
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.
0
 

Author Comment

by:nawaf
ID: 9874334
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

0
 
LVL 7

Expert Comment

by:MaB
ID: 9874359
>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.
-------------------------------------------------
0
 

Author Comment

by:nawaf
ID: 9874381


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
0
 
LVL 7

Expert Comment

by:MaB
ID: 9874409
>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
0
 
LVL 7

Accepted Solution

by:
MaB earned 300 total points
ID: 9874464
>Why you divided 256 by 4 and why divide by 2 (these are the reserverd addresses)

256 is all possible addresses (0-255) on a class C network. When subnetting to subnets with 4 addresses in each you get 256/4=64 possible subnets.

But since two subnets disappear because of the reserved class C network address and broadcast address you have two draw two subnets from the result. 64-2=62 subnets.
0
 

Author Comment

by:nawaf
ID: 9874506
Thanks a lot. Ok 300 points u deserve

0
 
LVL 7

Expert Comment

by:MaB
ID: 9874530
THX!
This isn't easy. Hope you've "seen the light".
0
 

Author Comment

by:nawaf
ID: 9874645
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

0
 
LVL 25

Expert Comment

by:mikeleebrla
ID: 9875423
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.  
0
 
LVL 7

Expert Comment

by:MaB
ID: 9880743
>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...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now