Wednesday, June 29, 2011

what is the first usable host of the IP address

This is a post I did on about subnetting. I wanted it here for reference.

You've got two way to look at it 0., Binary and 1., Magic. <-- see that binary humor?!?

Ok, your question is
what is the first usable host of the IP address

we'll look at 3 different kinds of bits,
N=network bits
S = subnet bits
H= host bits is a class C address which means the first 3 of the 4 sets of 8 bit blocks called octets, are N blocks (Class A = first octet, class B = first two octets, class C = first three octets - are network). like:

thats says the 212.46.165 is the network portion of the address. So the rest is devided up into S bits and H bits. Lets look at that CIDR number again, /25. So the first 3 blocks, our network blocks are /24 (count the Ns in the above class C example). That means we have 1 extra bit to be placed in our network bits, but its beyond the class C first 3 blocks so it ends up being a subnet bit like so
nnnnnnnn.nnnnnnnn.nnnnnnnn.s <--/25 where /24 is the n bits and /1 is the subnet bit

The rest of our bits are then host bits. So IPv4 is a total of 32 bits. We have 24 N bits, 1 S bit, and that leaves us with 7 bits. Those last bits are then H bits which makes the IP effectively look like this:

We can then take those H bits and drop them into the equation
2^H= number of hosts per subnet (we can also do 2^s but well save that for later)

We have 7 H bits which gives us, 2^7 = 128

So for each subnet in the address there is 128 hosts. So lets count by 128s <-- first subnet <-- second (and last) subnet

For usable hosts, we need to take out the broadcast and network address' (first and last address) <--network address <-- first usable host <-- last usable host <-- broadcast

Whew! On to magic!
Again, we look at the CIDR notation /25. If we count up the first 3 octects are 24 bits which means /25 lands us at the first bit in the 4th octet.
----------------------------- ^
first bit last octet

So that 1st bit in the last octet, that points to our magic number. If we look at an octet, its powers of 2,

128 64 32 16 8 4 2 1

if we take that 1 bit left over (25-24=1) then we can drop that bit in the first place on the left side, the 128th place.

128 64 32 16 8 4 2 1

So that left over 1 is telling us that the magic number is 128. So, to figure the subnets we count by 128.
0 128
In our questioned address, it would look like so, <--subnet 1 <-- subnet 2 -- it stops here (because 2^8=256 thus an octet can only handle 256).

So the address falls into the host range -

But as you know, we need to take out the broadcast and subnet addresses in order to get our usable hosts, thus the usable host range is -

Great subnetting by binary (and IPv6) lecture here. Also, great practice here.

No comments:

Post a Comment