Login or Register

Forgot?
I'm new, register me!

What is OmniNerd?

100% of OmniNerd's content is generated by you, the reader. OmniNerd allows content of all sorts and highlights the nerdiest of what's around.

Want to know more? Check out our welcome page, or simply register and have a first-hand look.

Submit New Content

Voting Booth

Been a victim of a violent crime?

60 votes, 4 comments
3
Nerd-Its
+ -

Getting from A to B on the Internet: An Introduction to Routing

Layout article by markmcb on 19 December 2004, tagged as computing, internet, and networking

Have you ever wondered how all of that data you request on the Internet pops up on your screen with the click of a mouse? How is it that a little humming box in Chicago manages to send all of the information stored on OmniNerd to locations all over the globe in fractions of a second? This article will take you on a journey from a web server to requesting client and show you just how all of that data gets to your computer. Hopefully, the examples coupled with the sources provided will be more than enough to expand your understanding of a simple concept known as routing.

The Basic Pieces of a Network

Before we dive into the pool of ones and zeros, let us first lay out the physical pieces of the network we are going to consider. Our network will consist of five major components. All five will be briefly described in the following paragraphs. See figure 1 for the graphical symbols that will be used to represent these five pieces of hardware throughout this article.

Figure1

Figure 1. Graphical symbols for network hardware.|border

First, we have the cables and wires that are used to connect the various pieces of network hardware. This article will not go into the details of the various transfer media. Instead, everywhere you see something connected by a line in our network, you can assume that the appropriate media is being employed to ensure that data signals are getting from one end to the other.

Second, you have the network interfaces. These are the pieces of hardware to which the cables and wire connect. An example of a network interface is the network card in your computer to which your Internet cable connects. These interfaces handle how data goes on and off of the cables to which they are connected.

Third and fourth are the client and server. The client is simply the computer requesting data from the Internet. The server is the computer providing the data. A perfect example is your computer when you request the web page http://www.omninerd.com/. Your computer is the client because it is asking for the data that makes up that particular web site. On the other end is another computer with a slew of data files on it that is OmniNerd.com, also known as the server. The server can feed files to several clients, and a client can request data from several servers. This will all be explained in detail later.

Last, and probably the most important pieces, are the routers. Routers receive data on the network, analyze it, and then decide where it needs to go. These pieces of the network will be the focus of this article.

Step 1: Making Hardware Talk to Hardware

The first thing we must do if we ever want to send or receive data across a network is have a way to make one piece of hardware talk to the next. Obviously the cables and wires do no processing, so the first pieces of hardware that we will consider are the network interfaces. Network interfaces are found on all of the other three major hardware items that we have discussed thus far: client computers, server computers, and routers. As mentioned earlier, these interfaces send and receive data over our cable and wire media.

Figure2

Figure 2. Diagram of Connected Network Interfaces.|border

Figure3

Figure 3. Actual Network Interface.|border

So now that we have two pieces of silicon and metal tied together by some wires, how do we get them to talk to each other? This is done through the use of a Local Area Network address, or LAN address (also known as a physical address, Ethernet address, or MAC address). This address is specific and unique to only one interface. It is a sort of serial number that the interface uses to uniquely identify itself when talking to other interfaces. LAN addresses take the form of 12 base-16, or hexadecimal, digits often listed in pairs of two. An example of a LAN address would be: 00-04-3e-d8-91-af. If you are not familiar with hexadecimal notation, visit any of a number of on-line tutorials for a quick class.1

To put this address in perspective, you have one assigned to the network card that you are using to access this page. It is quite simple to locate your LAN address. In Windows, open a command prompt and type ipconfig /all. You should see a line labeled “Physical Address” with your LAN address listed out to the right. In a Unix, Linux, or OS X environment, open up your favorite terminal shell and type ifconfig. You will find a line labeled “ether” and with your LAN address formatted as 00:04:3e:d8:91:af.2

It’s worth noting that many of today’s computers have more than one network interface. The standard layout for most computers is one wireless interface and one wired interface. Both of these interfaces will have their own unique LAN address so don’t be confused if you run one of the commands mentioned and find multiple LAN addresses.

Putting Your LAN Address to Work

Since we know each individual network interface has an address, we now need to know how connected interfaces are able to become aware of neighboring network interfaces’ addresses.

