A router connects two networks together, forming an internetwork. Unlike bridges and switches, routers function at the network layer of the OSI reference model. This means that a router can connect LANs that run completely different data-link layer protocols (such as Ethernet and Token Ring), as long as all of the systems are running the same network layer protocol. Transmission Control Protocol/Internet Protocol (TCP/IP) is the most popular protocol suite in use today, and IP is TCP/IP's network layer protocol, so most of the router information you come across refers to IP routing.
When a computer on a LAN wants to transmit data to a computer on another LAN, the system sends its packets to a router on the local network and the router forwards them to the destination network. In many cases, the destination system is not located on an adjacent network, so the router has to forward the packets to another router. On a large internetwork, such as the Internet, packets may have to pass through a dozen or more routers on the way to their destination.
The term router always refers to a hardware or software device that connects two LANs at the network layer. In TCP/IP parlance, however, routers are often referred to using the term gateway. For example, when you configure the TCP/IP client on a Microsoft Windows system, you supply the address of a default gateway, which is actually a router on the local network that the system uses to access other networks. Unfortunately, gateway can also be used to refer to a hardware or software device that operates at the application layer to provide an interface between two programs. For example, an e-mail gateway enables people using one particular e-mail system to send messages to people using another e-mail system. Don't confuse the two.
Because routers operate at the network layer, they transcend the limitations of the data-link layer protocols. Packets arriving at the router travel upward through the protocol stack to the network layer and, in the process, the data-link layer frame is stripped away. Once the router determines where to send the packet, it passes the data down to a different network interface, which encapsulates it within a new frame for transmission. If the two data-link layer protocols involved support different-sized packets, the router might have to fragment the network layer data and create multiple frames that are small enough for transmission.
Routers are more selective than hubs, bridges, and switches about the packets they forward to other ports. Because they operate at the boundaries of LANs, routers do not forward broadcast messages, except in certain specific cases. A router forwards a packet based on the destination address in the network layer protocol header, which specifies the packet's ultimate destination, and not the hardware address used at the data-link layer. A router has an internal table (called a routing table) that contains information about the networks around it, and it uses this table to determine where to send each packet. If the packet is destined for a system on one of the networks to which the router is connected, the router transmits the packet directly to that system. If the packet is destined for a system on a distant network, the router transmits the packet across one of the adjacent networks to another router.
Consider, for example, a typical corporate internetwork composed of a backbone and several segments connected to the backbone using routers, as shown in Figure 3.6. The computers on each segment use the router connecting it to the backbone as their default gateway. The computers transmit all of the packets they generate to either a specific system on the local network or the default gateway. The default gateway router strips the data-link layer frame from each packet and reads the destination address from its network layer protocol header. Using the information in its routing table, the gateway determines which router it must use to access the network on which the destination system is located. The gateway then constructs a new frame for the packet, using the backbone's data-link layer protocol (which can be different from the protocol used on the segment) and specifying the router leading to the destination network as the data-link layer destination address. When the packet reaches the next router, the process repeats itself, except that this router's table indicates that the destination system is on the segment to which the router is attached. The router can therefore construct a frame that transmits the packet directly to the destination system.
When the packet has to pass through multiple networks on the way to its final destination, each router that processes it is referred to as a hop, as shown in Figure 3.7. Routers often measure the efficiency of a given path through the network by the number of hops required to reach the destination. One of the primary functions of a router is to select the most efficient path to a destination based on the data in its routing tables.
Figure 3.6 In a typical internetwork configuration, the routers are responsible for directing the packets to their next interim destination
Figure 3.7 The distance between the two end systems in an internetwork connection is often measured by the number of hops (or routers) between them, so in this case, system A is six hops away from system B
In addition to connecting networks at a single location, such as a corporate internetwork, routers can also connect distant networks using WAN links. Organizations with multiple branch offices often connect the networks in those offices by installing a router at each location and connecting the routers together using leased telephone lines or some other WAN technology, such as frame relay. Because each location has a separate broadcast domain, the only packets that pass over the WAN links are those destined for systems on the other networks. This minimizes the amount of traffic passing over those links (even more than a bridge), thus minimizing their cost.
The most common use for a WAN router is connecting a network to an Internet service provider (ISP), providing the computers on the network with access to the Internet. The Internet is the ultimate example of a routed network; thousands of LANs are connected together using many different kinds of routers. To connect your LAN to the Internet, you install a router that can connect to an ISP using any type of link, from a dial-up modem to Integrated Services Digital Network (ISDN) to a leased line. The router is configured to forward all traffic not destined for the local network to the ISP, which relays it to the Internet.
The routing table is the heart of a router; without it, there's no way for the router to know where to send the packets it receives. However, the question then becomes where the routing table comes from. Unlike bridges and switches, routers cannot compile routing tables from the information in the data packets they process. This is because the routing table contains more detailed information than is found in a data packet, and also because the router needs the information in the table to process the first packets it receives after being activated. A router can't forward a packet to all possible destinations the way a bridge can.
However, the process of building the routing table can still be either manual or automatic. Static routing is the process of creating routing table entries manually. A network administrator decides what the router should do when it receives packets addressed to systems on a particular network and adds entries to the routing table that reflect these decisions. You can perform this process on a relatively small network with a handful of routers, but on a larger network, the manual configuration process is too much work and the routers are unable to modify their table to accommodate changes in network status.
The alternative to static routing is dynamic routing, in which routers use specialized protocols to exchange information about themselves and the networks around them. Routers have direct information about the LANs to which they are connected, and they use routing protocols to send that information to other routers. When the routers on an internetwork share the contents of their tables using these protocols, all of the routers can have information about more distant networks as well.
There are many different routing protocols, particularly on the Internet, where routing is one of the most complex and vital parts of the internetwork infrastructure. Dynamic routing requires no direct participation by network administrators, other than installation and running the routing protocols, and it also enables routers to automatically modify the information in their tables when the network changes. For example, if a router malfunctions, all of the routers that normally communicate with that router remove it from their tables after a given period of time. Those routers then inform others of the malfunction, and the entire network eventually stops trying to use that router. When the offending router is put back into service, the other routers update their tables and begin to use it again.
For more information about routing tables, routing protocols, and specific IP routing practices, see Chapter 9, "TCP/IP Routing."
Part of a router's function is to select the most efficient route to each packet's destination. On a relatively small internetwork, such as the one pictured in Figure 3.6, there is only one possible route to any particular destination. However, on a more complex network, administrators often install more than one router on each network to provide alternate routes in case of a malfunction. When multiple routes to a particular destination exist, routers include all of them in their routing tables, along with a value called a metric that specifies the relative efficiency of each route. The nature of the metric depends on the routing protocol used to generate it. In some cases, the metric is simply the number of hops between the router and the destination network. Other protocols use more complex computations to determine the metric.
Most people think of routers as a large, complex devices costing tens or hundreds of thousands of dollars, used only on giant enterprise networks. Actually, routers can take many different forms and are far more common than you might think. It is true that many routers are large, powerful, and very expensive. Generally speaking, routers are more expensive than switches, bridges, and hubs. You can indeed find routers on large corporate networks, where they're mounted in racks in data centers and server closets. These routers connect segments to a backbone and provide an entire private internetwork with access to computers in their branch offices, the Internet, or both.
However, there are also much smaller and less expensive routers on the market. In fact, if you use the Internet Connection Sharing (ICS) feature in Microsoft Windows 2000, Microsoft Windows 98 Second Edition (SE), or Microsoft Windows Me to connect your home network to the Internet, you are actually using your computer as a router. Other software-based router products enable you to share dial-up, cable television network, and Digital Subscriber Line (DSL) connections with a small network. There are also relatively small hardware routers on the market that you can use for connecting a LAN to the Internet.
For private internetworking, you can use any one of many hardware routers across a range of prices, or use a Windows 2000 or Microsoft Windows NT system with two or more NICs installed in it to route IP traffic between networks. Every computer with a TCP/IP client has a routing table in it, even those that are not strictly functioning as routers. For example, when you use a computer on a LAN to connect to the Internet with a dial-up connection, the system uses its routing table to determine whether requests for network resources should go to the NIC providing the LAN connection or to the modem providing the Internet connection. Even though the system is not providing Internet access to the LAN, it still uses the routing table.
Run the Bridges_and_Routers video located in the Demos folder on the CD-ROM accompanying this book for a demonstration of the difference between a bridge and a router.
You are the network administrator responsible for a 10-Mbps Ethernet LAN that consists of 45 computers connected to three standard repeating hubs. In recent weeks, you've received complaints that the network's performance is diminished during certain hours of the day. When you monitor the network, you notice that traffic levels have increased substantially, as have the number of collisions occurring on the network. Having determined that this is the source of the problem, answer the following questions.