IP routing is concerned with the choice of a path over which the IP datagrams, destined to a given host, are sent. And it is important to emphasize the word destination here. Even though there may exist advanced techniques that rely on attributes such as the source address, the classic definition of routing considers the destination address as the sole criterion for path selection.
The main tasks pertaining to the routing process are listed in the following:
- Gathering routing information: either manually (static routing) or with the use of dynamic routing protocols.
- Installing entries in the routing table: before installing a path in the routing table, two comparisons are performed by a Cisco router: if two equal length network prefixes are available to a destination, the router prefers the one with the lowest Administrative Distance (AD). For two equal length prefixes that have the same AD value, that with the lowest cost (from the perspective of the routing protocol in place) is chosen.
- Searching for the longest prefix match: when a packet arrives at the incoming interface, its destination IP address is extracted and compared with each entry available in the routing table. The comparison that results in the longest bitwise match for the network mask will be selected. (The last possibility of finding a match is to use a Default Route, if one is available).
- Forwarding the packet on the outgoing interface: when a match happens in step 3, it points to an entry in the routing table that has an associated outgoing interface. This last step includes the construction of the appropriate L2 header for this interface.
To simplify matters, I normally divide the IP routing process in two parts: building the routing table (control plane) and using the table to forward packets (data plane).
The figure below depicts a scenario in which the host 172.16.16.16 is using the routing services provided by the “blue” router to forward packets to the destination with address 192.168.1.200. After consulting its routing table, the router concludes that the intended host is reachable via its Ethernet1 interface (using R1 as the next-hop).
- The simplest routing case happens when the incoming and outgoing interfaces are directly connected to the same router. In this type of situation steps 1 and 2 are not necessary.
- When two routes to a given destination point to the same outgoing interface and have equalvalues for AD and cost, they are both installed in the routing table. In such a situation, load sharing takes place.