IPv4 addresses are 32-bit binary numbers which enable devices to communicate with each other using the TCP / IP protocol suite. click for more info A common scenario for two IP devices that communicate with each other will be your computer talking to an internet web server to view a web page stored on the web server. Each IP address consists of 4 bytes, each octet contains 8 bits and is thus a total of 32 bits. This article only applies to class C IP addresses, which are computer networking’s bread and butter.
This looks like an IP address: 192.168.1.126
The Binary numeral scheme uses 0 and 1, so that any bit in the address is either 0 or 1.
The address 192.168.1.126 written in binary appears as: 11000000.10101000.000001.011111110
Where do we get from 192.168.126 a 11000000.10101000.000001.011111110? It is pretty easy actually.
Here’s a table showing you the decimal value in an octet for every bit:
128 64 16 4 2 1 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2
Use this table as a guide we can say that:
The first bit in an octet valued 128
The second bit in an octet priced 64
The third bit in an octet priced 32
The fourth bit in an octet priced 16
In an octet the 5th bit is worth 8
For an octet the 6th bit is worth 4
In an octet the 7th bit is worth 2
For an octet the 8th bit is worth 1
Let’s use the first octet in the address 192.168.1.126 as an example (the first octet’s decimal value is 192), and we’ll convert it from decimal to binary. We look at the table to do so, to figure out which bits can add up to exactly 192 when put together.
By doing some basic maths, we realize that the 128 + 64 = 192 bits should be represented with a 1 and the remaining bits should be represented with a 0. This gives us the binary number of: 11000000
Let’s take another example, but this time with the second octet of the address 192.168.1.126. We know we need to add up a certain mix of bits to get 168. If we add together 128 and 32 and 8, we get 168, which means the bits corresponding to 128 and 32 and 8 are represented by a 1 and the remaining bits are represented by a 0. That provides us with the following binary number: 10101000
A last example, using the 192.168.1.126 address thrid octet. We need to get 1, we know the 8th bit has a value of 1, so all bits other than the 8th bit will be worth 0. This gives us binary number 00000001
Now you should understand the 192.168.1.126 to 11000000.10101000.00000001.011111110 relationship
You now have the framework needed to grasp the more advanced concepts of IP addressing. To understand how to subnet an IP address please read my Subnet Mask Tutorial.