IP Routing
The IP layer of end-system hosts and the routers work together to route a packet from source to destination. The IP layer of each host and router maintains a routing table that is used to decide to whom the packet is to deliver. Each row in the routing table must contain the following information:
Each time a packet is to be routed, the following operations are to be done in order:
i. The first column is searched to see whether the table contains an entry for the complete destination IP address. If found, the packet is sent according to the next-hop entry and G-flag.
ii. If the table does not contain a complete destination IP address, then the routing table is searched for the destination network ID. If found, the packet is forwarded according to the next-hop entry and G-flag.
iii. If the table does not contain the destination network ID, then the table is searched for a default router. If found, the packet is forwarded to it.
iv. If none of the above searches is successful then the packet is declared undeliverable and an ICMP host unreachable error packet is sent back to the source host.