Exploration Binary and subnet exercises. Please complete the following exercises, and return your answers to your instructor or the instructor's alias. It is important to know how to convert numbers from binary to decimal and decimal to binary. in our exercises numbers will only range 1-255 To convert decimal to binary here is a worked example. Convert 107 to binary. Find the largest power of 2 that can be subtracted from 107. 2^6=64 107-64=43: write a 1. 43-32=11 write a 1 we can not subtract 16, write a zero. 11-8=3 write a 1 we can not subtract a 4, write a zero. 3-2=1 write a 1 1-1=0: write a 1 Answer 1101011 Convert 1101011 to decimal to check results. add the powers of 2 from right to left. 1+2+8+32+64=107 Convert the following to binary: 37 86 176 233 252 Convert the following to decimal: 1110 10111 1110000 11010011 11111100 A subnet mask is a binary quantity that shows how many bits of an address belong to the network portion of an address and how many bits belong to the host portion. The bits on the left of the subnet mask are set to 1 to denote network bits and set to 0 on the right-hand-side of the address to denote The subnet mask host bits. For example let us take the subnet mask 255.255.255.0 This can be written in binary as 11111111 11111111 11111111 00000000 If we count the bits that are set to 1, we find that 24 bits of the address are network bits, and 8 bits are host bits. In the address 192.168.26.55 192.168.26 is the network portion, and 55 is the host portion. In the following subnet masks how many bits are for network portion and how many bits are for host portion? Note that for IPV4 addresses adding these 2 quantities should equal 32. 255.255.0.0 255.255.255.224 255.255.255.192 255.255.240.0 255.255.252.0 Note that class a addresses ranging 1-127 have 8 bits for network, 24 bits for host. Class B addresses 128-191 have 2 bytes network, 2 bytes host. Class C addresses ranging 192-223 have 3 bytes of network address and 1 byte of host portion. Class A B C have 1 2 3 bytes of network address. Is this machine on my network? A router uses the logical and operation to determine whether a machine exists on a network that the router can reach. An and gate works as follows: If both inputs to the gate are 1, the output to the gate is 1. This gives us the following truth conditions: 0 and 0 is 0 0 and 1 is 0 1 and 0 is 0 1 and 1 is 1. A router ands the destination ip address with the subnet mask of the route and figures out whether or not the machine is on the same network as the route. If it is the packet is forwarded out the interface or through the gateway. Anding the destination ip address with the subnet mask will yield the network address for the network. Here is a worked example: destination ip address 192.192.192.128 anded with 255.255.255.0 Convert our quantities to binary. 192.192.192.128 in binary is 11000000 11000000 11000000 10000000 255.255.255.0 in binary is 11111111 11111111 11111111 00000000 Now put our quantities one above the other and perform the and. Note that Jackie's notepad scripts may be useful for this as they will only read the character you land on rather than the line. They can be had from www.cucat.org in the extras folder. 11000000 11000000 11000000 10000000 anded with 11111111 11111111 11111111 00000000 Let's work from left to right most significant bit to least significant bit: 32: 1 and 1 is 1 31: 1 and 1 is 1. 30: 1 and 0 is 0 29: 1 and 0 is 0 28: 1 and 0 is 0 27: 1 and 0 is 0 26: 1 and 0 is 0 25: 1 and 0 is 0 Left hand byte is 11000000 So are second and 3rd bytes. 4th byte: 10000000 anded with 00000000 8: 1 and 0 is 0 7: 0 and 0 is 0 6: 0 and 0 is 0 5: 0 and 0 is 0 4: 0 and 0 is 0 3: 0 and 0 is 0 2: 0 and 0 is 0 1: 0 and 0 is 0 Our final answer is: 11000000 11000000 11000000 00000000 11000000 in decimal is 64+128=192 so our answer converted back to decimal is 192.192.192.0 Here is an example of a routing table for a fictitious router. Where would the packets be sent for the below ip addresses? destination: 192.168.1.0, mask 255.255.255.0 gateway 123.123.123.123 destination 192.168.2.0: mask 255.255.255.128 gateway 125.125.125.125 destination 192.168.2.128 mask 255.255.255.128 gateway 126.126.126.126 192.168.1.5 192.168.1.231 192.168.2.42 192.168.2.244 Calculate the network addresses and broadcast addresses for the above networks. When subnetting a network it is important that you allocate the correct number of ip addresses to each network based on the number of machines present. We subnet by borrowing bits from the host portion and shifting them into the network portion. Here is an example. We wish to subnet the class c supernet 192.168.1.0/255.255.255.0 into subnets. We analyse the network in question which has 4 networks containing 50 machines per network. We wish these machines to be on separate subnets for security reasons. A subnet must contain a power of 2 number of cominations, and contain 2 less than the number of cominations in available hosts. We find the smallest power of 2 that will accommodate 50 hosts, which is 64, or 2^6. We now have 24 supernet bits, 2 subnet bits and 6 host bits so the ip address is made up of nnnnnnnn.nnnnnnnn.nnnnnnnn.sshhhhhh where n are the supernet bits, s are the bits for subnetting and h are the host bits. As we have 2 subnet bits the binary combination for these bits can be 00 01 10 and 11 giving us 4 subnets of 62 hosts, 2^6-2=62. we note that we can put our 50 hosts inside the 4 subnets. Note that the networks start at 0, 64, 128 and 192. It is possible however to make subnets of the correct size to fit demands so in our previous example if we had 2 networks of 25 hosts, we would use a 32-address subnet for these 25. If we have more than 256 hosts we need a block bigger than a class c. What netmask would be necessary for the following numbers of hosts? 25 hosts. 86 hosts. 60 hosts. 507 hosts. 3000 hosts. If we have the network 192.168.4.0/255.255.254.0 how would we subnet it for the following? a group of 250 hosts, and a group of 20 hosts and a group of 90 hosts