Computer Communications Spring 1998
Suppose you have a 1.7MB file to send over a link of length 1900km. The link uses electrical signals that travel at 200,000,000 meters per second. Our goal is to have a link that will have a small total delay to transfer the file from one end to the other, so we need large bandwidth. The ``link factory'' can manufacture this link with any desired bandwidth. However, we know that (a) larger bandwidth is more expensive, and (b) increases in bandwidth eventually don't reduce delay by very much. To illustrate point (b), what is the smallest bandwidth T so that a bandwidth of 2T would reduce the total delay by no more than 5%?
The following programs are simple examples of how UDP can be used in a Unix environment. These programs are not examples of good programming -- they purposely have been oversimplified and most comments have been removed. They are initial examples that you can modify and experiment with to learn some network programming techniques. Some of the programming techniques will be explained in class.
The program udpcli.c is the ``client'' of the example. This program reads from standard input (the terminal) and sends lines in UDP datagrams to a server. You should be able to compile this program and test it with the corresponding server program, udpserv.c in the same machine (it uses localhost as the network address). To give an idea of just what the various system calls are for these two programs, you can see annotated versions of udpcli and udpserv as well in an HTML format. To experiment with these programs, follow these steps.
gcc -o udpcli udpcli.c
gcc -o udpserv udpserv.c
Recall that RPC (Remote Procedure Call) uses UDP to communicate between client and server. This means, of course, that a client expects some kind of answer returned from a request it sends the server. But the udpcli and udpserv examples above do not illustrate how the client gets a response from the server. This is slightly more complicated, because the server needs to send a datagram back to the client -- and how does the server know which port to use? The server's port is known to the client (in these example programs it is 5057), but the client's port must be determined by the server during runtime.
illustrate the server responding to the client. The server
receives text from the client, increments all the characters in
that text (for instance, aaa becomes bbb) and
sends the modified text back to the client. Instructions for
compiling and testing these two programs are the same as for the
first pair of UDP programs.