Difference between routing and forwarding table
Solution 1:
Routing is the decision over which interface a packet is to be sent. This decision has to be made for locally created packets, too. Routing tables contain network addresses and the associated interface or nexthop. This refers to ip route
and ip rule
(in a Linux context).
Forwarding refers to packets which reach a system but are not destined for this system. Forwarding is a decision of the system: "I take the packet and try to get it towards its destination." Instead of just dropping it. "forwarding" is a common term in the context of packet filters. Linux' Netfilter has three chains in its base table: INPUT, OUTPUT, and FORWARD. This chain just makes the decision "Shall this packet be forwarded or dropped?" (if forwarding is generally enabled on the system; Linux again: /proc/sys/net/ipv4/ip_forward).
Solution 2:
On most systems -- those with a single network connection -- they will be the same. On a router, however, they will tend to be different.
The routing table holds all the routes a router learns from its peers and neighbors using a dynamic routing protocol such as OSPF or BGP. Each route gets sorted and evaluated, based on the parameters of the routing protocol in use, and the subset of routing table entries that are 'best' are put into the forwarding table. When the router receives a packet, it looks up the destination address in the forwarding table to decide which interface to sent the packet out via, and what the next-hop address should be. As new routes are learned, interfaces brought up or down, or policy changes made to the ranking scheme, the routing table is reevaluated and the forwarding table updated.
Routing tables are typically stored in RAM; forwarding tables on high-performance gear will be distributed across line cards (in modular systems), and is stored in higher-speed TCAM. There is typically a finite number of routes that can be held in TCAM; when the forwarding table exceeds TCAM capacity, packets may be dropped, or routed in software (which is significantly slower).
Solution 3:
First of all, in my point of view, I think you should first clearly understand the distinction between forwarding and routing, which is often neglected. According to the book Computer Networks in page 240 by Lary L.Peterson, forwarding is a series of actions the router will take once receives a packet, including looking at its destination address, consulting a table, and sending the packet in a direction determined by that table. However, routing here refers to the process by which the forwarding tables are built.
Returning back to the original question, we can draw the conclusion that although we can keep a forwarding table and a routing table in the same structures, there are many reasons to separate them. A forwarding table usually needs to be structured to optimize the process of looking up an address when forwarding a packet, which holds more information such as MAC address. In contrast, the routing table usually focuses on calculating changes in topology, and the entries in routing table are usually more succinct, only including the IP of next hop.