Wednesday, 28 December 2011

Converting IPv4 addresses into Binary (Hard)

What is Binary?


Binary is the language that the computer speaks in and it consists of zero's and one's e.g. 110100101101.



Without a protocol, these numbers would mean nothing. You need to tell the computer how to read the numbers e.g. 1010101111010 could mean nothing if the computer read it as text but a butterfly if read as a picture.





Converting Binary into an IP4 and vise versa.

A IP4 address is made up of 32 bits (4 bytes) and consists of 4 sets of numbers that are 8 bits each (one digit is one bit - 11010010 = 8 bits/1 byte).

An IP address = 192.168.1.1 which would look something like 11001100.10100101.01101010.00101101 in binary.

The biggest IP address you can get is 255.255.255.255

To convert an IP into binary, you simply use the 8 numbers below to add up to the byte you want to convert.

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

e.g.

 192.168.1.1

192.

128 goes into 192, so we put a 1. We are now left with 64.
then we go to the next number along which is a 64.
64 - 64 = 0 so we put a 1.
We have now reached 192 by adding the first 2 numbers together.
Our conversion should look like this - 11000000.

11000000 = 192.

128.64.32.16.8.4.2.1
1     1   0   0   0 0 0 0

And to convert it back you do the reverse.

This is quite hard to understand, especially because i am writing it down.

As always, if you have any questions please comment and i will answer you.


6 comments:

  1. Quite complicated, could you explain what's the point of this ?

    ReplyDelete
  2. 01000011011011110110111101101100001000000110001001101100011011110110011100100001

    ReplyDelete
  3. had to do this at school. I hate it !
    Why don't just let how it is :D

    ReplyDelete
  4. 128 goes into 192, what??

    ReplyDelete
  5. This is to show how a computer would read an IP address.

    128 goes into 192 so you are left with 64. 64 is the next number along that you have to minus from until you get 0. 128 goes into 192 (= 10000000), 64 goes into 64 leaving 0 so the binary conversion of 192 is 11000000

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete