CS 3733 Operating Systems, Fall 1998 Assignment 6

Due Tuesday, December 1 at the start of class


This assignment is similar to assignment 5, except that the communication is done over the network and therefore the work can be done on different machines.

Again you are going to be calculating the sum of an arithmetic progression, but this time you will farm out parts of the computation to different machines and then gather and combine the results.

You will need to use a port number of communication. To make sure that no two students are using the same part number, check here for a list of port numbers you can use for this project.

Use a single makefile for this assignment. When you compile the programs be sure to use the libraries: -lnsl -lsocket. Use the cover sheet available in /usr/local/courses/cs3733/fall98/assign6/cover6.ps for turning in the assignment.

Part 1:

Obtain copies of Program 12.2 (server.c) and Program 12.4 (client.c) as well as the UICI code. You can find these and other files you need in /usr/local/courses/cs3733/fall98/assign6. Compile the code and make sure it works as described. Also run lint and make sure there are no unexpected warnings or errors.

Part 2:

Copy client.c into client_int.c and modify it so that it parses its ASCII input into integers and sends out these integers as sizeof(int) bytes of raw data. You may assume the the input will contain one integer per line and not contain any errors. You may want to use scanf or fgets.

Copy server.c to server_int.c and modify it so that it reads in raw integers instead of ASCII characters and displays the values read, one per line. As in Part 1, the server should not exit when the connection is closed, but should instead listen for another connection request.

Test these programs together. Include sample output showing that the programs are working correctly.

Part 3:

Copy server_int.c into server_sum.c and modify it so that it reads three integers in raw form from the network, calculates the sum of the arithmetic progression corresponding to the input data, and displays a line giving the input values and the sum calculated. The first integer read will be the first integer in the sequence of numbers to be summed, the second will be the delta value, and the third will be the number of values to sum. After the information is displayed the connection should then be closed and the server should listen for another connection request.

Test your program using client_int.c to generate the data. Include sample output showing that this is working correctly.

Part 4:

Copy client_int.c to client_input.c and modify it so that it takes the following commend line parameters in the order given: It sends the first three parameters (in raw form) to host using port port. It then closes the connection. Note that the host now comes after the port number.

Test your program with server_sum and include sample output.

Part 5:

Copy server_sum.c to server_summer.c and modify it as follows. After calculating the sum, it sends the value back over the same connection as a raw integer and closes the connection. It then listens for another connection request to come in. It does no other output.

Copy client_input.c to client_input1.c and modify it so that after sending out the three integers it reads a raw integer from the network and prints it out with an appropriate message. It then closes the connection and exits.

Provide sample output showing that the programs are working correctly.

Part 6:

Copy client_input1.c to client_inputs.c and modify it so that it takes 5 or more command line arguments. The additional arguments are additional host names. If there are n hosts given, the program breaks the arithmetic sum calculation into n almost equal parts and sends them out to the hosts. It then waits for the n values to come back, it sums them and prints the output with an appropriate message. Note that there are n independent network connections but that they can use the same port number. You should test your program in the cases n < count, n = count and n > count. You should also make sure it works when count is not divisible by n.

Your program should be written in such a way that the server calculations can be done in parallel.

Provide sample output showing that the programs are working correctly.

Part 7:

Answer the following questions: Suppose the client is run on a big endian machine and the server is run on a little endian machine. In Part 1, the value 23 is entered on the client machine. What value is displayed by the server? Answer the same question for the client and server from Part 2.

Extra Credit 1:

Do not attempt this unless everything else is working properly.

Copy client_inputs.c to client_inputp.c and modify it so that the values generated by the servers are processed as they become available, independent of the order in which they become available. It should print an appropriate message as the values come in and then a final message when they have all been received.

To test this, copy server_summer.c to server_summerp.c and have the server wait a random number of seconds (between 1 and 10) before starting the calculation. Use your random number library from the previous assignment, but use 100 times the process id for the seed.

Write a short report indicating how your client solved this problem. Provide sample output to show that it is working correctly.

Extra Credit 2:

Suppose the time to calculate the sum of n numbers in an arithmetic progression is cn where c is a constant determined by the hardware of the system.

Suppose that the round-trip delay in the network communication (the time to send a short message and get a response) is d.

Suppose that the time to break up a sum into k parts and establish k network connections is bk, where b is a constant.

  1. Write down an approximate formula for the time is takes Part 6 to compute the sum of an arithmetic progression of n numbers on k servers. Assume that n is a lot bigger than k.
  2. For a given value of n explain how you would find the best value of k to use.


Be prepared to demonstrate your programs on the last day of class.
Your servers should be able to work with clients written by other students and vice versa.