The path choice for the packet is the basic function of the router. The router ever selects the best path for packet sending. For selecting the best path router searches its routing table information for a network address that matches the packet destination IP address. The router selects the best route with the following three results.
Directly connected network
The directly connected routes are always the best path to any subnet. If the destination IP address of the packet belongs to directly connected device that is on the same network to one of the interfaces of the router and connected to this interface, and the packet directly forwarded to the destination device. The directly connected network is the host address on the same network as the interface of the router. The administrative distance of the directly connected network is 0. When an IP address is configured to an interface of the router, the router will automatically create a directly connected route in its routing table. The figure below illustrates the directly connected routes and remote routes. If we see the Router1, where host1 and Fa0/0 of Router2 are a directly connected network for Router1 and remaining all network is the remote network for Router1.
If the packet’s destination IP address is not on the same network with an interface of the router; so, this is a remote network. If the destination address is on the remote network then the router forward packet to another router connected to the current router. The packet for remote networks reached to the destination through the router to router. For complete process consult my earlier article Packet sending over a routed network.
No route determined
If the destination IP address of the IP packet not belongs to the directly connected or remote network; then the router determines for the Gateway of Last Resort. A Gateway of Last Resort is a route using the router when no other known route exists to send the IP packet. The Known routes are present in the routing table. Therefore, any route not known by the routing table forwarded to the default route. If there is a default route, the router forwards the IP packet to the default route (Gateway of Last Resort). If the router does not have a default route, then the router discards the packet. The default route is 0.0.0.0.
The router determines the best path for sending a packet by assessment of multiple paths to the same destination network and selecting the best and shortest path. In the case of multiple paths to the same destination network, each path uses a different exit interface on the router. The router selects the best path using a protocol based value or metric to calculate the distance to the destination network. The lowest metric value is the best Path to the destination network. Dynamic routing protocols use their own rules and metrics to build and update routing tables.
The algorithm of the protocol generates a metric, for each path through the network. Metrics can be based on a single characteristic or several characteristics of a path. Some routing protocols select a route on multiple metrics, combining them into a single metric. Some examples of routing protocol are Routing Information Protocol (RIP), Open Shortest Path First (OSPF) and Enhanced Interior Gateway Routing Protocol (EIGRP). The RIP is using hop count and OSPF is using Cisco’s cast based metric on available bandwidth. The EIGRP is an example of multiple metrics type which uses bandwidth, delay, load, and reliability. The video demonstrates the difference between hop count and bandwidth metric.