Sei sulla pagina 1di 12

1.

The first, and probably most important step, is to put down this row of values:

128

64

32

16

8 4 2 1

2. In order to remember these values start with the number 1, go from right to left, and double that number seven times. For example, start with 1 on the right side. For your next number, double the 1 (1 x 2 = 2). So, 2 is your next number (remembering to go from right to left). For your third number, double the 2 (2 x 2 = 4); to continue the sequence, double the 4 (4 x 2 = 8). Repeat this process until youve doubled your original number, seven times. The key to this is that every single one of the values we put in that row are going to have either number 1 or number 0 assigned to it. To convert the IP address we will take that string of numbers and start from left to right this time. For each value we ask this question: Can I subtract this value from the decimal remaining? If the answer is NO then you put a 0 under the binary value, and if the answer is YES then you put 1 there. 3. We take the IP address: 154.31.16.13 and start with the first part, which is 154.

a. Question: Can I subtract 128 from 154? Answer: YES. So we assign 1 to 128.

128 1

64

32

16

8 4 2 1

b. Question: Can I subtract 64 from 26? Answer: NO. So we assign 0 to 64.

128 1

64 0

32

16

8 4 2 1

c. Question: Can I subtract 32 from 26? Answer: NO. So we assign 0 to 32.

128 1

64 0

32 0

16

8 4 2 1

d. Question: Can I subtract 16 from 26? Answer: YES. So we assign 1 to 16.

128 1

64 0

32 0

16 1

8 4 2 1

e. That will give us a remainder of 10. (26-16=10). Question: Can I subtract 8 from 10? Answer: YES. So we assign 1 to 8.

128 1

64 0

32 0

16 1

8 4 2 1 1

f. That will give us a remainder of 2. (10-8=2). Question: Can I subtract 4 from 2? Answer: NO. So we assign 0 to 4.

128 1

64 0

32 0

16 1

8 4 2 1 1 0

g. Question: can I subtract 2 from 2? Answer: YES. So we assign 1 to 2.

128 1

64 0

32 0

16 1

8 4 2 1 1 0 1

h. That will give us a remainder of 0. So for the rest of the values in our row, we can assign 0.

128 1

64 0

32 0

16 1

8 4 2 1 1 0 1 0

i. So now we know that a decimal number 154 is 10011010 converted to binary form. To double check, we take the values assigned with 1 and add them together: 128+16+8+2=154
4. Our next number in the IP address is: 31. So we start with a question from step 2 again

a. Can I subtract 128 from 31?

128 0

64

32

16

8 4 2 1

b. Can I subtract 64 from 31?

128 0

64 0

32

16

8 4 2 1

c. Can I subtract 32 from 31?

128 0

64 0

32 0

16

8 4 2 1

d. Can I subtract 16 from 31?

128 0

64 0

32 0

16 1

8 4 2 1

e. Can I subtract 8 from 15 (remember, its the remainder)?

128 0

64 0

32 0

16 1

8 4 2 1 1

f. Can I subtract 4 from 7?

128 0

64 0

32 0

16 1

8 4 2 1 1 1

g. Can I subtract 2 from 3?

128 0

64 0

32 0

16 1

8 4 2 1 1 1 1

h. Can I subtract 1 from 1?

128 0

64 0

32 0

16 1

8 4 2 1 1 1 1 1

i. So the decimal number 31 is 00011111 converted to binary form. To double check: 16+8+4+2+1=31
5. Next number is 16. I will perform the conversion in one step now.

128 0

64 0

32 0

16 1

8 4 2 1 0 0 0 0

6. So the decimal number 16 is 00010000 converted to binary form. 7. Next number is 13.

128 0

64 0

32 0

16 0

8 4 2 1 1 1 0 1

8. So the decimal number 13 is 00001101 in binary form. To double check: 8+4+1=13

So the IP address of 154.31.16.13 has its binary form equivalent of:


FREE TOOL >> VM-to-Cloud Calculator - What Would It Cost To Move Your Virtual Machines To The Cloud?

Binary-to-decimal conversion
To be a network engineer (especially a CCNA), you need to understand binary so that you can understand how a network device uses its IP address, subnet mask, and default gateway information. You also need to be able to convert from binary to decimal and from decimal to binary. What is binary and how can it help you as a network engineer? Lets find out

Binary-to-decimal conversion
The following article was originally published on SearchNetworking.com To be a network engineer, you need to understand binary so that you can understand how a network device uses its IP address, subnet mask, and default gateway information. You also need to be able to convert from binary to decimal and from decimal to binary.

