Figure 6-3: Methods for calculating the number of possible values in a given number of bits
Barcode Maker In Objective-C
Using Barcode maker for iPhone Control to generate, create barcode image in iPhone applications.
PDF 417 Creator In Visual C#
Using Barcode generator for .NET framework Control to generate, create PDF 417 image in .NET framework applications.
Remember, unlike grade-school math, where they taught you that zero was nothing, in computers, it represents an individual state and is counted So from 0 through 6 is actually seven individual numbers, not six
PDF 417 Generator In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create PDF417 image in ASP.NET applications.
PDF417 Generator In Visual Studio .NET
Using Barcode printer for .NET Control to generate, create PDF 417 image in Visual Studio .NET applications.
This is because you count the number you start from So, with eight bits (which we will be working with most), there are actually 256 possible values, ranging from 0 through 255 By the way, the mathematical formula for this computation is 2n (2 to the power of n), where n is the number of bits in question Exercise 6-1: Binary-to-Decimal Conversions Convert the following binary numbers to decimal numbers Answers are provided in the sidebar on the next page Do not use a calculator (it will only defeat the purpose of this exercise) 1 2 3 4 5 10001101 011011 110 111100001010 1001001001
Draw PDF 417 In Visual Basic .NET
Using Barcode drawer for .NET Control to generate, create PDF 417 image in VS .NET applications.
UPC-A Creation In Objective-C
Using Barcode maker for iPhone Control to generate, create GS1 - 12 image in iPhone applications.
Answers to Exercise 6-1 1 2 3 4 5 141 27 6 3,850 585
Drawing UCC-128 In Objective-C
Using Barcode generation for iPhone Control to generate, create UCC.EAN - 128 image in iPhone applications.
EAN13 Generation In Objective-C
Using Barcode creator for iPhone Control to generate, create UPC - 13 image in iPhone applications.
The second shortcut is that when doing a binary conversion, always count the type of digits (0 or 1) you have the least of, and then subtract or add as necessary For instance, if you wanted to determine the value of 11110111, you could add 128 + 64 + 32 + 16 + 0 + 4 + 2 + 1, as we have been doing; but the easier way would be to count the place with the 0 in it (the eights place) and subtract that number from 255 (the value the number would be if all of the bits were a 1)
Generate USS Code 128 In Objective-C
Using Barcode maker for iPhone Control to generate, create Code 128 Code Set B image in iPhone applications.
Generate Bar Code In Objective-C
Using Barcode drawer for iPhone Control to generate, create bar code image in iPhone applications.
Now that you have an understanding of binary, let's take a look at the IP address structure
Drawing Bar Code In Objective-C
Using Barcode creation for iPhone Control to generate, create barcode image in iPhone applications.
Making Code 39 Full ASCII In Objective-C
Using Barcode generator for iPhone Control to generate, create Code 39 Full ASCII image in iPhone applications.
EAN-8 Supplement 2 Add-On Printer In Objective-C
Using Barcode creator for iPhone Control to generate, create EAN / UCC - 8 image in iPhone applications.
Barcode Recognizer In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
As mentioned previously, IP addresses are composed of two primary units: the network portion and the host portion
ANSI/AIM Code 128 Printer In None
Using Barcode generator for Word Control to generate, create Code 128C image in Word applications.
ANSI/AIM Code 128 Creator In Java
Using Barcode drawer for Java Control to generate, create Code 128 Code Set B image in Java applications.
In addition, every IP connection requires at least one unique IP address However, two additional pieces are commonly required to achieve IP connectivity: a subnet mask and a default gateway The subnet mask is required in all IP implementations It defines which part of the address is the host and which part is the network by using a Boolean process known as ANDing ANDing is very simple in binary It is basically multiplication For example, Figure 6-4 shows an IP address and a subnet mask To arrive at the network address (the portion that defines which network you are on), you simply multiply the IP address (in binary) by the subnet mask (in binary) The result is a binary number that you can convert back to decimal to learn the network address This is where routing comes into play Routing is the act of forwarding a packet from one logical network or subnetwork to another A router is simply the device that performs this process
Generating Barcode In .NET
Using Barcode printer for Visual Studio .NET Control to generate, create bar code image in .NET framework applications.
Bar Code Creation In None
Using Barcode creator for Font Control to generate, create barcode image in Font applications.
Figure 6-4: Basic ANDing When a host wants to communicate with another host, it takes that host's IP address and its own IP address, and performs the ANDing process with both addresses If the result for both addresses is the same, the host is assumed to be on the same logical network as the other host, and it should be able to communicate directly If the result is different, the hosts are assumed to be on different logical networks (that is, separated by a router), and they must use a router to reach each other (Figure 6-5 shows an example)
DataMatrix Reader In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
GS1 DataBar Stacked Printer In .NET
Using Barcode maker for .NET Control to generate, create GS1 DataBar Truncated image in VS .NET applications.
Figure 6-5: ANDing for network determination with multiple hosts The router's job is fairly simple on the surface First, it needs to be aware of any networks that its directly connected hosts may wish to reach Second, it needs to forward packets from hosts to those networks Finally, it limits (or eliminates) broadcasts This last function is actually why the first and second functions are needed Think about it like this: to reach a host, any host, you need a MAC address (or other layer 2 address) On a flat network ("flat" is a term typically used to describe a network that is not segmented with a router), this wouldn't be an issue You would just use an ARP broadcast to find the MAC address However, flat networks have serious scalability problems when a broadcast is sent, everyone receives and must process that broadcast For example, imagine the Internet, with 100 million hosts broadcasting for an address every five seconds or so Approximately 20 million packets would be delivered to every host every second If you suspect that this number would be difficult for most hosts to process (which are connected with low-speed lines like 56K modem connections), you are right Assuming 60byte packet sizes, this would eat around one gigabyte per second (that's gigabyte, not gigabit) Therefore, you would need an OC 192 (9953 Gbps) or faster connection to be able to transmit any data and this is without even considering the possibility of a broadcast storm, which occurs when a device begins spitting out broadcast packets as fast as it can This malfunction can saturate even LAN connections, so you can imagine what it would do to most WAN connections For this reason, routers are used to segment flat networks into hierarchical networks consisting of multiple broadcast domains A broadcast domain is the area in which a broadcast is contained (Figure 6-6 shows an example) Routers segment networks into broadcast domains to keep broadcasts from overrunning every device on the network
Figure 6-6: Segmentation into broadcast domains So the job of Boolean ANDing is to determine whether the host can just broadcast to reach the other host, or send the packet to a router instead Remember, however, that a MAC address is still required If the host can't broadcast for the MAC address of a remote host, how does it get its MAC address Easy It doesn't It uses the router's MAC address instead If a host determines that the host it is trying to reach is on a different network, it sends the packet to a router that is likely to reach the remote network Typically, this router is the host's default gateway (This router could also be one listed in the host's routing table, but we will discuss that further in 22) A default gateway is the IP device to which a host sends a packet when it doesn't know where else to send the packet When it sends the packet to the default gateway, it uses the default gateway's MAC address as the destination MAC address rather than the remote host's, but it still uses the remote host's IP address The router then determines where to send the packet and inserts the new next hop MAC address, as required Figure 6-7 illustrates this process
Figure 6-7: A transmission using the default gateway In this example, host Einstein is trying to send a packet to host Darwin Two routers, Beethoven and Mozart, block their path Einstein determines that Darwin is a remote host, so he inserts Beethoven's MAC address into the packet and transmits Beethoven, upon receiving the packet, realizes that he must go through Mozart to get the packet to Darwin He therefore inserts Mozart's MAC address into the packet and transmits Mozart knows that Darwin should be reachable directly from his Ethernet interface, but he doesn't yet know Darwin's MAC address, so he ARPs for it Upon receiving Darwin's MAC address, Mozart inserts it into the packet and transmits the packet directly to Darwin When Darwin wishes to reply back to Einstein, the process is repeated in reverse Now that you have seen this entire process, let's try our hand at determining whether two hosts are on the same network In Figure 6-8, two hosts, Michelangelo and Renoir, are attempting to communicate Michelangelo has an IP address of 1721611, with a subnet mask of 25525500 Renoir has the IP address of 172165202, with a subnet mask of 2552552550 Can they communicate Take a second to work out the ANDing on your own before continuing
Figure 6-8: Two hosts attempting to communicate The answer is no Why Take a look at Figure 6-8 again If you perform the ANDing process, it looks as if Michelangelo will attempt to send the packet to a router because his network address is 17216800 and Renoir's is 1721650 Actually, the reverse is true Michelangelo has no way of knowing that Renoir is using a different subnet mask than he is He will assume that, because Renoir is using the same address block, he must be using the same subnet mask Therefore, when Michelangelo performs his ANDing, the result will match, and he will attempt to send it directly The unusual part is that Michelangelo's send operation will actually succeed because they really are on the same logical network However, when Renoir attempts to respond, he will fail because he will perform his own ANDing operation The result will be that they are on different networks Renoir will attempt to send the packet to a router, but the packet will never be delivered This process is shown in Figure 6-9
Figure 6-9: Visual explanation of the failure The purpose of this final ANDing example is for you to realize that not only IP addresses but also subnet masks must match if hosts are on the same logical network If they do not match, the ANDing will be performed incorrectly, and the communication will fail