Lab 1: Conversion between different number systems 1.1 Decimal to Binary Conversion Objective Learn to convert decimal values to binary values. Practice converting decimal values to binary values. Background Knowing how to convert decimal values to binary values is valuable when converting human readable IP addresses in dotted decimal format to machine-readable binary format. This is normally done for calculation of subnet masks and other tasks. The following is an example of an IP address in 32-bit binary form and dotted decimal form. Binary IP Address: 11000000.10101000.00101101.01111001 Decimal IP Address: 192.168.45.121 A tool that makes the conversion of decimal values to binary values simple is the following table. The first row is created by counting right to left from one to eight, for the basic eight bit positions. The table will work for any size binary value. The value row starts with one and doubles, Base 2, for each position to the left. Position 8 7 6 5 4 3 2 1 128 64 32 16 8 4 2 1 Value 128 207 64 8 4 2 The same conversion table and simple division can be used to convert binary values to decimal values. Steps To convert 207 to binary: 1. Start with the digit farthest to the left. Determine if the decimal value can be divided by it. Since it will go one time, put a 1 in row three of the conversion table under the 128 value and calculate the remainder, 79. 2. Since the remainder can be divided by the next value, 64, put a 1 in row three under the 64 value of the table. 3. Since the remainder cannot be divided by either 32 or 16, put 0s in row three of our table under the 32 and 16 values. 4. Continue until there is no remainder. 5. If necessary, use row four to check the work. Position Value 8 7 6 5 4 3 2 1 128 64 32 16 8 4 2 1 1 1 0 0 1 1 1 1 128 64 8 4 2 1 = 207 6. Convert the following decimal values to binary values: a. 123 __01111011_____________________ b. 202 _____11001010__________________ c. 67 _____0100 0011__________________ d. 7 _______0111________________ e. 252 _________11111100______________ f. 91 _____________01011011__________ g. 116.127.71.3 ____01110100________ ____0111111________ _____01000111_______ _____0011_______ h. 255.255.255.0 _____11111111_______ ______11111111______ ____________ _____00000000_______ i. 192.143.255.255 ______11000000______ ______10001111______ _____11111111_______ _____11111111_______ j. 12.101.9.16 ______00001100______ ____01100101________ _____00001001_______ _____00010000_______ This concludes the lab. 1.2 Binary to Decimal Conversion Objective Learn the process of converting binary values to decimal values. Practice converting binary values to decimal values. Background The following is an example of an IP address in 32-bit binary form and dotted decimal form. Binary IP Address: 11000000.10101000.00101101.01111001 Decimal IP Address: 192.168.45.121 Binary data is made up of ones and zeros. Ones represent on and zeros represent off. Binary data can be grouped in varying increments, 110 or 1011. In TCP/IP binary data is usually grouped in eight digit groups called a Byte. A Byte, 8 bits, can range from 00000000 to 11111111 creating 256 combinations with decimal values ranging from 0 to 255. IP addressing uses 4 bytes, or 32 bits, to identify both the network and specific device. The specific device can be a node or host. The example at the beginning of this lab is an example of an IP address in both binary decimal formats. A tool that makes the conversion of binary to decimal values simple is the following table. The first row is created by counting right to left from one to eight for the basic eight bit positions. The tale will work for any size binary value. The value row starts with one and doubles, base 2, for each position to the 8 7 6 5 4 3 2 1 left. Position Value 128 64 32 16 8 Steps 1. Enter the binary bits in row three. For example 10111001 4 2 1 2. Put the decimal values in row four only for the third row 1s. Technically the row two values are being multiplied by row three. 3. Now just add row four across. Position Value 8 7 6 5 4 3 2 1 128 64 32 16 8 4 2 1 1 0 1 1 1 0 0 1 32 16 8 128 4. 1 Convert the following binary values to decimals: a. 1110 ________14_______________ b. 100110 _______38________________ c. 11111111 _______255________________ d. 11010011 ________211_______________ e. 01000001 ________65_______________ f. 11001110 ________206_______________ g. 01110101 _________117______________ h. 10001111 __________143_____________ i. 11101001.00011011.10000000.10100100 _________233________ _______27__________ ________128_________ __________164_______ j. 10101010.00110100.11100110.00010111 ________170_________ _______52__________ ______230___________ ________23_________ 1.3 Hexadecimal Conversions Objective = 185 Learn the process to convert hexadecimal values to decimal and binary values. Learn the process to convert decimal and binary values to hexadecimal values. Practice converting between decimal, binary and hexadecimal values. Background / Preparation The Hexadecimal (Hex) number system is used to refer to the binary numbers in a NIC or IPv6 address. The word hexadecimal comes from the Greek word for 16. Hexadecimal is often abbreviated "0x", zero and lower case x. Hex numbers use 16 unique digits to display any Dec Hex Binary 0 0 0000 1 1 0001 combination of eight binary digits as only two hexadecimal digits. 2 2 0010 A Byte, or 8 bits, can range from 00000000 to 11111111. A Byte can create 256 combinations with decimal values ranging from 0 to 255 or Hex values 0 to FF. Each Hex value represents only four binary bits. The alpha (A-F) values are not case sensitive. 3 3 0011 4 4 0100 A tool that makes the conversion of hexadecimal to decimal values simple is the following table. Use the same techniques as covered in binary to decimal conversions. The first row is the two Hex positions. The value row starts as 1 and 16, base 16, for each position to the left. 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 Position Value 2 16 1 1 Note: Steps are provided at the end of this lab in the use of the Windows Scientific Calculator to check the work. Steps for Hex to decimal conversion 1. Break the Hex value into pairs. Start at the right side. For example 77CE becomes 77 and CE. Insert a zero in the first position if necessary to complete the first pair. 2. Put each Hex pair in row three. The value in parenthesis is the decimal value of A-F. 3. To get the decimal values in row four, multiply the row two values by row three. 4. Now just add row four across. Position 2 1 Value 16 1 7 7 112 7 = 119 Position 2 1 Value 16 1 C(12) E(14) 192 14 = 206 Steps for decimal to Hex conversion 1. To be valid for the purpose of this lab, the decimal value will be between 0 and 256. The first Hex value is derived by dividing the decimal value by 16. If the value is greater than 9 it will need to be put in Hex form A-F. 2. The second value is the remainder from step 1. If the value is greater than 9 it will need to be put in Hex form A-F. 3. For example, 209 divided by 16 is 13 with a remainder of 1. 13 equals D in Hex. Therefore, 209 equals D1. Steps for Hex to binary conversion 1. This is the easiest conversion. Remember that each Hex value converts to four binary bits, so work right to left. 2. For example, to convert 77AE to binary. Start with E. Use the table at the beginning of this lab to go directly to binary. The other alternative is to convert the value to decimal, E = 14, and then use the last four positions of the table used in the decimal to binary conversions. 14 divided by 8 is 1 with a remainder of 6. 6 divided by 4 is 1 with a remainder of 2. 2 divided by 2 is 1 with no remainder. Add zeros if necessary to end up with four bits. Position 4 3 2 1 8 4 2 1 1 1 1 0 8 4 2 Value = 14 3. Using the same technique, A becomes 1010 and the total so far is 10101110. Position Value = 10 4 3 2 1 8 4 2 1 1 0 1 0 8 4. 2 Using the same technique, the two 7s each become 0111 and the total is 01110111.10101110. Position Value 4 3 2 1 8 4 2 1 0 1 1 1 4 2 1 =7 Steps for binary to Hex conversion 1. Each Hex value equals four binary bits. Start by breaking the binary value into 4-bit units from right to left. Add any leading zeros required to end up with all 4-bit values. 01101110. 11101100 would become 0110 1110 1110 1100. 2. Use the table at the beginning of this lab to go directly to Hex. The other alternative is to convert each 4-bit binary value to decimal, 0-15. Then convert the decimal to Hex, 0-F. 4 3 2 1 8 4 2 1 1 1 0 0 8 4 Position 4 3 2 1 Value 8 4 2 1 1 1 1 0 8 4 2 Position Value = 12 or C = 14 or E 3. The result is 6E-EC. Practice Convert the following values to the other two forms: Decimal Hex Binary 1 169 a9 10101001 2 255 FF 11111111 3 47825 Bad1 1011101011010001 4 231-99-28 E7-63-1C 11100111-01100011-00011100 5 53 35 00110101 6 115 73 01110011 7 19 13 00010011 8 212.65.119.45 D4.41.77.2D 11010100.01000001.01110111.00101101 9 170 AA 10101010 1.4 Converting IPv4 Addresses to Binary Objectives Part 1: Convert IPv4 Addresses from Dotted Decimal to Binary Part 2: Use Bitwise ANDing Operation to Determine Network Addresses Part 3: Apply Network Address Calculations Scenario Every IPv4 address is comprised of two parts: a network portion and a host portion. The network portion of an address is the same for all devices that reside in the same network. The host portion identifies a specific host within a given network. The subnet mask is used to determine the network portion of an IP address. Devices on the same network can communicate directly; devices on different networks require an intermediary Layer 3 device, such as a router, to communicate. To understand the operation of devices on a network, we need to look at addresses the way devices do in binary notation. To do this, we must convert the dotted decimal form of an IP address and its subnet mask to binary notation. After this has been done, we can use the bitwise ANDing operation to determine the network address. This lab provides instructions on how to determine the network and host portion of IP addresses by converting addresses and subnet masks from dotted decimal to binary, and then using the bitwise ANDing operation. You will then apply this information to identify addresses in the network. Part 1: Convert IPv4 Addresses from Dotted Decimal to Binary In Part 1, you will convert decimal numbers to their binary equivalent. After you have mastered this activity, you will convert IPv4 addresses and subnet masks from dotted decimal to their binary form. Step 1: Convert decimal numbers to their binary equivalent. Fill in the following table by converting the decimal number to an 8-bit binary number. The first number has been completed for your reference. Recall that the eight binary bit values in an octet are based on the powers of 2, and from left to right are 128, 64, 32, 16, 8, 4, 2, and 1. Decimal Binary 192 11000000 168 10101000 10 1010 255 11111111 2 00000010 Step 2: Convert the IPv4 addresses to their binary equivalent. An IPv4 address can be converted using the same technique you used above. Fill in the table below with the binary equivalent of the addresses provided. To make your answers easier to read, separate the binary octets with a period. Decimal 192.168.10.10 Binary 11000000.10101000.00001010.00001010 209.165.200.229 11010001.10100101.11001000.11100101 172.16.18.183 10101100.00010000.00010010.10110111 10.86.252.17 00001010.01010110.11111100.00010001 255.255.255.128 11111111.11111111.11111111.10000000 255.255.192.0 11111111.11111111.11000000.00000000 Part 2: Use Bitwise ANDing Operation to Determine Network Addresses In Part 2, you will use the bitwise ANDing operation to calculate the network address for the provided host addresses. You will first need to convert an IPv4 decimal address and subnet mask to their binary equivalent. Once you have the binary form of the network address, convert it to its decimal form. Note: The ANDing process compares the binary value in each bit position of the 32-bit host IP with the corresponding position in the 32-bit subnet mask. If there two 0s or a 0 and a 1, the ANDing result is 0. If there are two 1s, the result is a 1, as shown in the example here. Step 1: Determine the number of bits to use to calculate the network address. Description Decimal Binary IP Address 192.168.10.131 11000000.10101000.00001010.10000011 Subnet Mask 255.255.255.192 11111111.11111111.11111111.11000000 Network Address 192.168.10.128 11000000.10101000.00001010.10000000 How do you determine what bits to use to calculate the network address? ___We convert IP Address and subnet mask to binary. In the example above, how many bits are used to calculate the network address? __32 Bits__________________________________________________________________________________ Step 2: Use the ANDing operation to determine the network address. a. Enter the missing information into the table below: Description b. 172.16.145.29 10101100.00010000.10010001.00011101 Subnet Mask 255.255.0.0 11111111.11111111.00000000.00000000 Network Address 172.16.0.0 10101100.00010000.00000000.00000000 Enter the missing information into the table below: Binary 192.168.10.10 11000000.10101000.00001010.00001010 Subnet Mask 255.255.255.0 11111111.11111111.11111111.00000000 Network Address 192.168.10.0 11000000.10101000.00001010.00000000 Enter the missing information into the table below: Decimal Binary IP Address 192.168.68.210 11000000.10101000.01000100.11010010 Subnet Mask 255.255.255.128 11111111.11111111.11111111.10000000 Network Address 192.168.68.64 11000000.10101000.01000100.10000000 Enter the missing information into the table below: Description e. Decimal IP Address Description d. Binary IP Address Description c. Decimal Decimal Binary IP Address 172.16.188.15 10101100.00010000.10111100.00001111 Subnet Mask 255.255.240.0 11111111.11111111.11110000.00000000 Network Address 172.16.176.0 10101100.00010000.10110000.00000000 Enter the missing information into the table below: Description Decimal Binary IP Address 10.172.2.8 00001010.10101100.00000010.00001000 Subnet Mask 255.224.0.0 11111111.11100000.00000000.00000000 Network Address 10.160.0.0 00001010.10100000.00000000.00000000 Part 3: Apply Network Address Calculations In Part 3, you must calculate the network address for the given IP addresses and subnet masks. After you have the network address, you should be able to determine the responses needed to complete the lab. Step 1: Determine whether IP addresses are on same network. a. You are configuring two PCs for your network. PC-A is given an IP address of 192.168.1.18, and PC-B is given an IP address of 192.168.1.33. Both PCs receive a subnet mask of 255.255.255.240. What is the network address for PC-A? ___________________________ What is the network address for PC-B? ___________________________ Will these PCs be able to communicate directly with each other? _______ What is the highest address that can be given to PC-B that allows it to be on the same network as PC-A? ___________________________ b. You are configuring two PCs for your network. PC-A is given an IP address of 10.0.0.16, and PC-B is given an IP address of 10.1.14.68. Both PCs receive a subnet mask of 255.254.0.0. What is the network address for PC-A? __________________________ What is the network address for PC-B? __________________________ Will these PCs be able to communicate directly with each other? ______ What is the lowest address that can be given to PC-B that allows it to be on the same network as PC-A? ___________________________ Step 2: Identify the default gateway address. a. Your company has a policy to use the first IP address in a network as the default gateway address. A host on the local-area network (LAN) has an IP address of 172.16.140.24 and a subnet mask of 255.255.192.0. What is the network address for this network? ___________________________ What is the default gateway address for this host? ___________________________ b. Your company has a policy to use the first IP address in a network as the default gateway address. You have been instructed to configure a new server with an IP address of 192.168.184.227 and a subnet mask of 255.255.255.248. What is the network address for this network? ___________________________ What is the default gateway for this server? ___________________________