Monday, January 26, 2015

Basic IP Address Calculating

There are four octets in IPv4. Each octet has 8 bits. So, IPv4 is totally 32bits. IPv4 addresses are based on the binary and decimal. Binary is 0 to 1 and decimal is 0 to 9. When all bits are "1"

IPV4   ->   32 bits
                 1st Octet       2nd Octet      3rd Octet      4th Octet
                11111111  .  11111111  .  11111111  .  11111111
                     8 bits            8 bits           8 bits          8 bits
                      255    .         255    .       255      .      255

When all bits are "0"

               00000000  .   00000000   .  00000000   .   00000000
                      0       .           0       .         0         .        0

Sometimes, some bits are "0" and some bits are "1" in the same octet. For example, lets see the ip address 192.168.1.0.

(If we will calculate the Ip addresses, we better write down the following formula.)

  27        26         25        24         23        22      21     20   
128      64       32      16        8        4       2      1
                                                                       

192.168.1.0   

128  64  32  16  8  4  2  1 . 128  64  32  16   8   4   2  1  . 128  64  32  16  8 4  2  1  .  0
 1   1    0    0   0  0  0  0   .  1    0    1    0   1   0   0  0  .   0     0    0    0   0  0  0 1 . 00000000

11000000.10101000. 00000001.00000000


Now, lets try to change the following binary to decimal !

01110000.11000000.00011001.0

0      1     1    1   0   0   0   0  .   1  1  0  0  0  0  0  0  .  0  0  0  1  1  0  0  1 . 00000000
128  64   32  16  8   4   2   1
               
            112                         .             192                 .              25             .       0

112.192.25.0