Back to the Basics – Intro to Binary Conversions

by jmeredith88

The Basics

To develop a deep understanding of anything networking, you MUST understand the fundamentals. No matter how complex or simple the scenario might be, it all gets broken down into two numbers – 1s and 0s. That is correct. These two numbers are a tremendous part of your everyday life as a networking professional.

At the very top of the 7-Layer OSI model, data is simply data. While descending, encapsulation occurs, and at each respective layer data will also be known as: segmentspacketsframes, and finally: bits. Whether you are enjoying a video on YouTube, or sending an email, that data will eventually be broken down into bits, which have two values (you guessed it, 1 and 0). These numbers represent a current going through a circuit, and on/off switches.There is more to it than that, but, I want to focus on my next point:

Binary, Decimal and IPv4 Addresses

IPv4 addresses (you usually see them as simply IP addresses) are 32 bit addresses. They are actually broken down into 4 strings of 8 bits.

Example: xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx

 We know that there are only two representations of bits (1 & 0), so how does this translate into an address such as 192.168.0.1? First, lets break each binary string down in representation to its decimal counterpart:

xxxxxxxx (192) / xxxxxxxx (168) / xxxxxxxx (0) / xxxxxxxx (1)

There is no complex algorithm required to do a conversion. If you can take the number “1” and double it 7 times, you are halfway there. We take the number 1 and put it at the very end of the binary string, and double it, while working our way to the left – we come up with:

128-64-32-16-8-4-2-1

Remember how we mentioned those “on/off switches” – we are about to put those in use

Lets go back to “192” – we start at the left of the 128-64-32-16-8-4-2-1 reference string. Take a look at the first number, 128, and ask yourself: Can 128 be subtracted from 192? The answer is yes. This leaves us to do two things. Put a 1 as the first value of the binary string, and subtract 128 from 192…this is what we are left with:

1xxxxxx and 64

Now we move on to the 2nd number in the 128-64-32-16-8-4-2-1 reference string, which is 64. Now ask yourself: Can 64 be subtracted from 64? The answer is yes, and that leaves us with a remainder of 0, and another 1 in the binary string:

11xxxxxx and 0

As you move through the rest of the line, you ask yourself if 32, 16, 8, 4, 2 or 1 can be subtracted from 0. The answer is no, so we use the off markers (0) for the rest of the string.

192 translates into 11000000.

So far so good! Let’s move on to the second 8-bit binary string of 192.168.0.1

Can 128 be subtracted from 168? The answer is yes. That leaves us with:

1xxxxxxx and remainder of 40

Can 64 be subtracted from 40? No, so we put a 0 in the next value and are still left with “40”

10xxxxxx and remainder of 40

Can 32 be subtracted from 40? Yes, so we put a 1 in the next value and are left with 8

101xxxxx and remainder of 8

Can 16 be subtracted from 8? No, we put a 0 in the next value and are still left with 8

1010xxxx

Can 8 be subtracted from 8? Yes, we put a 1 in the next value and are left with a remainder of “0”. Anytime you are doing a conversion and are left with 0, it is safe to assume that all following values with be “0”

10101000 168

192.168.0.1 converts to (in binary) 11000000.10101000.00000000.00000001

Conclusion

Binary conversions are an integral part of sub-networking. Whether this is new information, or just a refresher, understand that learning and mastering the basics will allow you to advance your knowledge. Practicing 5-10 minutes a day will enable you to perform much better in the field, and also on exam day.

I leave you with 10 practice conversions; convert the following numbers into binary strings and post the answers in the comments: 255, 148, 7, 202, 127, 84, 30, 14, 188, 102