1

I always had this question. You can see that even cisco does that. Why not use a tree-like structure? Like so: enter image description here

Another example: http://www.davidc.net/sites/default/subnets/subnets.html

Of course it is possible to do it on paper in much cleaner way. Why no one has ever thought about that?

  • Where's the difference? – Zac67 Feb 15 '20 at 11:38
  • My teacher's way of doing it resembles something like this: http://www.kirkwood.edu/pdf/uploaded/569/ip_addressing_and_subnetting_workbook-student-v2.0.pdf. Only that his way is much worse. Imagine subnetting 10 levels deep how it would turn out on paper. Nevertheless, I encourage you to try the "tree way" on your own and you will understand. My question is just why is this the dominant way of doing subnetting and not something easier. – Chris Tzikas Feb 15 '20 at 12:04
  • This two-part answer goes into detail about why you must do it in binary, rather than decimal. – Ron Maupin Feb 15 '20 at 17:02

1 Answers1

3

Perhaps you're familiar with physicist Richard Feynman explaining why he can't explain magnetism in some other way:

"I can't explain that attraction in terms of anything else that's familiar to you. For example, if I said the magnets attract like as if they were connected by rubber bands, I would be cheating you. Because they're not connected by rubber bands ... and if you were curious enough, you'd ask me why rubber bands tend to pull back together again, and I would end up explaining that in terms of electrical forces, which are the very things that I'm trying to use the rubber bands to explain, so I have cheated very badly, you see." Richard Feynman BBC Video

The reason they are explained in binary terms is because they are actually done in binary: in the code where the host decides if two addresses are in the same network, there are bitwise boolean operators (AND, OR, NOT etc).

The operation of comparing two addresses to see if they're in the same network is typically only three machine instructions:

xor d1, d0   ; "bitwise not-equal" on two addresses
and d2, d0   ; keep network bits
beq doit     ; go if same

This is the reason why address calculations are done this way: it has to be very efficient because this is done several times for every packet in every router between hosts. At the time the internet protocols were designed, it wasn't obvious that this was a good idea, in contrast to the virtual circuits of X.25 etc.

It's perfectly practical for humans to do the arithmetic in binary, hex, or 4-digit base-256 numbers but most of us aren't very good at it. Any method that isn't done in a base which is a power-of-2 is adding complexity that doesn't really exist. The fundamental idea is that the operations are fantastically simple: absolutely as simple as the engineers could make them.

The method you describe is simply a way of explaining the binary operations. I promise you people have thought about these things in every way imaginable. If you helps you understand it, then great. Otherwise I recommend understanding it directly for what it is.

The canonical answer for network addressing and masks etc is How do you calculate the prefix, network, subnet, and host numbers?

PS. Those machine instructions are approximately equivalent to C if (!((addr1 ^ addr2) & mask)) { doit(); }

jonathanjo
  • 16,234
  • 2
  • 24
  • 54
  • I agree with the points you make. It's just that some professors make you do some outrageous subnets. Keeping them small is just fine (both ways). But when you have to deal with many nesting levels it just gets out of hand, like, I'm not a computer to deal with it. That is where trees really help. But after all, it is what it is I suppose. Thanks for the answer btw. – Chris Tzikas Feb 15 '20 at 12:32
  • You might see that the tree method is equivalent to the paper-halving method I describe in https://networkengineering.stackexchange.com/a/55146 – jonathanjo Feb 15 '20 at 12:34
  • Yes, thats the first alternative way I used for subnetting. But then I noticed trees are much more elegant. – Chris Tzikas Feb 15 '20 at 12:44