Friday, May 13, 2011

How to determine network address, broadcast address and number of usable host addresses if you are given an ip address.

How to find network address and broadcast address of a given ip address?
also how to find a range of usable host addresses for a given ip address.

In our example we shall use
IP ADDRESS: 192.168.31.5
IP SUBNET MASK: /28 or 255.255.255.240




/28 or 255.255.255.240 = 11111111.11111111.11111111.11110000
192.168.31.5 = 11000000.10101000.00011111.00000101

11111111.11111111.11111111.1111~0000
11000000.10101000.00011111.0000~0101
*"~" means starting of host bits by the mask.

For a network address all the host bits have to be 0
therefore

11111111.11111111.11111111.1111~0000
11000000.10101000.00011111.0000~0000 = 192.168.31.0


For a broadcast address all host bits have to be 1
therefore

11111111.11111111.11111111.1111~0000
11000000.10101000.00011111.0000~1111 = 192.168.31.15


Now, if you want to know how many usable host address we have
remember we cannot use network address and the broadcast address for host addresses, So,
it is always
Square Of (n) - 2
where n is the number of host bits

in our example: n = 4
Square of 4 = 16;
16 - 2 = 14

therefore starting usable host address = 192.168.1.1
ending usable host address = 192.168.1.14

so .1 to .14 are the usable host addresses

2 comments:

MrInfo said...

IP ADDRESS: 192.168.31.5
IP SUBNET MASK: /28 or 255.255.255.240

we have a easier way to calculate broadcast number:

1) Invert subnet mask:
255.255.255.240:
>> 11111111.11111111.11111111.11110000
>>invert: 00000000.00000000.00000000.00001111

2) Logically OR IP address with inverted subnet mask:

11000000.10101000.00011111.00000101
OR
00000000.00000000.00000000.00001111
___________________________________
11000000.10101000.00011111.00001111

Result: 192.168.31.15

Ashlesh said...

Thank you so much.....

I appreciate it.

Your method is seriously easier for us who do understand the boolean operators....

but for those who do not understand the boolean mechanics they might find it to be problematic....

But anyway thanks a lot for discussing a short method of doing the same thing.

-Ashlesh