The main function of a router is to determine the path that packets should take in attempting to get from one network to another. A router will always have at least two physical interfaces, but depending on the model may have many more. For example, a router may have one Ethernet, one Token Ring, and one serial interface – each of which connects to a different network. By default, a router will know about the networks on which it has a configured interface, and will be able to forward packets between them. When a router doesn’t connect directly to a network, it needs to know where to forward a packet next – this would be another router, referred to as the next hop. Consider the very basic routing table shown below.
Basic routing table:
Network Interface / Next Hop
In the table above, we can see the following:
- Network 10.0.0.0 is connected to the Ethernet interface
- Network 172.16.0.0 is connected to the Token Ring interface
- Network 192.168.0.0 is connected to the Serial interface
- Network 184.108.40.206 can be reached by sending packets to IP address 10.0.0.2, the next router in the path to that network.
This doesn’t mean that network 220.127.116.11 is directly connected to the next router – in fact, a packet may be forwarded to many other routers on its journey. The only thing this particular router knows is that the next place to send the packet is the address 10.0.0.2 – once there, it’s up to that router to figure out where the packet gets forwarded to next.
Note that since it exists at Layer 3, a router is concerned with network (or logical) addressing. As such, a router doesn’t forward packets based on MAC address, but instead on the addressing of the routed protocol in use – for example IP, IPX, or AppleTalk. When a router receives a packet, it inspects the destination network address, and forwards the packet according to information found in its routing table. Ultimately the packet should reach the router that is connected to the destination network, where it will be forwarded to the destination host.
The actual communication process that takes place when two systems communicate over a network with routers is a bit more complex. Consider the figure below, where two hosts communicate through a single router.
In the example, Computer A needs to send a packet to Computer B using TCP/IP. Notice that Router 1 is connected to the two networks on which these hosts reside. The following steps outline the basic process that will take place in getting the packet from A to B.
- Computer A will first determine that Computer B is on a different network, based on the destination address. At the Network layer, it will add source and destination IP addresses to the packet. In this case, the source is the IP address of A, while the destination is the IP address of B.
- Given that Computer B is on a remote network, Computer A will need to forward the packet to the router, its configured default gateway. Before it can send the data to the router, it still needs to frame the packet. As such, source and destination MAC addresses need to be added. In this case, the source MAC address will be that of Computer A, while the destination address will be that of interface X on the router.
- Once the frame has reached the router, it will strip away the MAC addressing and pass the packet up to the network layer. At this point, the router will determine the route to the destination network using its routing table.
- Before sending the packet out interface Y, it will need to be reframed. The new source and destination MAC addresses must still be added. In this case, the source MAC address will now be that of router interface Y, while the destination MAC address will be that of Computer B.
Note that the source and destination IP addresses never changed in the example above. Striping away and recreating the MAC framing would have happened at each router had there been many in the path between Computers A and B. The process of route determination and reframing at each router is what makes routing approximately 30-40% slower than switching.
On a small network, you might manually define the next hop to each network in a router’s routing table. However, as an internetwork grows, this gets much more complex and also does nothing to account for network failures. On a large network, you’ll want routers to communicate with each other using routing protocols. Routing protocols allow routers to communicate with each other by dynamically exchanging information about the networks that they know about. In this way, routers ‘learn’ from one another. Examples of routing protocols include Routing Information Protocol (RIP) and Open Shortest Path First (OSPF). Routing protocols are particularly helpful when a network error occurs. If a network path becomes unavailable (say due to a router failure), a router will find out about it via routing protocol updates (or lack of) and will switch to using a redundant path if one exists. The details of how routing protocols function will be looked at in Chapter 8.
Routers are best known for providing multiple paths to different networks and connecting networks that use different technologies. However, they are also capable of controlling network traffic using features such as access lists. Access lists allow you to control which hosts can communicate with different networks, as well as the types of traffic that can move between networks. Access lists will be looked at in detail in Chapter 9.
Another important responsibility of a router is to act as a demarcation point between broadcast domains. By default routers do not pass broadcasts, thus acting as a barrier that stops broadcasts from overwhelming an internetwork. What is a broadcast domain? A broadcast domain defines the group of computers to which a broadcast will travel. In the figure below, a broadcast sent by Computer A will go to all computers in its broadcast domain. Computer B, who is part of a completely separate broadcast domain, will never see it. Notice that the router in the diagram is what separates the broadcast domains.
Tip: Remember that a router acts as a boundary between broadcast domains.