IP Routing Primer: Part Two
November 13, 2000
by Peter
Morrissey
To Route or Not to Route
The rules of IP networking dictate that any time a host has an IP packet to transmit, it must first determine whether the destination IP address is on its own network or another network. If the address is not on its own network, the host must send that packet to a router. The host determines this by comparing the network portion of its own address with the network portion of the address with which it wants to communicate, or the destination IP address.
At this point in the process, the subnet mask comes into play. The subnet mask determines how much of the address is the network address. By doing so, it helps ascertain the comparable portion of the host's and the destination' s IP address. If the network portion of the addresses is different, the packet is sent to the router; if it is the same, a router is not needed. The packet can be sent directly on the local network.
In the following 23-bit mask example the destination address is on the same network as the source IP address. The portion of the destination address directly beneath the contiguous binary 'ones' of the mask address is the same as that of the source address:
| 11111111.11111111.11111110.00000000 |
= 255.255.254.0 |
=
Mask |
| 10000000.11100110.00000100.00001000 |
= 128.230.004.8 |
= Source IP address |
| 10000000.11100110.00000101.00010000 |
= 128.230.005.16 |
= Destination IP address |
If the mask is changed to a 24-bit address, the result will be different. Here, those sections of the source and destination addresses overlaid by the binary 'ones' of the mask are different, thus proving the addresses are on different networks:
| 11111111.11111111.11111111.00000000 |
= 255.255.255.0 |
=
Mask |
| 10000000.11100110.00000100.00001000 |
= 128.230.004.8 |
= Source IP address |
| 10000000.11100110.00000101.00010000 |
= 128.230.005.16 |
= Destination IP address |
In this example, the packet must be sent to the router. It's because of such differences that every host has to have a router or gateway address configured. If a host can communicate with other hosts on its own subnet but not with those not on its subnet, then either the mask or the router address is incorrectly configured on the host.
IP Over Ethernet
It's important to remember that IP operates on layer 3 of the OSI model. But for IP's bits to be physically transmitted on a network, it must rely on the protocols in layers one and two of the OSI model. Enter Ethernet.
At this point it is important to remember that data on an Ethernet network cannot move from point A to point B without knowing the Ethernet address of point B. Also, an Ethernet NIC (Network Interface Card) will ignore all Ethernet packets without an Ethernet address as the destination address. The only exception is the Ethernet broadcast address, which turns the destination Ethernet address to all binary 'ones.'
Continuing with the example above, once packet transmission via the local network vs. the router is determined, another step is necessary. This step involves the Address Resolution Protocol (ARP). ARP sends a broadcast out on the network using the IP broadcast address discussed earlier. This broadcast, at which all network devices will look, includes a query for the Ethernet address of the device with the destination IP address.
Every device on the local network-note, the router will not propagate the broadcast to other networks--will then look at the Ethernet packet, and the device with the destination IP address in question will respond to the Ethernet address query. Once this address is received, the transmitting host can place the IP packet inside an Ethernet frame and send it to the destination host. When that host receives the packet it throws away the Ethernet frame, leaving the IP packet.
Packet transmission via a router is no different. If the destination IP address is on another network and has to be sent through a router, ARP must still determine the Ethernet address of that router. And like the host, when the router receives the packet it strips off the Ethernet address. Remember, routers are only interested in the destination IP address.
Routing
When a router receives a packet, it is really only concerned with the packet's destination network address. This is the only information the router needs from the packet to do its job.
Like hosts, routers use masks to determine the extent of the network address within the destination IP address. Every router keeps a table listing all the networks it knows, along with the interface it needs to transmit the packet in the right direction. This is called a routing table. Also like a host, a router uses masks to determine whether it is directly connected to a network, automatically adding a corresponding entry to its table. It is possible to manually enter routes into a routing table. These are usually called static routes.
If there is only one router in the network, then it isn't necessary to worry about anything other than directly connected networks. If there are a few networks that are not directly connected, then it will be necessary to tell the router the direction in which to send packets destined for the network. This can be done by manually configuring the routes. If there are numerous routes, then it will be necessary to rely on routing protocols to do this automatically.
Routing protocols give routers the ability to automatically inform each other of any directly connected routes. Not all routing protocols are created equal, though. For example, with some routing protocols, such as RIP version 1 and IGRP, only one subnet mask can be used on the whole network. With other protocols, it is possible to have different subnet masks on different parts of the network. The next section, "Choosing an Interior Gateway Routing Protocol," will talk more about routing protocols.
|
 |

Sidebar: Routing vs. Switching
Traffic will not propagate across a router unless it is sent to the router's interface using the router's Ethernet address, and it must have a destination IP address that the router is aware of. For this reason, routers provide a good means for filtering and segregating traffic.
Switches can provide traffic filtering as well, but they operate strictly at layer 2. A switch forwards packets based on their Ethernet addresses. Switches determine the Ethernet addresses of devices attached to every port by watching incoming packets' source Ethernet addresses and building routing tables accordingly. To determine where to forward a packet, a switch looks at its destination Ethernet address, consults the forwarding table and then forwards traffic via the correct port.
While switches do not alter the contents of the packet, routers do. When a router receives a packet from an Ethernet network, the first thing it does is strip off the Ethernet header to examine the packet's destination IP address. The router then consults its routing table and forwards the packet accordingly.
|
 |
 |
|