EECS 489 Fall 1999

Homework Assignment 1

DUE DATE 9/23/1999, 1:30pm
Note: For this and all subsequent homeworks and programming assignments, the course directory refers to /afs/engin.umich.edu/class/f99/eecs489. Each homework and programming assignment will have its own subdirectory under the course directory assignments with the name hw1, hw2, pa3, pa4,  etc., I will refer to each assignment's directory as the assignment directory. It is possible that there may be bugs in my code. Please let me know asap if you suspect a bug.

Preamble

For this homework, you are to write the client side and modify the server side of a turnin program that you will use to turn your homeworks and/or programming assignments in for the rest of the semester.

If you are new to network programming, study the files server.c and client.c in the assignment directory first. Refer to these files when you are coding the actual project.

There are seven (7) files in the assignment directory in addition to server.c and client.c. The server side code (turnind.c and tind_recv.c), a skeleton of the client side code (turnin.c), their shared header ( turnin.h), a solution code object file (_turnin.o), the make file ( Makefile ), and an info text file (info).  In case you were wondering, the "d" postfix stands for "daemon" which means "server".

You will modify info, turnin.c and tind_recv.c to complete the project.  In turnin.c you will replace five (5) extern calls to the solution object file with your own code. Then you will modify the server function tind_recv() which has been extracted into the file tind_recv.c for convenience. Info is self-explanatory. More on these modifications later.  Read the comment blocks before the functions for additional implementation information.

To see how the program works:
1. Open a local shell and go to your working directory.
2. Type make to make the two executable files turnin and turnind.
3. Move the executable turnind into a new directory named, say, daemon.
4. Make another subdirectory in  daemon named hw1.
5. Telnet to another unix box, say, xor.engin.umich.edu.
6. On xor fire up the daemon by executing turnind in the daemon directory.
7. From your local shell type :
  turnin -s xor.engin.umich.edu -p 4898 -i 1234 hw1 tind_recv.c turnin.c info
(This is the same command you will use to submit your project except the server name will be the box we are running our server on.)
8. If this worked, the files tind_recv.c, turnin.c, info and a new file named SID.txt should be found in the directory daemon/hw1/<unique name> and you should have gotten a message from the client saying 3 files were received.

Part 1: The Client

The first part of your mission is to replace the following functions in turnin.c: tin_setup_conn(), tin_send_hdr(), tin_send_fhdr(), tin_send_file(), and tin_recv_ack() with ones that do not make call to their associated functions in _turnin.o.

Command line arguments and program behavior

Your client code should take the following command line argument:
      % turnin -s <servername> -p <port#> -i <last 4 ss#s> assignment files...
where servername is the name of unix box running the server (ie xor.engin.umich.edu) and the port number is 4898 (it's arbitrary). The assignment is one of hw1, hw2, hw3, hw4, pa1, pa2, pa3, pa4, pa5, and pa6. The files... are the files you are turning in.

You can turn in a file as many times as you want. The server overwrites any existing file with the same name with the new copy. Note that someone masquerading as you can clobber your files. So, keep a local copy of everything you turn in.

Packet structures and sending order

 
 

 
 

figure38
Figure 1: The turnin header _tin_head.

The server expects to receive the following in order: First, a turnin header that tells the server three things: (1) the assignment for which you are turning in files, (2) your uniqname, and (3) the number of files you are turning in. Fig. 1 shows this header in pictorial form. It is defined in turnin.h as the _tin_head structure.

figure47
Figure 2: The file header _tif_head.

Next, for each file you turn in, you must first send a file header depicted in Fig. 2 (and found in turnin.h as the _tif_head structure) to tell the server what to expect. After you send the file header, you can send the file in chunk(s) of TIN_DLEN bytes, as defined in turnin.h.

When you're done sending, the server will reply with a message (of maximum size TIN_MLEN bytes--again, as defined in turnin.h) telling you what it has received, or what error it has encountered. Your client must be prepared to receive this message and print it out.

Notes on the student id field: Suppose your SS number is 123-45-6789-0. That field would then contain the string 6789.  Hint: Be careful to note that the course  and your student id numbers are sent as strings while the number of files field is sent as a binary number!

Part II: The Server

To prevent the server from getting hung by a misbehaving client, the server socket is put into asynchronous mode in tind_waitfor_conn(). Thus in tind_recv() the server polls the socket for data every TIND_SLEEPUSEC, for a maximum of TIND_MAXTRIES times so that buggy client won't cause an infinite loop. This could be better implemented using select(). The second part of your mission is to rewrite the tind_recv() function in turnind.c with a version that uses select() instead of calling _tind_recv().  To access the man page on select type man -s 3c select.

What to Turn in

There is a file called info in the assignment directory. Please make a copy of it and fill it in with your information. Using your turnin client, turn in all the files you modified, including the info file. DO NOT TURN IN FILES YOU DO NOT MODIFY. DO NOT TURN IN OBJECT AND BINARY FILES. A sample turnin session would be:

      %   turnin -s kailash.eecs.umich.edu -p 4898 -i 1234 hw1 tind_recv.c turin.c info

kailash.eecs.umich.edu  is the name of my machine where I will run the turnind server. We will assume the default port number 4898 as the well-known port of the server. Note that the server on kailash.eecs.umich.edu will not be running until 9/22/99. Run a turnind server on your localhost to test your code.

Questions on this assignment can be posed in the news group. Open Netscape and then select Communicator > Collabra Discussions. Right click on news and select add discussion group. Then join umich.eecs.class.489. Answers to your questions may already be there!!!