What is binary?
Binary is a numbering system that uses only the digits 1 and 0. We are accustomed to using the decimal number system, which uses the digits 0 through 9. Binary is the numbering system that network devices use to process all data. Without binary, computers and networks would not function. All data sent across a network is in binary. Just like we use the decimal numbering system (numbers 0 through 9) for all counting, money, and financial transactions, computers use binary for storage of all data, all data transmissions, and all numerical calculations. You can think of this as a language. For example, all people in Russia use Russian for all communication. If someone in Russia talked to someone in the United States, they would probably talk in English so that we could understand and communicate. That person would be bilingual because they understand two languages. In that sense, you could compare the computer to them because the computer understands two numbering systems, binary and decimal. Humans dont want to have to think or do calculations in binary. We want to convert those binary numbers to decimal. Converting from binary to decimal is not difficult. The numbers 0 and 1 in binary are converted to 0 and 1 in decimal. After that, it gets a little more complicated.

Here is an example of counting from zero to ten using binary:

Decimal Binary 0 0

10

11

100

101

110

111

1000

1001

10

1010

All binary to decimal or decimal to binary conversions use this chart:

27

26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

Lets discuss how to use this chart. First, always start by looking at the chart from right to left,not from left to right. Second, all the numbers on the chart stay where they are you dont change these. These numbers are used to tell you the values of the binary digits you will enter in the blanks. Finally, the top line of 2x numbers tells you what each column represents. The column on the far right is worth 20. The second line, with the decimal numbers, tells you what the answer is to the 20 line. So, if you look at the column on the far right, second line, it tells you that 20 is equal to 1 IF there is a 1 in the blank below it. If you had a one in the fourth column from the right, 23, you would have a value of 8 turned ON. Anywhere that you do not have a 1 in the bottom line, you will fill in with a zero. Think of each of these columns being able to be turned ON and OFF by using a 1 or a 0, respectively. When you are done filling in your 1s and 0s on the bottom line of the chart, you can add all the values that you turned ON, in decimal, from left to right (using the second line of the chart). Thus, if you had put a 1 in the 23 column (8) and a 1 in the 20 column (1), you would add 8 + 1 = 9. That 9 is represented by 1001. These numbers are calculated using this table:

27

26 25 24 23 22 21 4 2

2
0

128 64 32 16

1 =9

1 0 0 1 = 1001

Lets look at another example If you look at the number 3, it was calculated by having a 1 in the 20 place and a 2 in the 21 place (starting on the right-hand side of the table). If you add the 1 that you get from the 20 place and the 2 that you get from the 21 place, you get 3. In other words, 1 + 2 = 3. Lets look at another one. The 1000 in binary represents 8 in decimal because you have a 1 in the 23 place and that gives you 8. You have 0s in all the other places.

IP addressing and binary


The three critical pieces of information that you, the network administrator, provide or a DHCP server provides to network devices (computer, server, router, switch, etc.) are:

IP Address

Subnet mask Default Gateway

The network device immediately converts this information into binary. So, lets pretend that we are that network device and we are given the following information:

IP Address = 1.1.1.1 Subnet Mask = 255.255.255.0 Default Gateway = 1.1.1.254

The computer converts this information into binary and calculates the Network ID. Before we can calculate the Network ID, we first have to convert from decimal to binary.

Converting decimal to binary


Lets start with converting the IP address to binary. To convert 1.1.1.1 to binary, you take the octets (the numbers between the decimals) one at a time, like this: 1 decimal = 1 binary 1 decimal = 1 binary 1 decimal = 1 binary 1 decimal = 1 binary An IP address is 32 bits in binary, so each octet is 8 bits in binary. Because of this, we need to pad the other bits as 0s. That means that 1.1.1.1 in decimal equals the following number in binary: 00000001 00000001 00000001 00000001 That was easy! To convert the subnet mask of 255.255.255.0, take each octet one at a time, using the table:

27

26 25 24 23 22 21 20

128 64 32 16 8 4 2 1
Here is what I get: 255 = 11111111 To do this, I looked at the bottom row of numbers that each binary space represents. I started with 27, which equals 128. So, how many 128s are in 255? The answer is 1. So I write: 255 128 = 127 Now, how many 64s (the next binary space) are in 127? The answer is 1, so I write: 127 64 = 63

