The following procedure shows how packets are routed to a system
connected directly to the local network.
See
Figure 5-1, ``Example internetwork'',
for an illustration of the networks described in this example.
The IP layer of the machine thames receives a
packet addressed to the machine
seine at the IP address 132.147.118.4.
thames consults its kernel routing table which
may look like the following:
destination netmask gateway interface
132.147.246.0 255.255.255.0 volga le0
132.147.118.0 255.255.255.0 local le0
default N/A volga le0
thames applies each netmask to the destination IP
address 132.147.118.4
until it finds a match with the destination address.
That is, the four places of the IP address are aligned over the
four places of the netmask and the IP address is pushed through the
netmask as through a filter. The number strings 255 allow the
IP address number to pass through unchanged. The zeros in the mask
convert the IP address string to zero as shown below.
132.147.118.4
255.255.255.0
results in
132.147.118.0
As you can see, the result matches the second destination in the routing
table.
(If no match is found, thames uses the default entry.)
Having found a destination match, thames uses the gateway and
interface fields of the entry. thames addresses the packet for
the gateway. In this case the gateway is local, meaning the local
network, so the ultimate destination address is used.
thames transmits the packet through the specified interface.
In this case, the interface is to an Ethernet, so thames does a
lookup in the ARP table to translate the IP address
for seine to an
Ethernet address for seine.
thames transmits the packet on the Ethernet, and it is received by
seine.