When a packet arrives on the router, the router identifies the destination path that packet should traverse by evaluating the prefix length as programmed in the Forwarding Information Base (FIB).
The Forwarding Information Base is programmed the routing table, also known in this context as the Routing Information Base (RIB).
The Routing Information Base contains the routes made up from the information gathered by the routing protocol processes that are on the local router.
When it comes to selecting the destination path, they are three main components: Prefix Length, Administrative Distance, and Metric.
The prefix length represents the number of leading binary bits in that subnet mask that are marked as ‘1’.
The administrative distance is a priority between multiple routing protocols where they have the same routing information. It is between 0 and 255 with the lower number being a preferred selection.
Metrics are used by each individual routing protocol as a measure of cost to reach a network. The lower this cost the more preferred the route will be.