← Back Published on

IPv4 addresses and Binary numbers

When looking at an IPv4 address we need to learn what the numbers in it mean!

so…

Let's practice binary!

This is used with ipv4 addressing. Each number in the IP address is what's known as a “bit”, Ipv4 bits are binary numbers and A binary number is simply a 1 or 0 This is how computers store numbers

0 0 0 0 0 1 0 1 looks weird right?

When the computer is looking at an IP address, this is what it sees, a bunch of 1’s and 0,s. IP addresses run off a system known as a base 2 system. This means we multiply by 2!      Stay with me

Let's multiply by 2 starting with the number 1

1 2 4 8 16 32 64 128 simple right???  Now let's flip this around to make it easier for us to use

128 64 32 16 8 4 2 1 ok, so far so good. Now back to what I said earlier binary is either the number 1 or 0. Imagine 1 means yes and 0 means no, or even better, 1 means add and 0 means do not add!

Let me lay it out

128   64   32   16   8   4   2   1

 0       0     0     0    1    0   1   0

8 and 2 are on. Let's add them up. What does this give us?? 10! And 00001010 is the binary bite or also known as an octet

Here is a quick pic to explain what a bit vs bite is

If you remember the magic number of 128! You can remember this exercise every time. Let's try again. 

128 64 32 16 8 4 2 1

1 0 0 0 0 0 1 1

10000011 value gives us a decimal value of 131!

Ok, now two tougher ones!

128 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1   Yup 255 - the biggest number

Next-

128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 0 Weird right? But, all 0’s added up is simply 0 itself :)

Ok! The basics handle, let's reverse it.  

The decimal value is 43, Let’s convert this into a binary bite comprising of bits.

If I say I have a binary bit of 43 what sequence of 1’s and 0’s do I have? Let's lay it out

128 64 32 16 8 4 2 1

0 0 1 0 1 1 1 1

Yup 32+8+4+2+1 gives us 43

So the bite also known as the octet would be 00101111

Last one without the cheat sheet

254!

1 1 1 1 1 1 1 0

Alright! Binary calculations down. Now let's see the big picture

All these binary bits can represent an IP address. Specifically, an IPv4 address

IPv4 addresses are 32 bits in length and 4 bites or octets, Again each bite has 8 bits 8x4 is 32!

so, look at this long IPv4 address!   10000000 00000001 11111111 11111110

Ummmm what??? Using our last exercise, let's do it again! Except with each bite!

Big math time. 10000000=128 00000001=1 11111111=255 11111110=254

Put it all together and whala! 128.1.255.254. now that looks like an IP address!

See these dots? We have each decimal separated by dots. This is why it is called a dotted decimal value!

I need to emphasize tho, the “.” dots in this IP address is only for us- the human!

It is simply presented to us from the system for us to read easily and to break numbers down for us to read and split into bites.

So 128.1.255.254 is for the human to read and 1000000011111111111111110 is what the computer sees

The structure of an IP address is further broken down into 2 more components.  What does this mean?

The big creators of the internet wanted to have communications to different computers all over the world! So they said, let's make sure to add into the IP address the network position and the host position! So packets being sent know where to go!

To see this, lets start small Think of it as a new street!

Construction just finished and the physical street is the network!

We are either assigned a random IP or it is configured by important people for specific reasons. In this case, we are randomly given an IP address.

Let's pick house 101! Our friend Tom lives at this location

Tom's house give us a full IP address of 192.168.1.101

Tom's house is labeled 101! But what is the 192.168.1 before toms Host ID number?

It is the network ID! When the street was constructed, it was constructed with a random network ID. We can keep it or change it with configurations.

What do you see in this picture?

The IPv4 address of toms house

And the default gateway. Or router. Or mailman! He gets one also 🙂

Why is this important? If a host is trying to reach a specific IP, it needs to know what protocol to use and how to communicate depending on the location and distance of the delivery.

For example. If the NIC 'network interface card' sees that the packet is addressed to an IP address in a different network, it needs to send the packet to the router, known as the default gateway to send out that package to the desired location.

(we will cover network masks in another article)

So let's put it into an example again. Tom is at IP address 192.168.1.101 and is labeled above in the house.

If tom wants to send a postcard to Frank, 2 houses down, then he does so very easily. Tom and Frank are on the same network. No need to send the packet very far. Let's just send it over to Frank. In simple terms without explaining subnetting… what we can see is this

Sending ---> 192.168.1.101 and Receiving → 192.168.1.103

Now, if Tom wanted to send his postcard to Sandra across the city, He will have to give it to the mailman “the router” who will read the IP. From there, depending on its location of Sandra, the packet may go through several mailmen to get there. And eventually, it will get to Sandra. Sandra's network ID will be completely different than Tom’s and Franks tho.

This was a quick representation of what an IPv4 address is made of.

In a future article, we will go over subnet masks and how a subnet mask represents a network and the determination of a host ID

cheat sheet listed below! :)