A CIDR Example
-------------------------- One Example
Suppose a router has the following entries in its forwarding
table:

0.0.0.0/0	X
192.168.128/17	Y
192.168.128/18	Z

Where do the following datagrams get forwarded?

(a) 192.168.130.14
(b) 192.168.193.47
(c) 192.168.127.64

First, all the datagrams match X, so unless a destination matches
a more specific address, it will be sent on X. So, we're looking
for a more specific match. A more specific match will have a
longer CIDR mask (more significant digits).

All three datagram are the same through the first two bytes. So,
maybe they match Y or Z. Let's look at the third byte of each:

(a) 130 = 128 + 2 = 10000010 binary. To 17 significant bits, it
matches Y, since both have a 1 in the 17th bit from the
left. However, it also matches Z, since both have 10 in the 17th
and 18th bits.

Since Z is the more specific match--matching a longer mask--Z is
the choice.


(b) 193 = 128 + 64 + 1 = 11000001 binary. This does *not* match Z,
since (b) has 11 at the top of the 3rd byte, whereas Z has 10. But
since the third byte of each (B) and (Y) start with 1, and that's
the last bit we care about for Y, (b) matches Y.


(c) 127 = 128 - 1 = 10000000 - 1 binary = 01111111 binary. This
doesn't match Y or Z, so X is the choice.



------------------------------A second example

Toadnet in Severna Park has been allocated the following block of
IPv4 addresses:

NetRange:   162.33.128.0 - 162.33.159.255 
CIDR:       162.33.128.0/19 

Are these consistent? 

The /19 indicates that the network portion of the address block
is the first two bytes plus three bits of the third byte. So all
addresses in the block will start with 162.33.  In the third byte,
the top three bits have to be 100.  So, the bottom 5 bits will
range from zero to 11111, which is 100000-1, which is 2^6 - 1,
which is 31.  So the range of possible values for the third byte
is 128+0 through 128+31, or 128 through 159.

So, yes, both the "NetRange" and the "CIDR" refer to the same
block of addresses.

From here one can go
, Jeff Martens