Routers and Routing
As you already know, routing is the process of getting your data from point A to point B. Routing datagrams is similar to driving a car. Before you drive off to your destination, you determine
which roads you will take to get there. And sometimes along the way, you may change your mind and alter your route.
The IP portion of the TCP/IP protocol inserts its header in the datagram, but before the datagram can begin its journey, IP determines whether it knows the destination. If it does, it sends
the datagram on its way. If it doesn’t know and can’t find out, IP sends the datagram to the host’s default gateway.
Note:
One key to understanding some of the original Internet documents, as well as some of the legacy terminology, is to realize that every router in the Internet was once referred to as a gateway. Therefore, a default gateway is really a default router.
Each host on a TCP/IP network can have a default gateway, an off-ramp for datagrams not destined for the local network. They’re going somewhere else, and the router’s job is to forward
them to that destination if it knows where it is. Each router has a defined set of routing tables that tell the router the route to specific destinations.
Because routers don’t know the location of every IP address, they have their own default gateways that act just like any TCP/IP host. In the event that the first router doesn’t know the
way to the destination, it forwards the datagram to its own default gateway. This forwarding, or routing, continues until the datagram reaches its destination. The entire path to the destination is known as the route.
Datagrams intended for the same destination may actually take different routes to get there. Many variables determine the route. For example, overloaded routers may not respond in a
All TCP/IP Devices Route
Technically, end devices and routers both work similarly when deciding what to do with an IP packet. In fact, any packet that leaves one of these devices toward a destination does so because the transmitting device knew what to do with it, even if it is sent out to the default gateway address. The default gateway is actually a statically or dynamically learned route entry, just like every other entry in the routing table. Any potential destination address is ANDed (ANDing is a Boolean algebra operator that produces a 0, unless two 1s are ANDed) with each route entry’s mask, the result compared to the entry’s network address. All matches are then
compared for the longest prefix length, which means the most 1s in the mask, which is the one chosen when more than one match is found. Since the default gateway’s entry always has a prefix length of 0, it will only be chosen when no other match is found, leading to the use of the word default. Therefore, even when the default gateway is used, it is because the destination is “known.” Any packet whose destination address produces no matches with the route entries in the routing table is dropped.
timely manner or may simply refuse to route traffic and so they time out. That time-out causes the sending router to seek an alternate route for the datagram.
Routes can be predefined and made static, and alternate routes can be predefined, providing a maximum probability that your datagrams travel via the shortest and fastest route.
Note:
If you configure the TCP/IP settings for a computer on a LAN that has a router through which the Internet is accessible, there are certain settings that must be made and others that just make life easier but without which reliable Internet access cannot be achieved. These are an IP address for the computer, a common subnet mask for the LAN, a default gateway IP address for the local router interface, and the address of a DNS server. While the last two settings are not technically mandatory, it’s easier to consider these four parameters as requirements than it is to explain the extra and meticulous configuration that must be made to get around the last two settings, which includes manual routing table manipulation and the use of hosts files.