In computer networking, routing is the process of receiving a packet on one interface of a router, validating the packet, and (assuming the router knows that a particular outbound interface will move the packet one hop closer to its final destination) forwarding it out that interface. Routing may be compared to driving to a destination along a set of highways. Each exit sign informs the driver of a set of destinations reachable through that exit. The driver will decide to take the exit if it goes toward the destination, or will continue looking for a better exit.
The process that draws the "map" of the network, or, in the highway analogy, puts the list of destinations on the exit sign, is the control plane of the router. The process that actually moves the packet from input to output is the forwarding plane.[1] The device that performs these functions is called a router.[2] Physically, a router is usually a special-purpose computer, although it is possible to program a personal computer to route.
Both in Internet Protocol version 4 and Internet Protocol version 6, the most basic principle of routing is "longest prefix match." Every Internet Protocol address has a certain number of bits, from the left, which form its prefix or locator, describing the target network or group of networks in which it resides. Unless other factors override, routing forwards a packet towards its best knowledge of the most precise specification of that destination. That knowledge is in a forwarding information base, created by the router's control plane. If, for example, there are two routing table entries, one matching the first 8 bits of the address and the second matching the first 16 bits, the second entry will prescribe the next hop for the routing operation.
The control plane learns the connectivity and reachability of the router, stores it in a routing table from which it generates the forwarding information base.