why AND-ing? - TCP-IP

This is a discussion on why AND-ing? - TCP-IP ; I find AND-ing a confusing concept in subnetting and I was wondering if it's necessary or not. To find the subnet where a host address lives on, we simply turn off all host bits and find the subnets as multiple ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: why AND-ing?

  1. why AND-ing?

    I find AND-ing a confusing concept in subnetting and I was wondering if it's
    necessary or not. To find the subnet where a host address lives on, we
    simply turn off all host bits and find the subnets as multiple of last
    subnet bit. The subnet where our host lives on is the subnet where the host
    range includes our host, right?

    Example: Host address 10.17.2.14/18
    Class A, so turning off all hosts bits will give us the subnets as multiple
    of 64. That is, 10.17.0.0; 10.17.64.0 etc.
    Since in 10.17.2.14 number 2 is in the range of the subnet 0 (0 to 64) then
    the answer is: Our host lives on subnet 0: 10.17.0.0

    new guy




  2. Re: why AND-ing?

    In article , "new guy" guy@now.anonymous> writes:
    > I find AND-ing a confusing concept in subnetting and I was wondering if it's
    > necessary or not. To find the subnet where a host address lives on, we
    > simply turn off all host bits and find the subnets as multiple of last
    > subnet bit. The subnet where our host lives on is the subnet where the host
    > range includes our host, right?


    Yes. To find the subnet our host lives on, you round the host address
    down to the next lower subnet boundary.

    > Example: Host address 10.17.2.14/18
    > Class A, so turning off all hosts bits will give us the subnets as multiple
    > of 64. That is, 10.17.0.0; 10.17.64.0 etc.
    > Since in 10.17.2.14 number 2 is in the range of the subnet 0 (0 to 64) then
    > the answer is: Our host lives on subnet 0: 10.17.0.0


    You choose to do this by iterating through the subnet boundaries with
    repeated addition and comparing at each step to the target host address.

    A computer does this with a logical AND.

    Personally, I use a mental lookup table together with some ad hoc
    simplification rules. ["18 is two narrower than 16, so we're talking
    about 1/4 of a 'B', that puts the boundaries at 0, 64, 128 and 192,
    and the relevant octet is the third one. Our host is at 2, so the net
    is at 0, making the net address 10.17.0.0"].

    Someone else may whip out a calculator, divide by the subnet size,
    truncate to an integer and multiply by the subnet size.

    Another person may browse to a web page with a subnet calculator.


    They're all equivalent techniques and yield the same result.


    If your approach is easy for you to use, understand and rely upon
    then it is the right approach for you.

  3. Re: why AND-ing?

    In article ,
    "new guy" guy@now.anonymous> wrote:

    > I find AND-ing a confusing concept in subnetting and I was wondering if it's
    > necessary or not. To find the subnet where a host address lives on, we
    > simply turn off all host bits and find the subnets as multiple of last
    > subnet bit. The subnet where our host lives on is the subnet where the host
    > range includes our host, right?
    >
    > Example: Host address 10.17.2.14/18
    > Class A, so turning off all hosts bits will give us the subnets as multiple
    > of 64. That is, 10.17.0.0; 10.17.64.0 etc.
    > Since in 10.17.2.14 number 2 is in the range of the subnet 0 (0 to 64) then
    > the answer is: Our host lives on subnet 0: 10.17.0.0
    >
    > new guy


    ANDing is used because the original subnetting specification used a bit
    mask, not a prefix length. So a subnet mask could be 255.0.252.64,
    meaning that the subnet consisted of bits 0-7, 16-21, and 25. As a
    result, a subnet would not necessarily have a contiguous range of
    addresses, and they aren't just simple multiples.

    Over time we realized that this generality was not useful, and CIDR,
    variable-length subnetting, and aggregation depend on the simpler notion
    of prefix lengths rather than subnet masks. But the underlying
    implementations still make heavy use of ANDing, both for backward
    compatibility and because it's an easier operation for computers to
    perform.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  4. Re: why AND-ing?


    "Barry Margolin" wrote in message
    news:barmar-F2A9A6.20295305062006@comcast.dca.giganews.com...
    > In article ,
    > "new guy" guy@now.anonymous> wrote:
    >
    >> I find AND-ing a confusing concept in subnetting and I was wondering if
    >> it's
    >> necessary or not. To find the subnet where a host address lives on, we
    >> simply turn off all host bits and find the subnets as multiple of last
    >> subnet bit. The subnet where our host lives on is the subnet where the
    >> host
    >> range includes our host, right?
    >>
    >> Example: Host address 10.17.2.14/18
    >> Class A, so turning off all hosts bits will give us the subnets as
    >> multiple
    >> of 64. That is, 10.17.0.0; 10.17.64.0 etc.
    >> Since in 10.17.2.14 number 2 is in the range of the subnet 0 (0 to 64)
    >> then
    >> the answer is: Our host lives on subnet 0: 10.17.0.0
    >>
    >> new guy

    >
    > ANDing is used because the original subnetting specification used a bit
    > mask, not a prefix length. So a subnet mask could be 255.0.252.64,
    > meaning that the subnet consisted of bits 0-7, 16-21, and 25. As a
    > result, a subnet would not necessarily have a contiguous range of
    > addresses, and they aren't just simple multiples.
    >
    > Over time we realized that this generality was not useful, and CIDR,
    > variable-length subnetting, and aggregation depend on the simpler notion
    > of prefix lengths rather than subnet masks. But the underlying
    > implementations still make heavy use of ANDing, both for backward
    > compatibility and because it's an easier operation for computers to
    > perform.


    Computers do not understand subnetting



  5. Re: why AND-ing?


    Barry Margolin wrote:
    > In article ,
    > "new guy" guy@now.anonymous> wrote:
    >
    > > I find AND-ing a confusing concept in subnetting and I was wondering if it's
    > > necessary or not. To find the subnet where a host address lives on, we
    > > simply turn off all host bits and find the subnets as multiple of last
    > > subnet bit. The subnet where our host lives on is the subnet where the host
    > > range includes our host, right?
    > >
    > > Example: Host address 10.17.2.14/18
    > > Class A, so turning off all hosts bits will give us the subnets as multiple
    > > of 64. That is, 10.17.0.0; 10.17.64.0 etc.
    > > Since in 10.17.2.14 number 2 is in the range of the subnet 0 (0 to 64) then
    > > the answer is: Our host lives on subnet 0: 10.17.0.0
    > >
    > > new guy

    >
    > ANDing is used because the original subnetting specification used a bit
    > mask, not a prefix length. So a subnet mask could be 255.0.252.64,
    > meaning that the subnet consisted of bits 0-7, 16-21, and 25. As a
    > result, a subnet would not necessarily have a contiguous range of
    > addresses, and they aren't just simple multiples.
    >
    > Over time we realized that this generality was not useful, and CIDR,
    > variable-length subnetting, and aggregation depend on the simpler notion
    > of prefix lengths rather than subnet masks. But the underlying
    > implementations still make heavy use of ANDing, both for backward
    > compatibility and because it's an easier operation for computers to
    > perform.
    >
    > --
    > Barry Margolin, barmar@alum.mit.edu


    what's the alternative to ANDing?

    did you have in mind Right Shift k times and test if equal. ?


  6. Re: why AND-ing?

    In article <1150454067.336232.198160@g10g2000cwb.googlegroups. com>,
    q_q_anonymous@yahoo.co.uk wrote:

    >Barry Margolin wrote:


    >> ANDing is used because the original subnetting specification used a bit
    >> mask, not a prefix length.


    >> Over time we realized that this generality was not useful, and CIDR,
    >> variable-length subnetting, and aggregation depend on the simpler notion
    >> of prefix lengths rather than subnet masks. But the underlying
    >> implementations still make heavy use of ANDing, both for backward
    >> compatibility and because it's an easier operation for computers to
    >> perform.


    >what's the alternative to ANDing?


    >did you have in mind Right Shift k times and test if equal. ?


    A number of architectures support direct bitfield examination
    and manipulation -- sometimes only of 1 bit, and sometimes
    of multiple consequative bits.

    It is true, though, that on a number of architectures that support
    setting bits, that the internal implementation is to read an
    entire unit, manipulate the bits (perhaps using a mask...),
    and then write out the entire unit again.

    [The size of the unit depends upon the architecture -- there are
    architectures that do all byte-level (well, octet-level) operations in
    this manner, that turning out to be less complex (and so cheaper) than
    writing a complete set of byte-level instruction microcodes. e.g., if
    the processor pipelines, the extra overhead of being able to pipeline
    bytes instead of words could end up slowing down everything, so
    Yes, handing bytes internally as words can end up being faster
    than keeping their byte-identity distinct in the internals
    of the processor.]

+ Reply to Thread