First let us discuss the scope of a LAN address. LAN addresses are only visible to network interfaces that are directly connected to each other. This may be a bit confusing at first because “directly connected” is not limited to meaning two interfaces connected by one cable. Two pieces of hardware that commonly exist on a LAN are switches and hubs. Though both pieces allow you to plug cables into them, neither have network interfaces in them.3 This is best illustrated by an example.

Let us say you have three computers in your house that you want to connect for some networking need. Obviously, you are not going to be able to run one cable between all three computers.4 To overcome this barrier, switches and hubs are available to provide a means by which to connect more than two computers. From the computers’ perspectives, switches and hubs do not exist. All the computers see are the other network interfaces that are plugged into the switches and/or hubs. For the computers, it’s as if one cable was connecting them all together.

I will not go into detail about switches or hubs. It is worth noting though that a hub is a dumb physical device. When you send a signal into one port on a hub, it gets sent out on all other ports, even the ports that do not have the signal’s destination on it. A switch is slightly smarter and remembers which network interfaces are connected to each port. This way when a signal goes through the switch, it is only transmitted out on the port that has the destination interface on it. Switches cut down on signal interference and provide you with a better overall performance on your network. But as far as the network interfaces are concerned, hubs and switches are just pieces of the physical media, thus the interface does not have to communicate with them.

So now that we understand that all network interfaces have unique addresses and connect to each other using cables, switches and hubs, it is quite easy to understand how interface A sends a message to interface B. Interface A simply takes the data that is to be sent, packages it into what is called a “frame,” and adds a header that includes the LAN address of B. Once interface A pushes the frame of data onto the network, it travels through whatever wire, hubs, or switches in encounters and arrives at one or more destinations. Each destination then examines the frame of data to see if the header information includes its LAN address. Obviously, only interface B will have this address and accept the frame. All other interfaces will discard the frame of data.5

Computers on a LAN are much like people in a neighborhood. If I need to get a message to my neighbor, I do not need to put a letter in the mail to be routed through the postal service. I know where my neighbor lives, and I know that all I have to do is write my message and put it in his mailbox. That’s all there is to it. The one piece we’ve yet to discuss though, is how do we meet our neighbors? In our neighborhood example, we would probably know that we have new neighbors when we see the moving van sitting in the driveway of the house across the street. But how do computers, specifically network interfaces, know when a new computer has been plugged into the LAN?

Address Resolution Protocol, or ARP, is the most common way that network interfaces on a LAN learn about each other’s existence. When you tell your computer to communicate with another computer, your computer gives your network interface a packet of data with the address of the destination computer. Now the address your computer uses is known as an IP address and will be discussed later in detail. For now, all we need to know is that the computer knows other computers by using IP addresses and network interfaces know other network interfaces by using LAN addresses. In order for your network interface to know the LAN address of the network interface the destination computer is using, ARP is used.

Let us say that your computer’s IP address is 192.168.0.102 and you are trying to send data to a computer on your LAN with the IP address 192.168.0.103. Your computer tells its network interface that it needs to send data to 192.168.0.102. Your network interface immediately pulls up its ARP table that looks something like this:6

? (192.168.0.1) at 00:40:05:c7:4f:ab on en0 [ethernet]
? (192.168.0.104) at 00:05:5d:25:fd:fb on en0 [ethernet]
? (192.168.0.255) at ff:ff:ff:ff:ff:ff on en0 [ethernet]

Looking at this table we find IP addresses and their associated LAN addresses. Your computer looks for 192.168.0.103, but doesn’t find it. Before giving up, your computer sends out a broadcast ARP frame that goes to every computer on the LAN. This frame asks all other network interfaces to look at the IP address stored in the frame and decide if that IP address belongs its respective computer. If it does, then the network interface should respond with its LAN address. So your computer essentially yells out on the network, “hey, anyone out there attached to a computer that goes by 192.168.0.103?”

For this example, we’ll assume that the computer with the 192.168.0.103 address just got plugged in and exists on the LAN. So of course this computer’s network interface pushes a frame onto the LAN that essentially says, “Yeah, I’ve got 192.168.0.103 and my LAN address is 00:0d:93:ed:dd:fb.” After receiving this reply, your network interface immediately updates its ARP table so that it reads:

? (192.168.0.1) at 00:40:05:c7:4f:ab on en0 [ethernet]
? (192.168.0.103) at 00:0d:93:ed:dd:fb on en0 [ethernet]
? (192.168.0.104) at 00:05:5d:25:fd:fb on en0 [ethernet]
? (192.168.0.255) at ff:ff:ff:ff:ff:ff on en0 [ethernet]

