In this video, we’re going to be looking at Binary!
Ok so, in the last video, we looked at IP addresses. Now we’re going to take it up a notch.
Binary is how computers process data. It’s just a whole bunch of 1s and 0s.
You’ve likely seen or heard about binary, especially in those cheesy hacker or cybersecurity videos.
It can look intimidating at first, but don’t worry, it’s very simple.
An IPv4 address is 32 bits long. This means the address is made up of 32 binary digits. Each digit is called a bit.
The IP address contains 4 octets. Each octet contains 8 binary bits.
When we type in an IP address, the computer will convert that into binary. To fully understand how IP addresses work, we need to be able to do the same.
We’re going to just use one octet for our conversation, and then the same process is repeated for the rest of the IP address.
So here we have 8 binary bits. These bits can either be a 1 or a 0.
So how do we make numbers like 192 from 1’s and 0’s?
Well, each bit represents a value. That value doubles in size from right to left. This is called the power of 2.
Using this chart, we can see that each bit is assigned its own column. It’s important to know, that 1 means on, and 0 means off. This means we can turn columns on or off, just by adding either a 1 or a 0.
So let’s try it. All of our columns currently 0, which means they’re all off.
What value does 8 0s give us? We’ll, because all columns are off, there’s nothing to add up, so our value is 0.
If we turn on the 1 column by adding a 1, what value does that give us? It gives us 1.
If we put a 1 in the 2 columns, this gives us a value of 2.
Pretty straight forward so far right?
Ok this time, let’s turn on the 1 and 2 columns. What do we do here?
We need to add up all of the columns that have a 1 in it. So our value here would be 3.
Hopefully, that makes sense.
Let’s try one that’s a bit more difficult. Our binary value is 0 0 1 0 1 1 0 1
Again, we just need to add up all of our columns.
32 + 8 = 40
40 + 4 = 44
44 + 1 = 45
So 45 is our number.
Ok so now we’ve gone over the basics, let’s bring in an IP address and convert it to binary.
Remember, there are 8 bits in each octet so we are going to do this one at a time.
The first number in our IP address is 192. So this is the number we need to generate from our binary bits.
We always start with the highest value we can. In this case 128, so we put a 1 in that column. That leaves us with 64 remaining and that just happens to be the next column. So we add a 1 there as well. Our binary value for 192 is 1 1 00 00 00
The next number in our IP address is 54. Again, we start with the highest number possible. This time, that’s 32. That leaves us with 22, so we can add 16 as well. Then we have 6 left. We can get that by adding in the 4, and then the 2. So the binary value for 54 is 00 11 01 10
The next number is 103. We start at 64 because that is the highest we can use. Add a 32 in there, that gives us 96, so only 7 to go. We will add 4, 2 and 1. Meaning the answer is 01 10 01 11
And the last one to do is 29. So we need 16, 8, 4 and 1. Meaning our last binary value is 00 01 11 01
And we have now converted our IP address into binary.
Don’t worry though, this isn’t something you’ll need to do all the time.
But it is extremely important you understand how this works as we progress.
If you’re not great with maths, again don’t worry. The more you practice; you will start to memorize this. Without thinking, you will know that 128 + 64 = 192.
Subnet Masks Bits
IP addresses are split into a network section and a host section. The way we know which bit is which is with a subnet mask.
Our IP is a class C address so we should know that the default subnet mask is 255.255.255.0
The way to see which part of an IP address is the network section is by looking at the subnet mask bits. Anytime you see a 1 value, this bit is the network section. Anytime you see a 0 it’s the host section.
It may seem overkill with this example, but as we move on to subnetting, it’s extremely important you understand how this works.
Now, instead of the full subnet mask, you will often see it written as a forward slash and then the number of network bits. In this case, instead of 255.255.255.0, we could write it as /24.
Let’s take a closer look at our host section. You can see we have 8 bits.
Thinking back to our chart, how many host addresses can we have with 8 bits? We can have all 0s, all 1s or anything in between. 255 is the number we get if we add all columns together. This means we have a total of 256 possible combinations. That’s including 0.
There is a catch though, you cannot use the first or last IP address for a host. These are reserved. The first address (188.8.131.52) is the network address and the last address (184.108.40.206) is a broadcast address. So we only have 254 usable hosts.
So just remember, you cannot assign the first or the last address to a host.
OK, so that’s the basics of binary.
We will be using this a lot as we go. Especially when we move on to subnetting.