How does a route table work?



How does a route table work?

Here is some stuff from Microsoft Corporation's Internet Protocol
Helper Technical Articles.

==============================================
Internet Protocol Helper Technical Articles

Introduction to TCP/IP

Microsoft Corporation

September 1998

------ Fragments ------

The route determination process
To determine which the routing table entry will be used for the
forwarding decision, the following process is used:

* For each entry in routing table, perform a bit-wise logical AND
between the Destination IP address and the Subnet Mask.
Compare the result with the Network ID of the entry for a match.
* The list of matching routes is compiled. The route that has the
longest match
(the route that matched the most amount of bits with the destination
IP address) is chosen.
The longest matching route is the most specific route to the
destination IP address.
If multiple entries with the longest match are found (multiple routes
to the same network ID, for example),
the router uses the lowest metric to select the best route.
If multiple entries exist that are the longest match and the lowest
metric,
the router is free to choose which routing table entry to use.

The result of the route determination process is the choice of a single
route in the routing table.
The route chosen yields a forwarding IP address (the next hop IP
address) and an interface (the port).
If the route determination process fails to find a route, IP declares a
routing error.
For the sending host, an IP routing error is internally indicated to
the upper layer protocol such as TCP or UDP.
For a router, an ICMP Destination Unreachable-Network Unreachable
message is sent to the source host.



Example routing table for Windows NT
Table 28 shows the default routing table for a Windows NT 4.0 host (not
a router).
The host has a single network interface card and has the IP address
157.55.27.90,
subnet mask 255.255.240.0 (/20), and default gateway of 157.55.16.1.

Table 28. The Windows NT routing table

Network Netmask Gateway Interface Metric Purpose
Address Address
0.0.0.0 0.0.0.0 157.55.16.1 157.55.27.90 1 Default Route
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 Loopback Network
157.55.16.0 255.255.240.0 157.55.27.90 157.55.27.90 1 Directly Attached
Network
157.55.27.90 255.255.255.255 127.0.0.1 127.0.0.1 1 Local Host
157.55.255.255 255.255.255.255 157.55.27.90 157.55.27.90 1 Network
Broadcast
224.0.0.0 224.0.0.0 157.55.27.90 157.55.27.90 1 Multicast Address
255.255.255.255 255.255.255.255 157.55.27.90 157.55.27.90 1 Limited
Broadcast


For example, when traffic is sent to 157.55.16.48, the most specific
route
is the route for the directly attached network (157.55.16.0/20).
The forwarding IP address is set to destination IP address
(157.55.16.48)
and the interface is the network interface card which has been assigned
the IP address 157.55.27.90.

When sending traffic to 157.20.0.79, the most specific route is the
default route (0.0.0.0/0).
The forwarding IP address is set to the gateway address (157.20.16.1)
and the interface
is the network interface card which has been assigned the IP address
157.55.27.90.

-----------------------
==============================================

For each entry in routing table, perform a bit-wise logical AND between

* the Destination IP address
and
* the Subnet Mask (Netmask)


Example 1. IP Destination = 157.55.16.48
Here is a list of logical-AND's for IP Destination = 157.55.16.48

Logical-AND Network Netmask Gateway Interface
Address Address
0.0.0.0 0.0.0.0 0.0.0.0 157.55.16.1 157.55.27.90
157.0.0.0 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
157.55.10.0 157.55.16.0 255.255.240.0 157.55.27.90 157.55.27.90
157.55.16.48 157.55.27.90 255.255.255.255 127.0.0.1 127.0.0.1
157.55.16.48 157.55.255.255 255.255.255.255 157.55.27.90 157.55.27.90
80.0.0.0 224.0.0.0 224.0.0.0 157.55.27.90 157.55.27.90
157.55.16.48 255.255.255.255 255.255.255.255 157.55.27.90 157.55.27.90

The most specific route is the route for the directly attached network
(157.55.16.0/20). - Why?



Example 2. IP Destination = 157.20.0.79
Here is a list of logical-AND's for IP Destination = 157.20.0.79

Logical-AND Network Netmask Gateway Interface
Address Address
0.0.0.0 0.0.0.0 0.0.0.0 157.55.16.1 157.55.27.90
157.0.0.0 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
157.20.0.0 157.55.16.0 255.255.240.0 157.55.27.90 157.55.27.90
157.20.0.79 157.55.27.90 255.255.255.255 127.0.0.1 127.0.0.1
157.20.0.79 157.55.255.255 255.255.255.255 157.55.27.90 157.55.27.90
80.0.0.0 224.0.0.0 224.0.0.0 157.55.27.90 157.55.27.90
157.20.0.79 255.255.255.255 255.255.255.255 157.55.27.90 157.55.27.90

The most specific route is the route for the directly attached network
(0.0.0.0/0). - Why?


Thanks,


--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

.



Relevant Pages

  • Re: Whats important to you?
    ... That feature is the only way to force the routing go via the route that ... There are also some models that simply won't let you add any intermediate destinations to a route or maybe only a single intermediate destination. ... And there are some that have a feature usually called a "detour" that is, in fact, no more than a change in the destination and of little use in controlling routing. ...
    (sci.geo.satellite-nav)
  • Re: Which Units support MDR?
    ... route for deliveries or sales calls? ... destination probably contributed to my use of the phrase too. ... i.e. for which this features was available, ... do multiple destination routing. ...
    (sci.geo.satellite-nav)
  • Re: Which Units support MDR?
    ... I am comfortable with just using multiple waypoint routing or via routing or anything else that is understood. ... And when I activate the route I can choose Follow Road or Off Road navigation. ... Garmin tends to require the via point which can be a problem if you go offroute and would prefer the re-calc to just send you on to the destination. ... You are describing the behavior of off road routes I believe since you talk about actual waypoints although if you view the route page (not the eta on the navigation page) then you can get the data on Garmin units. ...
    (sci.geo.satellite-nav)
  • Re: NAT Solution
    ... directly to the correct destination using GSLB or if this is an HTTP ... based on source address to a different resource. ... default behavior would let the packet route to the normal destination, ... accomplish this task. ...
    (comp.dcom.sys.cisco)
  • Re: Which Units support MDR?
    ... Some considerations for Multiple Destination routing. ... MDR on the 76Cx is that I can put waypoints at a series of places, put those waypoints into a route and it will lead me to those places in that order. ... And when I activate the route I can choose Follow Road or Off Road navigation. ... if the waypoint is via point it directs me to the next waypoint after I pass by or through the waypoint. ...
    (sci.geo.satellite-nav)