Within an internet, it is possible to send a datagram over many paths to a given address. A datagram is a unit of information that contains a source and destination address, plus data. Routing is the process of choosing which path or route is best.
Basically, there are two kinds of routing: direct and indirect.
You can route a datagram directly when the sending and receiving hosts are in the same network.
You must route a datagram indirectly when the sending and receiving hosts are in different networks. In this case the datagram first goes to a local gateway. The local gateway decides where to send the datagram next. The datagram “hops” from one gateway to another until it reaches a gateway connected to the destination network. The final gateway then sends the datagram to the destination host.
All hosts and gateways on a network store routing information in tables. Each record in a routing table usually contains:
Some routing tables also contain information about network performance (for example, whether specific network interfaces are up or down) to help regulate the flow of network traffic. Table 3 contains a sample routing table.
|Destination Address||Gateway Address||Host or Network Route?||Direct or Indirect Route?|
The host or network routing flag determines how the host or gateway compares the datagram's destination internet address with the destination address in the routing table.
Upon finding a host routing record, the host or gateway compares all parts of the datagram's destination internet address with the destination address defined in the routing record. Both addresses must match exactly for the datagram to use the route defined in that record. This is shown in Figure 5.
Upon finding a network routing record, the host or gateway compares only the network or subnet portion of the datagram's destination internet address with the destination address defined in the routing record. Both addresses must have the same network or subnet numbers for the datagram to use the route defined in that record. The host portion of the address is irrelevant.
Assume that the internet addresses shown in Figure 6 belong to a Class A network that is not subnetted. The first byte of the address specifies a network. The remaining bytes are host numbers. The network routing record defines only the network portion of the destination address (188.8.131.52).
A host or gateway does the following to send a datagram:
Routing tables are maintained in two ways: manually or dynamically.
The system manager maintains routing tables manually by adding and deleting records. Gateways can maintain routing tables dynamically by sending Internet Control Message Protocol (ICMP) redirect messages to hosts and other gateways in response to routing requests. These messages advise the hosts and gateways of the best way to route datagrams. Hosts and gateways use the ICMP messages to update routing tables automatically.
The example in Figure 7 shows how ICMP redirect messages work.
Suppose Harpo wants to send a datagram to Bart. This is what happens:
You can also have a routing process (GateD, the Gateway routing daemon) that communicates with routers using protocols such as Routing Information Protocol (RIP) or Open Shortest Path First (OSPF). These protocols learn about routes and dynamically add them to the routing table.