Now, every time your computer wants to talk to 192.168.0.103, your network interface knows that it will be sending and receiving data from the network interfaces with the LAN address 00:d:93:ed:dd:fb.

Figure4

Figure 4. Network Interface Communicating.|border

Step 2: Making Computers Talk to Computers

So now that we know how to make network interfaces on a LAN talk, we need to consider the next step, which is how to make computers talk to each other on LAN. As we briefly mentioned before, computers have addresses known as “IP Addresses.” IP stands for “Internet Protocol.”7 Almost every network that is active today and used in conjunction with the Internet is based on the IP networking and addressing scheme. For a computer to be able to communicate with other computers on an IP network, the computer must have an IP address. We will not go into the details of how addresses are assigned, but we will discuss a few of the basics.

Figure5

Figure 5. Separate Addresses for Computers and their Interfaces.|border

The first thing you must understand when looking at an IP address is what they are numerically. An IP address is usually shown divided into four octets: 111.222.333.444. The reason they are called octets is because the computer sees them as four sets of eight binary 1’s or 0’s: 11111111.00000000.11110000.00001111. Since you can only have eight binary 1’s or 0’s, the highest any one octet can ever be is 255. Therefore, a valid IP address will always have four octets, each with a value ranging from 0 to 255. So if you ever see something like: 423.918.3211.-3, you’ll immediately know that all four of those octets are invalid, thus making the entire address invalid.

The second thing you must understand when dealing with IP address is how to read them. In general, an IP address can be viewed as III.III.III.NNN. The numbers that fill in the “I” slot are the numbers that uniquely define what portion of the Internet a computer is on. The numbers that fill in the “N” slots are the numbers that uniquely define a node or a computer on that portion of the Internet.8 For example, I use Adelphia for my cable Internet service. My cable router (we’ll talk about routers in detail later) plugs directly in to the Adelphia network. At the time of writing this, my IP was 24.55.104.17. What this means is that Adelphia probably owns all of the addresses starting with 24.55. They have specifically assigned the segment of the network in my area with addresses that start with 24.55.104. There are certain to be several others, but this is the segment that I’m currently on. My cable router has been assigned the address 24.55.104.17. The 17 is the only part that is really specific to my router. The rest of the numbers define the network.

Unlike network interfaces, IP addresses are not always unique. For example, if your computer is plugged into a router that plugs into your cable or phone line, your IP address is probably 192.168.XXX.XXX. Nearly every computer on a LAN that is behind a cable or DSL router assigns the computers that plug into it addresses starting with 192.168. These addresses are reserved for LAN use. So, while my computer currently has the address 192.168.0.102, your computer may have the exact same address. If your computer is not plugged into a router, but has a network card, your IP address is most like going to be 169.254.XXX.XXX. This is another set of reserved IP addresses that computers usually auto-assign themselves when there is no other entity like a router on the network assigning IP addresses.

Basic Routing

Now that we’ve gotten all of this IP address stuff out of the way, let us look at how IP addresses are used to get data from one computer to the next. Much like the network interface used an ARP table to decide where a frame needed to go, computers and routers use routing tables to decide where IP packets should go on a network. If you go to your Windows command prompt and type “route print”, or from your Unix, Linux, or OS X environment type “netstat –rn”, you will see your computer’s routing table. It should look something like:

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.0.1        UGSc        8       78    en0
127                127.0.0.1          UCS         0        0    lo0
127.0.0.1          127.0.0.1          UH         47   725209    lo0
169.254            link#1             UCS         0        0    en0
192.168.0          link#1             UCS         1        0    en0
192.168.0.1        0:40:5:c7:4f:aa    UHLW        9     1128    en0   1083
192.168.0.102      127.0.0.1          UHS         0        4    lo0

Despite the fact that your computer does much more than route packets, it is the first router that handles the sending of IP packets onto the network. This table allows the computer to figure out where it should send its IP packets. For every packet sent, a computer has two choices: send it directly to the destination, or send it to a router that can get it there.

