Conceptually IP routing is pretty straight forward, especially when you look at it from the hosts point of view. If the destination is directly connected such as a direct link or on the same Ethernet network then the IP datagram is simply forwarded to it’s destination. If it’s not connected then the host simply send the datagram to it’s default router and lets this handle the next stage of the delivery. This simple example illustrates most scenarios.
The basis of IP routing is that it is done on a hop-by-hop basis. The Internet Protocol does not know the complete route to any destination except those directly connected to it. IP routing relies on sending the datagram to the next hop router – assuming this host is closer to the destination until it reaches a router which is directly connected to the destination.
IP routing performs the following –
I) Searches the routing table to see if there is a matching network and host ID. If there is the packet can be transferred through to the destination.
II) Search the routing table for an entry that matches the network ID. It only needs one entry for an entire network and the packet can then be sent to the indicated next hop.
III) If all other searches fail then look for the entry marked – ’default’. The packet then is sent to the next hop router associated with this entry.
If all these searches fail then the datagram is marked undeliverable. In reality most searches will fail the initial two searches and be transferred to the default gateway which could be a router or even a proxy site which forwards to the internet.
If the packet cannot be delivered (usually down to some fault or configuration error) then an error message is generated and sent back to the original host. The two key points to remember is that default routes can be specified for all packets even when the destination and network ID are not known –like this.
The ability to specify specific routes to networks without having to specify the exact host makes the whole system work – routing tables thus contain a few thousand destinations instead of several million!!