How does a route table work?
- From: "Alex Vinokur" <alexvn@xxxxxxxxxxxxxxxxxxxxx>
- Date: 4 May 2006 04:44:13 -0700
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
.
- Follow-Ups:
- Re: How does a route table work?
- From: Alex Vinokur
- Re: How does a route table work?
- Prev by Date: ★★ 妳是很想瘦的人嗎?★★
- Next by Date: Re: Does WinInet use sockets ?
- Previous by thread: ★★ 妳是很想瘦的人嗎?★★
- Next by thread: Re: How does a route table work?
- Index(es):
Relevant Pages
|