Let us reconsider our previous scenario where we were trying to send a packet to 192.168.0.103. Prior to sending the packet, the computer will look in its routing table to see to whom the packet should be addressed. In the table above, the computer will go line by line until it finds a rule that matches the destination. Obviously neither 192.168.0.102 nor 192.168.0.1 match our destination, but what about the next entry. The next line lists 192.168.0. Now, we know that this isn’t a complete address, so what does it mean? This rule is saying that, if you are trying to send something on the 192.168.0 network, all you need to do is send the information out on link#1 (which is our network interface) and it will reach its destination, if the destination exists. This is exactly what we need, so we hand the data off to the network interface telling it to send to 192.168.0.103. The network interface does its ARP work and the packet is successfully delivered.

Figure6

Figure 6. Connected Computer Systems.|border

Step 3: Making Computers Talk to Computers Over the Internet

So far we have not sent any data outside of our LAN. This is a good start, but if we want to get data from our favorite web sites like OmniNerd, our packets must leave the LAN. To go back to our neighborhood analogy, we now need to get a note to a friend of ours who does not live in our neighborhood. Rather than physically traveling to our friend’s location to deliver our note, we simple put it in an envelope, drop it in the mailbox, and wait for a reply. Once we put the note in the mailbox, the postal service becomes responsible for delivering our message. The Internet is quite similar. When we push a packet off of our LAN and on to the Internet, we put our trust in the hundreds of routers that comprise the backbone of the Internet to get our data from our computer to its destination.

The first step is to get the packet off of our LAN and onto the Internet. Let us reconsider our routing table:

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.0.1        UGSc        8       78    en0
127                127.0.0.1          UCS         0        0    lo0
127.0.0.1          127.0.0.1          UH         47   725209    lo0
169.254            link#1             UCS         0        0    en0
192.168.0          link#1             UCS         1        0    en0
192.168.0.1        0:40:5:c7:4f:aa    UHLW        9     1128    en0   1083
192.168.0.102      127.0.0.1          UHS         0        4    lo0

Let us say that we want to talk to the OmniNerd web server that has an address of 66.113.130.190. As we start from the bottom and work our way up, we find that none of our numeric listings match our destination. We’re left with only one choice that is labeled “default.” This default option is known commonly as the “default gateway.” A default gateway is the path a packet will take if none of the other rules in the routing table are useful. By using the default gateway your computer is saying, “I don’t know where the destination computer is, but I’ll ask someone who does.”

In this case, our default gateway is the cable router that we have plugged into the wall. This cable router is the first step out onto the Internet. Once we hand our packet to the router, the whole process is repeated. The router has a routing table as well and it uses it to determine where to send the packet. If it knows where the destination computer is, it will send to packet to it. If not, it will send it to a router that can. This process will repeat until the packet gets to its destination.

Figure7

Figure 7. Connected Computers with a Router for a Default Gateway.|border

Step 4: Routing Basics

It must be noted that the last section was extremely over-simplified. As we looked at routers and routing tables, we just took for granted that all of the information in the routing table existed. The fact of the matter is that in most every router on Internet, the routing table is constantly being updated with new information. For example, let’s say that some router out on the Internet is connected to three other routers. What happens when one of those other routers goes down for whatever reason? The routing table undoubtedly had a rule for certain traffic to go through the router that just died. Somehow, and quickly, the existing routers must decide how they are going to modify their routing tables and get their data where it needs to go.

Distance Vector Algorithms

One way that routers figure out what paths to send data on is through the use of “distance vectors.” In simple terms, a router creates a distance table for each destination on a network. Let us consider the network in figure 8. If node E wants to build a distance table, it will first decide what the cost9 is to send packets to each of its adjacent nodes: A, B, and D. To have a complete table, node E must ask each node its connected to what its lowest cost is to send packets to node C. Once node E gets a response, it adds the cost between itself and that node to that node’s cost to send to C. Once the distance table is created for each destination on the network, node E can send data out on the shortest distance vector. In this case, E would find that D only has a cost of 3 to send to C. That cost added to the cost of 3 to send from E to D gives the lowest cost path, which is 6.10

Figure8

Figure 8. A Group of Routers and the “Costs” of the Paths Between Them.|border

Link State Algorithm

Another way to decide a path is by determining “link states.” This determination is made when each node finds out what the lowest cost is to get to every node in the network. Basically, a single node will determine the cost to get to all adjacent nodes. Then, the node will ask each adjacent node what the cost is for it to get to all of its adjacent nodes. This process continues. In the network above in figure 8, node E would note that the cost is 8 to talk to node B. This would be stored in a table as the shortest path to B until node A reported that it can talk to B with a cost of 6. When E realizes that the cost of 2 to talk to A plus the 6 to get from A to B, E will write in its table to send all packets destined for B through A since the cost is only 8, 1 cost lower than sending traffic directly between E and B. This continues until node E knows which router to send data to for all destinations in the network.11

