|[ LiB ]|
From the beginning of history, communication has been an important part of human society. As important as communication has been, the mass distribution of communication through networks is only a recent development. Most early communication was accomplished through horseback riders carrying written messages.
Latency is a communications term that describes how long it takes for one piece of data to reach its desti nation. For example, it takes less than one millisecond (msec) for data to go from one computer to another on my home network, and around 15 msec for data to reach my Internet Service Provider's (ISP's) routers.
The invention of railroads brought a major advancement in communications networks by facilitating the transfer of massive amounts of mail across the world. But communication was still inadequate. While the throughput of these railroad networks was large, the latency was also large.
While masses of mail could be sent through railroad networks, it still took weeks for some pieces to reach their destinations, and this was unacceptable to many people.
In 1835, something amazing happened : The telegraph was invented.
The telegraph was essentially a long wire with a speaker on one end and a battery at the other. Figure 1.1 shows a simple telegraph "network." Whenever the battery was engaged, it sent an electrical signal down the wire that would power the speaker and cause a small tone to be heard . Since there were only two states of the communicationthe presence or absence of sounda special messaging system called Morse code was invented, which varied the number and length of tones to represent different characters . Short tones were called dots, and long tones were dashes.
It is a commonly held "fact" that Samuel Morse invented the tele graph, but there are conflicting reports about a person named C.M. Renfrew inventing it as well. You can read about this more on the Internet if you wish; there's good information about telegraphs at this site: http://www.worldwideschool.org/library/books/tech/engineering/HeroesoftheTelegraph/chap1.html .
Even though communication in this manner had a low latency (tones were transmitted almost instantly), you can imagine that the throughput of this method of communication was very low. There were no machines back then to convert signals from Morse code to English, so people had to do it by hand.
The next major innovation in communications occurred in 1876 with the invention of the telephone.
Alexander Graham Bell is generally credited with inventing the tele phone, but he was only lucky enough to get his patent approved first. Elisha Gray, working independently of Bell, simultaneously invented the telephone, but he didn't file his patent application fast enough. What have we learned today, class? Always file your patents immediately.
The telephone allowed people to encode sound data into an analog electrical pulse, which would then be sent down a wire, to the speaker on the other end (Figure 1.2). This method of communication was an incredible innovation, since with the direct interpretation of voice, communication could be accomplished without people encoding and decoding Morse code. This greatly improved the throughput of the communications, because voice data could now be transmitted in real time.
This method of communication only increased people's desire for faster and better communications, since only one person could use one telephone line at a time.
Both the telegraph and the tele phone supported two-way communi cations, which Figures 1.1 and 1.2 do not show, for simplicity's sake.
Peer-to-peer networking connected many telephones to many other telephones. Alexander Graham Bell was a major proponent of this kind of network, and it worked well for small networks. Basically, every node in a peer-to-peer network is physically connected to every other node in the network through wires. This gets to be a major problem as the number of nodes grows, because, as you can probably see, the number of wires needed in this kind of network follows a geometric progression based on the number of nodes in the network. To add a third node to a network, you need two extra wires, making a total of three in the network. Table 1.1 shows a listing of the number of wires needed for networks with different numbers of nodes.
The number of wires needed in a peer-to-peer network follows this formula: ( n * (n-1) )/2. So you can see that any network that gets past a certain size is in the realm of being completely unmanageable.
Because of this, the concept of a centralized communications network was invented, and its implementation was called a circuit-switched network . This kind of network contains any number of nodes and one central switching station , arranged as shown in Figure 1.3.
Since only one conversation could be conducted at any given time on a telephone wire, the original networks had to use switching to enable multiple conversations to occur at the same time. Essentially, this is how it worked.
There was a human operator at the switching station, who monitored all the nodes for incoming activity. Whenever one of the nodes wanted to talk to any of the other nodes, a person called the operator from his node, and the operator asked whom he wanted to talk to. When the operator determined whom the caller wanted to talk to, he physically connected a wire from the caller's circuit to the destination circuit. For example, Figure 1.4 shows node 1 connected to node 4. When node 1 wants to talk to node 4, an operator physically connects the circuits with a wire.
So, with this network, a total of two conversations can be held at the same time, and any single node can talk to any other node, as long as the line is open . This spawned a major breakthrough in communications, but its service was still inadequate. Eventually these switching stations became too large for human operators to manage, so methods were developed to spread out the communications into many switches, as shown in Figure 1.5.
When a person wanted to call someone at his local switch, the same procedure was followed. When a person wanted to call someone on another switch, the operator connected the person to the operator on the desired switch, and that operator connected the person to the right destination. Each switch had only a certain number of wires connecting it to other switches, and that limited the number of connections that could be made from switch to switch. For example, a switch may have 16 nodes, which allows up to eight intra-switch connections at once, but it may have only four wires connecting to an adjacent switch, which means that only four inter-switch connections can be made.
The terms intra and inter refer to "internal" and "external" respec tively. So inter-switch refers to connections between two nodes on one switch, but intra-switch refers to connections of nodes that are on different switches.
Eventually, each switch in the United States was numbered with its own area code, and this led to our current area code system.
It didn't take long for these networks to become such huge messes of wires that it was difficult to make connections. Therefore, an even more centralized system was created. The switches were given centralized switches, sometimes called hubs . Figure 1.6 shows one of these networks.
Traditional circuit switching was great, but it had too many limitations for our growing communications needs. Since traditional circuit-switched networks were so centralized, the main hubs could go down, and half of the communications in the country would instantly be halted. Only one line could be in use at any given time, limiting the number of concurrent connections drastically. There also came a time when it took about seven to eight minutes just to go through all the operators to connect to someone else on the network.
In the 1960s, the United States Advanced Research Projects Agency ( ARPA ) invented the first packet-switched network. The idea of such a network is to separate data into tiny chunks , called packets .
In this type of network, instead of only one connection per wire, special machines at the end of each wire accept discrete chunks of data (packets) and send each chunk one at a time down the wire, with the chucks arriving first sent first. These machines are called switches , but they are much more commonly known as routers . Figure 1.7 shows a simple network with two routers.
Whenever a node has data to send, it puts that data into a discrete- sized packet and then sends it to the router. The router decides where it goes and sends it to the right place. If the wire between the routers is busy, the router puts the packet in a queue and keeps it there until the wire opens up and is available for transmissions.
This kind of network is a great improvement, because it drastically reduces the number of wires needed to connect two switches. One of the downsides, however, is that since many more communications are now occurring on the same line at the same time, each connection has less bandwidth. The original Defense Advanced Research Projects Agency Network ( DARPANet) didn't have enough bandwidth to transmit a single voice communication, unless it was the only communication going on at the time.
Since data packets had to be in a form that the routers could understand, and the routers were digital computers, it made sense that they would send digital data. Unfortunately, data sent over a wire is analog by nature, so the digital data needed to be turned into an analog signal using a device called a modulator -demodulator ( modem for short). Early modems didn't do a great job of converting data efficiently , and were limited to a bandwidth of about 300 baud .
Bandwidth is a networking term that generally describes how much data can be sent through a network. In the traditional sense, bandwidth refers to the size of a signal. For example, telephones have 3,000 Hz of bandwidth, from 400 Hz to 3.4 KHz. Telephone wires are not rated to send data above or below those thresholds. AM Radio broad casts use about 10 KHz of bandwidth each, FM Radio broadcasts use about 200 KHz, and VHF/UHF TV broad casts use 6 MHz of bandwidth. Most people, when dealing with packet-switched networks, refer to their throughput as bandwidth as well.
Baud is an old term, dating back to the days of telegraphs. The term comes from the name of one of the engineers who first worked with telegraphs, Jean Maurice Emile Baudot. The speed at which an electronic circuit changed states was measured in bauds , and a baud was roughly equivalent to the number of bits per second that could be transmitted. So 300 baud is about 300 bits per second. Modems stopped using the term baud at around the time the 14,400 bps modem was invented. Does this sound like ancient history?
Over the years , significant improvements have been made to methods of data transmission over traditional copper wires. New inventions such as fiber- optic wires and even wireless radio-frequency ( RF ) communication allow data to be transferred in a much more efficient manner. Eventually, everything will be transferred over packet-switched networks, since they are far more cost-efficient and useful than the circuit-switched or broadcast networks that your telephone and cable companies use. You won't need a specific cable line, phone line, or Internet line; everything will connect into one standard interface.
Eventually, all land-based copper wires will be replaced with fiber optics . Fiber-optic communication is an incredible breakthrough in the realm of wired communications. Every electrical circuit has resistance, which slowly saps out the signal strength and causes the wires to become hot. There fore, to maintain signal strength on copper wires, repeaters must be placed on the wire to boost the signal and send it further. Not only do these boosters require lots of energy, but they slow down transmission speed as well. Fiber-optic wires directly transmit light impulses with much less signal drop-off, and since they transmit light directly, they are faster than traditional electrical signals as well. In addition, fiber-optic wires require fewer repeaters.
Broadband communications originally referred to cables that carried more than one type of data at the same time. The first types of broadband included Digital Subscriber Line (DSL) and cable modem technologies. However, the term now generally applies to any Internet communications that are faster than traditional modems, which are limited to 56 kilobits per second.
DSL lines are essentially an extension of the standard telephone lines to your house. While telephone wires are not officially supposed to handle data above 3.4 KHz bandwidth, most new telephone wires actually can handle that kind of data. Therefore, digital data can be encoded into an analog electrical signal above 4 KHz and transmitted to the phone company without disrupting the normal phone conversation. The most popular DSL variant is ADSL (the "A" stands for asynchronous , because it allocates more bandwidth for downloading than uploading), which uses the band of 25 KHz to 160 KHz for its upstream, and 240 KHz to 1,500 KHz for its downstream.
Unfortunately for me, DSL technology came too late. The year before DSL was standardized, my telephone company installed a digital switch in my neighborhood that encoded the telephone data into a digital stream of data and sent it to the phone company via a fiber-optic cable, ignoring any data outside of the standard telephone range of 400 Hz to 3.4 KHz. Therefore, DSL cannot be used in my neighborhood because the phone technology is too advanced for DSL. Talk about irony!
Cable modems work in a similar way to DSL, except they use the unused bands of the coaxial cable that goes into your house, instead of your telephone line. Cable modems typically use the band of 5 MHz to 65 MHz for upstream data and 850 MHz to 1000 MHz for downstream data. Cable modems use much more bandwidth for their signals, because coaxial cables are typically a lot longer than telephone cables, and signals on them are weaker.
The Internet is a very cool thing, but I'm sure you already knew that. I want to show you how packets actually work, so you can appreciate even more how wonderful the Internet is.The basis of the Internet lies in the Internet Protocol ( IP) . This protocol was invented in 1981, which really wasn't that long ago in the grand scheme of things.
The whole idea of the IP protocol was to define a standard method of communication among routers, switches, and nodes on a network. Basically, every chunk of data that is sent is prefixed with a header , also known as the IP header . Two versions of IP exist today: IPv4 and IPv6.
Figure 1.8 shows the standard layout of an IPv4 header.
The v4 means version 4 . IPv4 is the current IP standard across the world, but there is a newer version called IPv6 . (What happened to IPv5? Who knows ? It's probably having a party along with DirectX 4.) I'll get into IPv6 later on, since it's not used too muchyet.
You don't have to understand all the little details of the header; they're really important only to network engineers. I'll go over the important points, though.
The first thing you should know is that the length of the header is variable. Everything up to the Options parameter (bottom row of the figure) is set in stone, but the Options parameter is variable. That is why there is a parameter that holds the length of the header (the Header Length parameter); any data past the header is the data stored in the packet.
The Total Packet Length parameter describes the entire length of the packet, in bytes, including the header. Since it's 16 bits long, an IP packet can be at most 65,535 bytes long.
The Time To Live (TTL) parameter is particularly interesting; it determines how long, in jumps , the packet lives. This prevents packets from accidentally being routed around in circles forever. Every time a packet passes through a new router, the TTL field is reduced by 1, and when it reaches 0, the router completely discards the packet. The field is 8 bits, so there can be at most 255 hops between routers before a packet is completely discarded. The 255 hops is an incredibly large number, so it is reasonable protection.
The Protocol parameter determines which protocol is being used on top of the IP header. Only a few kinds of protocols operate on top of IP. As a games programmer, you should mainly pay attention to two:
Transmission Control Protocol (TCP)
User Datagram Protocol (UDP)
I describe these protocols in more detail later on. The Header Checksum parameter is an important data integrity measure in IPv4. A checksum is a value that represents the data and is computed by a checksum algorithm. The checksum is a simple measure that verifies if data has been changed in the transmission. Whenever a router receives an IP packet, the packet's checksum is calculated and compared to the existing checksum value in the packet. If the numbers match, you can be reasonably certain that the data has not changed; if the numbers don't match, you know the data was somehow changed by an error or interference in the communication path . Whenever the checksums don't match, the router immediately discards the packet. You'll see why this is a good idea later on. Also, since the TTL parameter is changed at every router, the checksum is recalculated whenever a router passes a packet on.
Finally, the two most interesting parts of an IP packet are the source IP address and the destination IP address. Every node on an IPv4 network is given a 32-bit IP address, typically represented as four numbers, separated by periods, like this: 192.168.100.5.
Under the old addressing system, organizations such as the University of California At Berkeley were given more IP addresses than the entire country of China. You can see how the old system just isn't going to work anymore, especially when you consider that Berkeley only has a few thousand people, and China has 1.2 billion.
The original Internet addressing scheme classified all addresses into three groups: large, medium, and small networks. This system was wasteful and isn't used much anymore, so I won't waste time describing it.
Using 32-bit addresses limits the number of total nodes on a network to a little more than 4 billion, which used to seem like a large number, but it seems smaller and smaller every day. There are already many more than 4 billion people on this planet, so giving every person his own IP address is not even possible anymore. This was the major concern for upgrading the system to IPv6, which I will touch on next.
IPv6 was created in 1995, when the Internet community realized that IPv4 was too constrained. The biggest problem, by far, was the small address space allocated to IPv4. As I've said before, 4 billion addresses is simply not enough to identify all the computers on the planet now or in the future. Most large ISPs dynamically assign an IP address to a customer when he logs on and reuse that number for another customer once he logs off. This method isn't useful anymore, as most people are starting to realize the importance of permanent Internet addresses. How would you like a phone number that changed every day? In addition, as broadband connections are becoming the standard, more and more people are staying online longer and longer, making dynamic IP allocation less workable .
And finally, there are going to be thousands of devices in the future that will need their own IP addresses. IBM has even promised refrigerators that can connect to the Internet, and gosh darn it, I want them now!
Besides the larger address space, IPv6 has a host of new features making it more streamlined and functional, and even better security features have been added. However, if you're interested in those features, you should get a networking book, because this stuff isn't that important to game programming.
Figure 1.9 shows a diagram of an IPv6 header.
IPv6 has been simplified, and the rarely used portions of the IPv4 header have been removed. The other big change is the huge addresses; IPv6 addresses are 128 bits long. That means that there are a total of 3.4x10 38 addresses available. That's 340 undecillion addresses, and when you haven't even heard of a number before, that means you've got enough addresses. But to further illustrate my point, I'm going to show you some more pointless calculations that illustrate the sheer size of the IPv6 address space.
The surface area of the earth, water included, is 5.1 x 10 14 meters squared. If you divide 3.4 x 10 38 by 5.1 x 10 14 , you get 6.6 x 10 23 . That means that there are around 660 sextillion IPv6 addresses available for every square meter of space on the planet . That ought to be enough for anybody until we decide to give IP addresses to every molecule on the planet. Or until we provide free Internet to the multiverse.
At any rate, there should be enough addresses for at least the next few hundred years, so we'll let programmers find more addresses when the time comes. For now, there are places on the Internet where you can obtain a block of a few millionor even billion IPv6 addresses.
The rest of the fields of an IPv6 header are pretty much the same as the important fields in IPv4, with updated names . They're not really important.
|[ LiB ]|