The Logic Used To Make Forwarding Decisions
Every device on the network maintains a routing table in memory. This table may be very simplistic, as would be the case with a low-end PC workstation, or very complex, as would be the case with a high-end router.
The table consists of pairs of IP addresses. "Where do you want to send to?" coupled with "Where do you really send to get there?". For example, a routing table may indicate that all frames destined for network 22.214.171.124 are to be sent to IP address 126.96.36.199. The immediate destination is always directly reachable; in this case we must be on network 188.8.131.52 and we trying to reach an ultimate destination on 184.108.40.206. The routing table provides a lookup for a device to tell it how to send frames.
There are two interesting exception cases. In the one case, the originating station concludes that the ultimate destination is, itself, directly reachable. In that case the frame will be forwarded directly to the destination IP address in the frame. It is not necessary to forward it to a router; the sender realizes that it is on the same subnetwork as the destination. In the other case the routing table doesn't have any matching lookup value when the masked destination address is compared against the available entries in the table. In this case a special address appears in the routing table called the Default Gateway Address. The pair of values in the table has "0.0.0.0" paired with an assigned DLC address of a router. This is the router to which frames will be sent when there is no other reference to the frames' destination in the table.
When making a routing decision the following steps are taken:
- Mask the destination IP address, mask your own IP address. If the results are the same then you are on the same subnet as the destination. Send the frame directly to the data link (physical) address of the destination.
- If the destination is not on the same subnet then check the routing table to see if the exact, complete, 32-bit destination address is specified. This is referred to as a Host Specific Route. If such a route is specified then forward the frame to the IP destination indicated in the table. The implication is that this destination is the next router in line on the way to the destination.
- If a Host Specific Route doesn't appear in the routing table then use the masked address that you computed as the lookup key against the routing table. That is, see if the network/subnetwork is specified in the table. If it is, then forward the frame to the IP address specified in the table. The implication, again, is that this is the IP address of the next router in line.
- If there isn't a Host Specific Route and there also isn't a reference to the network/subnetwork then forward the frame to the address specified as the target for the Default Gateway.
- If there is no default gateway specified then assume that all unspecified destinations are directly reachable. Resolve the physical address of the destination IP station and forward the frame directly to the destination. This is sometimes referred to as activating "Proxy ARP" which will be discussed in more detail later.