Converting Decimal IP Addresses to Binary


Converting Binary IP Addresses to Decimal

Routers, being computers, work in binary. For example, 32-bit IPv4 addresses are used throughout the Internet, so you need to understand how to work with IP addresses. Because people usually like to work in decimal, IP addresses are typically written in a format called dotted decimal notation. The 32 bits in the address are divided into four 8-bit chunksthese chunks are called octets. Each octet is converted into decimal and then separated by dots.

When converting a binary octet to decimal, each binary digit is weighted based on its position, as described earlier. The weights for the eight bit positions in an octet are shown in Figure C-2.

Figure C-2. Binary Digits Are Weighted Based on Their Position


For example, consider the following IP address, written in binary:

10101100000100001000001100001100

Follow these steps to write this binary address in dotted decimal notation:

Step 1.

Divide the 32 bits into four octets, as follows:

10101100 00010000 10000011 00001100

Step 2.

Convert the first octet into decimal, as illustrated in Figure C-3.

Figure C-3. Converting an Octet from Binary to Decimal


Note the following points in Figure C-3:

  • The least significant digit, 0, has a weight of 20; thus, it represents 0 * 20 = 0 * 1 = 0.

  • The next digit, also 0, has a weight of 21; thus, it represents 0 x* 21 = 0 * 2 = 0.

  • The next digit, 1, has a weight of 22; thus, it represents 1 * 22 = 1 * 4 = 4. The weighted value for each of the other digits is calculated in the same way.

  • The most significant digit (on the far left), 1, has a weight of 27; thus, it represents 1 * 27 = 1 * 128 = 128.

  • Therefore, the binary number 10101100 in decimal is the sum of each of these representations: 128 + 0 + 32 + 0 + 8 + 4 + 0 + 0 = 172.

Step 3.

Repeat this process for the other three octets. The results are as follows:

  • 00010000 binary equals 16 decimal.

  • 10000011 binary equals 131 decimal.

  • 00001100 binary equals 12 decimal.

Note

You can confirm these results using the decimal-to-binary conversion chart in Table C-1.


Thus, the IP address 10101100000100001000001100001100 in dotted decimal notation is 172.16.131.12.




Campus Network Design Fundamentals
Campus Network Design Fundamentals
ISBN: 1587052229
EAN: 2147483647
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net