Jump to content
  • entries
    9
  • comments
    3
  • views
    2,861

The conversion of IP addresses (Decimal) and Binary

BSpendlove

3,993 views

This is a revision of a previous blog I posted on my website with better examples and hopefully more depth into the world of binary for IP addresses and Subnetting. I will not explain how to subnet in this article but will explain why you might need to know how to convert binary to decimal (vice versa) and why it is useful.

 

Let's dive straight into the deep end.

 

Binary

 

Binary can be represented as either 1 or 0 (On or Off). We will be using the 'on/off' terms to make it easier to understand how to get the decimal value from our binary expression.

 

An IPv4 Address is constructed from 32 individual binary bits which are split in 8 bit 'sections' also know as octets. (1 octet actually equals 1 byte!) Here is an example:

 

192.168.0.1

 

Now you might feel like this isn't so daunting, an address that we are all familiar that is most probably the most commonly assigned IP address to a home router or the first device in our home network. Well, we can explore this IP address in the binary world.

 

The conversion for this IP address is 11000000.10101000.00000000.00000001. You will explore a method used to get this result although right now, we will focus on the structure of this binary format.

 

A little fact is that an IPv6 address is actually created from 128 bits but normally represented in Heaxdecimal format (0-9, A-F = total of 16 values - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)

 

Structure

 

Representing the above binary result in our '8 bit' or '4 octet'.

 

8bits.8bits.8bits.8bits (32 bits in total)

octet.octet.octet.octet

 

When beginning to learn the conversion, starters will want to proceed to memorize a table and even have a similar table available on screen or a piece of paper to help with the process.

 

 

 
de28d7_72fc9f5ab1ea40dea2416523e3d613cb~

 

 

Our process to convert our IP address to binary (and vice versa) will start by using this table on each octet (each 8 bits) and then follow with the second, third and finally fourth.

 

In our 8 bits, the bit on our right is our 'least significant bit' and on the right our 'most significant bit'. Don't get caught up too much with the maths expression until we dive deeper into the more subnetting section which will come in a later article.

 

A binary representation of 255 is: 11111111 (We have to add all the decimal values for each bit that is 'on' (1) which adds to 255)

 

If we were to work out 11111110 in decimal value (We would follow the rule to only to add the decimal values of the corresponding binary value that is 'on' or equal to 1)

 

 

 
de28d7_d24ebad9b6b44fdd9f11d797e6a09fae~

 

 So in the table above, we will only add the binary values equal to 'on' (1) which will result of the decimal number of 254. It would make sense now to try and work out our first octet of 192.168.0.1

 

 

 
de28d7_b98e0c7c71c449f6a1526d6d02814b2d~

 

 As the same concept applies, adding our binary values that are only equal to 'on' (1) will result in a decimal number of 192. (128+64 = 192)

 

 

 
de28d7_3f247b8fb1b442bfb37e47971c0172cc~

 

 

 128 + 32 + 8 = 168

 

 

 
de28d7_ce5275a4672048ecaf5c5be8cc5b8a48~

 

 00000000 in Binary is 0 in decimal....

 

 

 
de28d7_e081c5b283924014b305d87839b0a31c~

 

 Remember that we only add our values when the corresponding binary value is 'on' (equal to 1)

 

 

192.168.0.1

 

So, if we use our 4 tables above that were used to convert our decimal to binary, we will find that this 192.168.0.1 address represented in Binary is:

 

11000000.10101000.00000000.00000001

 

 

Ok that is cool I guess? Although I guess we don't really need to know this since the whole point of the hardware is to automatically do this, and IP addresses are a more friendly way for us humans to use... You are certainly correct, to a degree.

 

A single IP address on its own doesn't really mean much to Network Engineers and such. This is where a subnet mask comes in.

 

Subnet Mask

 

Do you really need to read on? You have already figured out how to convert Decimal to Binary (and vice versa if you just apply it in reverse) but this the part where I explain why learning this can be important in specific job roles and such.

 

Now a subnet mask is not to be confused with 'Subnets' or 'Masking an IP address' or even a robber mask. To simplify a subnet mask, it is an address used to describe the following information about a single IP address:

 

Which part of the IP address is the Network ID

Which part of the IP address is used for the Host ID (assigning IP's to devices)

 

If you want to carry on into depth with subnetting,subnet masks and using Binary/Decimal conversions into a bit more depth then feel free to suggest and comment if you would like me to create an article. I plan to create one but not soon!

 

 

 

 

Practising and Questions

 

Using your own table or a similar table as shown in the above demonstrations, work out the following:

 

Convert the following from Decimal to Binary:

 

192.168.10.210

172.16.34.255

10.32.47.100

192.168.43.77

 

Convert the following from Binary to Decimal:

 

11000000.10101000.01000001.00010101

00001010.00100001.00010001.10000011

10110001.11001010.11110000.00101111

 

  • How many bits in an Octet?

  • What information does a Subnet masks provide??

  • How many total bits are in an IPv4 Address?

  • How many total bits are in an IPv6 Address?

 

Convert these binary values and describe where you would commonly find the decimal representation

(10000000, 11000000, 11100000, 11110000, 11111000, 11111100, 11111110, 11111111)

0 Comments

There are no comments to display.

×