Program 6


It is not uncommon for a client to have to find a server. For example, an X-terminal booting up needs to find a BOOTP server that knows about its needs. The way to do this is by broadcasting, where a message is sent to all of a set of hosts by setting part of the IP address to all ones. The routers in the network will insure that every host receives the message, and the host will deliver it to the appropriate process if there is one. This process is described in more detail in the Unix Network Programming Manual . Other uses of broadcasting are for hosts that are exchanging information with many other hosts, such as ruptime, or rwho (check the man pages). Routers also use broadcasting to distribute the information they have about current routes.

Broadcasting obviously can increase the load on a network or a set of hosts if it is misused. It should only be used when necessary and under strict controls for the amount of traffic generated.

Create a client-server system to enhance your lookup program (Program 4) by broadcasting for a server. The client will broadcast the request and the servers will do the lookup. What happens next is of interest: servers with no information can do nothing, or they can send a failure message. Normally, they should remain quiet to reduce the load on the network, but that means that the client could hear nothing. Lets say that they do nothing, so that the client needs a timeout period. If nothing is heard, assume that no information is available. Set the timeout period to 10 seconds. Note that we have gone back to the UDP version of the program. You will need at least three servers running on the same port number on different machines. Broadcast a request and wait up to 10 seconds for a reply, but stop waiting after any response. You will need to set up a timer to handle the timeout. For each server that responds, output the information. The broadcast mechanism should be written as a modular unit. For example,

   Broadcast (network_address, port, message, timeout, host_list)
because this is a common activity that should be standardized. The host_list would be the information about the hosts that responded.

This is a rather simplistic program, but it has lots of uses. For example, finding servers for file sharing, finding machines that can provided DHCP or BOOTP support, or finding sites that provide directory services.

Turn in your source and scripts showing what your client and servers did. Try requests that succeed and fail and output some sort of message when no response is found.