There are advantages and disadvantage to each of these algorithms but the details are beyond the scope of this article. A comparative study will show that neither algorithm has a strong advantage over the other, and that each is slightly better suited for certain types of networks. It is also worth noting that these two types of algorithms account for nearly every routing algorithm in use on the Internet.

Changing Names to Numbers

One technology that is worth noting is DNS, or Domain Name Service. DNS has nothing to do with routing, but it will help you to understand the big picture of how the Internet works. Let us consider the case in which a person opens their favorite web browser and types in “www.omninerd.com”. As we discussed earlier, the only addresses that computers and routers know are IP addresses. So how is it that this person’s web browser is able to communicate with the OmniNerd web server and get data?

The answer lies in DNS. When a user types in an address using words and not numbers, a program on the user’s computer queries the nearest DNS server and asks if it has an IP address associated with the name. If that DNS server doesn’t know, it asks the next higher DNS server. This continues until the master DNS server is queried. If it doesn’t know, then the name is not registered and the user will get an error. If the name is registered, the IP address will be returned to the client’s computer and it can begin communicating with the remote computer using its IP address.

You can try this out in Windows by running the nslookup command, or in Unix using the dig or host command. Running “host omninerd.com” will result in the following output:

omninerd.com has address 66.113.130.190

Now your computer knows that when you type “omninerd.com” you really mean “66.113.130.190”. Given this information, your computer is ready to start talking to the OmniNerd web server. See figure 9 to help understand where everything is in relation to everything else.

Figure9

Figure 9. Simplified View of the World Wide Web.|border

Conclusion

Hopefully this has given the non-geeks some insight into how the Internet works while at the same time providing a refresher for all of the uber-nerds out there. There are hundreds of great sites and books that discuss in detail everything I have mentioned above if you are curious. If you are a serious Internet user like me, you’ll find that knowing a few of the basics will save you much time and money in the long run. Happy surfing.

Notes

  1. Selvia, John. “Hexadecimal.” The Art and Tech of John Selvia. Accessed 29 November 2004 from http://www.johnselvia.com/hex1.html. This is just one of many hexadecimal references, but I found this one goes into more detail than most.
  2. You should be aware that both ifconfig and ipconfig are commands whose output may vary between versions. If you find that your respective command isn’t working, then you probably have either an older system, or a system with a new command that was written after this article. See your operating systems documentation for more details.
  3. Some switches do have network interfaces in them, but they tend to be extremely high-dollar switches and are not something you would have in your house. Unless of course you are a super-geek.
  4. This entire article assumes the use of CAT-V cable and RJ-45 connecters.
  5. With certain software applications, it is possible to put a network interface in a mode that allows it to see all packets that come to it, even if they are not addressed to that interface. This technique is known as “sniffing.” So if you’re on a large LAN at work, and your computer goes through any number of hubs, beware! Everything you send and receive can be seen by a user with sniffer software installed.
  6. There are various outputs for ARP that depend on the system you are using. This ARP table was produced by running "arp -a" on a PowerBook G4 running Apple OS X (10.3) using ARP from 4.3 Berkeley Distribution, June 6, 1993.
  7. The Internet Protocol that I will focus on is version 4, which is defined in RFC 791. There are plans for the Internet to switch to IP version 6 in the near future. All IP addresses in this article will be version 4.
  8. This is admittedly a very rough overview of IP addressing. A thorough explaination of how the actual addressing works can be found at: http://www.webopedia.com/DidYouKnow/Internet/2002/IPaddressing.asp. Information about how addresses are managed can be found at: http://www.icann.org/.
  9. Cost can be defined as any of a number of things. Usually the least cost is the path that gets the data to its destination the quickest without errors. Things that improve cost are distance traveled, speed of hardware in the path, etc.
  10. Kurose, James E. and Keith W. Ross. Computer Networking. (Boston: Addison Wesley, 2001), 286. This is a summary of a detailed explanation of the distance vector algorithm.
  11. Ibid, 282. This is a summary of a detailed explanation of the link state algorithm.

Discuss this Article Discuss this Article
25 comments

Have an opinion, a question, or correction? Leave comments for this article in the discussion area.