And so on, like this: 63 32 = 31 31 16 = 15 15 8 = 7 74=3 32=1 11=0 So, I used all 8 binary spaces to calculate the 255 in decimal, to be 11111111 in binary. The last octet is a 0, so 0 in binary is 0 but we write 00000000. As you get more experience you will already know that eight 1s in binary equals 255 in decimal. The total subnet mask in binary is: 11111111 11111111 11111111 00000000 So, here is our IP address and subnet mask in binary: 00000001 00000001 00000001 00000001 11111111 11111111 11111111 00000000

Calculating the Network ID


The network device on which you configured this IP addressing information must know what its network ID is. The network ID tells the device what its local network is. If the destination IP address for the network device with which this network device is trying to communicate is noton its local network, that traffic is sent to the default gateway. Thus, the default gateway is used only if the destination for the traffic y our device is sending is not on your local network. To calculate the Network ID, start off with the IP address and subnet mask in binary, from above:

IP Address

00000001 00000001 00000001 00000001

Subnet Mask 11111111 11111111 11111111 00000000


Perform a logical AND on these. A logical AND is a math function where you look at each row and calculate an answer based on the following rules:

0 and 0 = 0 0 and 1 = 0 1 and 1 = 1

In our case, this is the answer you get:

IP Address

00000001 00000001 00000001 00000001

Subnet Mask 11111111 11111111 11111111 00000000 AND Network ID 00000001 00000001 00000001 00000000
Using the AND rules, I look at the first 0 in the IP address and the first 1 in the subnet mask. I see that, according to the rules, a 0 and a 1 = 0. That is how I calculated the first 0 in the network ID. To continue, I go from left to right, calculating each row. Notice that the only difference between the IP address and network ID is in the last number of the last octet. Now, to get the Network ID in decimal, we convert this back. This is a simple example, so converting it back is easy. The 00000001 in binary is converted to 1 in decimal. In the last octet, the 00000000 is converted to 0. This makes our network ID: 1.1.1.0 So, when the network device wants to communicate with a host that has the IP address of 1.1.1.200, it compares this with its network ID and finds that this host is on the local network. The network device can then communicate directly with it because it is on the 1.1.1.0 network. If the network device wants to communicate with host 1.1.2.1, however, it finds that this is NOT on its local network (the 1.1.1.0 network) and it sends this traffic to the default gateway. These examples are, of course, very simplified, since this topic can get very complex when you begin subnetting networks and using variable-length subnet masks.

How to convert Hexadecimal into Decimal


Hex or Hexadecimal, is a 16-base number system with values from 0-9 as well as ABCDEF where A=10, B=11, C=12, D=13, E=14, F=15. Hex is used in many things in IT, most commonly seen in Mac addresses (A unique identity number on every Network Card). It is also seen in certain features such as HSRP (Hot Standby Routing Protocol) group numbers.

This section is here to help understand how to convert Hex into Binary, and Binary into Decimal and of course the reverse.

Lets begin with the easy one, the reverse If I have the number 47 and wanted to convert that into Hexadecimal, the easiest way is to first put it into Binary.

Using our binary table (as described in the post How to count in Binary ) we see the binary value is 00101111

128 0

64 0

32 1

16 0

8 1

4 1

2 1

1 1

Hex is not that much harder to get to from here, but what we need to do is break up the byte (8 bits) into 2 halves of 4 bits each. And draw a new table above each of the 4 bits (as seen below)

8 1 0 1

You will notice that the above Binary is the same as it was in the first table, however Ive split the 8 bits in half and created 2 new groups of 4 bits each. If we look at the first group we see that only the 2 has been turned on which results in the value been equal to 2

In the second group, the 8 and 4 and 2 and 1 have all been turned on which results in the value been equal to 15 (8+4+2+1)

So we currently have 2 (from the first group) and 15 (from the second group). 2 is a valid number in Hex so it remains exactly the same however 15 is represented in Hex as F Therefore 47 in Decimal is equal to 2F in Hexadecimal.

So what if we had the Hex value and wanted to get it back to Decimal, lets look at the value 4C. We know that 4 is a valid Hex value, and we now know that C is a representation of 12 in Hex. Working backwards we need to create 2 tables of 4 bits each, and fill 4 into the first table, and 12 into the second

8 0

4 1

2 0

1 0

8 1

4 1

2 0

1 0

After we have done this, we now need to re-join the 2 halves back into a single 8 bit structure

128 0

64 1

32 0

16 0

8 1

4 1

2 0

1 0

And if we add up all our On bits, we have (64+8+4=76) Therefore 4C in Hexadecimal is equal to 76 in decima

Potrebbero piacerti anche