We have seen before that erdos, when given a datagram for quark, checks the destination address and finds it is not on the local network. It therefore sends it to the default gateway, sophus, which is now basically faced with the same task. sophus recognizes that quark is not on any of the networks it is connected to directly, so it has to find yet another gateway to forward it through. The correct choice would be niels, the gateway to the Physics Department. sophus therefore needs some information to associate a destination network with a suitable gateway.
The routing information IP uses for this is basically a table linking networks to gateways that reach them. A catch-all entry (the default route) must generally be supplied, too; this is the gateway associated with network 0.0.0.0. All packets to an unknown network are sent through the default route. On sophus, this table might look like this:
----------------------------------------- +-----------+-------------+------------+ |Network | Gateway | Interface | +------------+-------------+------------+ +------------+-------------+------------+ |149.76.1.0 | - | fddi0 | |149.76.2.0 | 149.76.1.2 | fddi0 | |149.76.3.0 | 149.76.1.3 | fddi0 | |149.76.4.0 | - | eth0 | |149.76.5.0 | 149.76.1.5 | fddi0 | |... | ... | ... | |0.0.0.0 | 149.76.1.2 | fddi0 | +------------+-------------+------------+ +------------+-------------+------------+Routes to a network that sophus is directly connected to don't require a gateway; therefore they show a gateway entry of ``-''.
Routing tables may be built by various means. For small LANs, it is usually most efficient to construct them by hand and feed them to IP using the route command at boot time (see chapter-). For larger networks, they are built and adjusted at run-time by routing daemons; these run on central hosts of the network and exchange routing information to compute ``optimal'' routes between the member networks.
Depending on the size of the network, different routing protocols will be used. For routing inside autonomous systems (such as Groucho Marx campus), the internal routing protocols are used. The most prominent one is RIP, the Routing Information Protocol, which is implemented by the BSD routed daemon. For routing between autonomous systems, external routing protocols like EGP (External Gateway Protocol), or BGP (Border Gateway Protocol) have to be used; these (as well as RIP) have been implemented in the University of Cornell's gated daemon.