2

I was reading Data Communication book by Forouzan in which there is a one restriction put on CIDR subnetting by Internet authorities:

First IP address in the block should be evenly divisible by the number of addresses. For example, below, the first address, when converted to a decimal number, is 3440387360, which when divided by 16 (block size) results in 215024210. enter image description here

Since this did not clear the practical significance behind this restriction I went on exploring and came across the video where it is explained as follows:

Whenever we divide any number by kth power of 2 (another restriction being that the block size should be 2^k), the reminder is least significant k bits. So evenly divisible by 2^k means that least significant k bits should all be 0. This way the first address of the allocated address block can be used as a block ID since it has all 0s in the host ID part.

Now that seems more logical despite the fact that I dont understand how

evenly divisible by the number of addresses 2^k

translates to

least significant k bits should all be 0

Can't it be just that the decimal equivalent of least significant k bits should be divisible by 2. I mean if least significant 4 bits (for a block of 2^4 addresses) is binary 1010, then it translates to decinal 10 which is divisible by 2.

So in short why is evenly divisible translates to all 0 LSBs?

2

This restriction on CIDR was created to forbid that an arbitrary block could be created, let's see an example:

Suppose that we have the full block 192.168.1.0 and we want to subnet it with /27

/27 means that from the 32 bits of the address, 27 are network, and 5 are host, then we have 2^5 addresess per subnet.

The subnets are:

First Address    Last Octet  Last Octet 
                             in decimal /32

192.168.1.0      000 00000       0
192.168.1.32     001 00000       1
192.168.1.64     010 00000       2
192.168.1.96     011 00000       3
192.168.1.128    100 00000       4
192.168.1.160    101 00000       5
192.168.1.192    110 00000       6
192.168.1.224    111 00000       7

The first address divided by the number of addresses per subnet is always an integer without decimals, and that is possible because the last k bits are 0.

It makes impossible to have a block starting on 192.168.1.133, for example, because 133/32= 4.15625

  • Nice... Now only thing I am confused about is why to use words: "evenly" divisible... What significance that "evenly" has. Do they mean to say wholly, not fractionally i.e. without leaving any decimal part in the quotient? – anir123 Jan 19 '17 at 5:21
  • 1
    @Mahesha999 Yes. I guess that when they say evenly they mean wholly. – jcbermu Jan 19 '17 at 9:26
1

I mean if least significant 4 bits (for a block of 2^4 addresses) is binary 1010, then it translates to decinal 10 which is divisible by 2.

Actually, 2^4 is decimal 16, hexadecimal 10, binary 10000, so the least significant four bits (the exponent in 2^4) are all 0.

Remember that an IP address is 32 bits, so a block of 2^4 host addresses is from a 32 bit number. This is how it would lay out, where N is a binary bit in the network portion of the address, and H is a binary bit in the host portion of the address:

NNNNNNN.NNNNNNNNN.NNNNNNNN.NNNNHHHH

What the book and video are trying to tell you is that increasing the number of host bits increases the number of hosts in that address block by a power of two. For every host bit in the address block, you double the number of hosts which you can have. The entire address block (call it the network or subnet) can then be referred to using only the network bits with the host bits all set to 0.

  • 2
    It always amazes me how textbook authors can take a relatively straightforward subject and complicate it into incomprehensibility ;) – Ron Trunk Oct 22 '15 at 14:42
  • I think, sadly, that is it because our nation is so math-phobic that most of the networking books try to teach around the math whenever possible, and they end up with complicated, confusing explanations. :( – Ron Maupin Oct 22 '15 at 14:46
  • 1
    And I was about to say, "It's just math, people" – Ricky Beam Oct 22 '15 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.