Homework Assignments: 22C:178 & 055:134

Computer Communications Spring 1998

Assignment 5

[23 February]

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%?

Some UDP Program Examples

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.

Copy the source files to your local directory.
Compile them with the commands
gcc -o udpcli udpcli.c
gcc -o udpserv udpserv.c
Then open an X-window and start the server program in that window with the command udpserv. It should print a message telling you it is waiting.
In another window, start the client program with the command udpcli. It should be waiting for your keyboad input. Enter some data, such as hello server. The data you enter should be printed in the server window.
After the above steps work, you should try some simple tests such as starting the client first, killing the server in the middle of a conversation with the client, and so on to see what happens if there is a failure. Another thing to try is to change localhost to some other machine name, such as horse@cs.uiowa.edu, and test the pair of UDP programs.

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.

Programs udpcli2.c and udpserv2.c 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.

Ted Herman