CS143 Programming Assignment One

The goal of this assignment is for you to design and implement a simple file transfer protocol. Because you'll be using unreliable UDP service, you'll have to use some of the ideas that make higher-level protocols such as TCP and NFS reliable. Later assignments will build on these ideas.

You should write two programs, a client and a server. You start the server on the host from which you want to read files, with a port chosen by you. If you choose port 27011, you might start the server thus, after creating a test file:

scws32% echo hello > testfile
scws32% ./server 27011
Log into another computer to read the file over the network from the server program:
scws40% ./client scws32.harvard.edu 27011 testfile
hello
scws40%
In order to avoid conflicts with other students, you should test your programs on randomly selected ports and workstations; don't just use scws32 and port 27011. The HP workstations at the Science Center are called scws23.harvard.edu through scws47. You can use ports from 7000 to 32000.

Requirements

We'll be running your programs as part of grading. In order that you solve the desired problem and we be able to verify this, please adhere to the following requirements:

Hints

Look here for some references on sockets programming on UNIX.

You will want to use sequence numbers to recover from duplicated or re-ordered packets. You will want to use time-out and re-transmission to deal with lost packets.

We've written some sample code for you, which you may incorporate into your assignment if you wish:

UNIX imposes a limit on the size of UDP packets -- a thousand bytes will work, but ten thousand probably won't.

You may find it convenient for the client to drive the conversation with the server. That is, the client should send requests to the server, each request for one packet's worth of data from the file. The server needn't keep any per-client state: each time it gets a request, it can open the file, read a packet's worth of data, close the file, and send the data. Don't be tempted to use the fork system call.

When you hand in your code (see the next section), you'll have to give us a Makefile. Here is a sample; it will cause client.c and server.c to be compiled when you type make:

CC = gcc
CFLAGS = -g
all : client server

Make your algorithms and code clean. We won't grade your coding style. However, if we suspect your code doesn't completely work but we cannot understand it, we won't cut you much slack.

What to Hand In

This assignment is due at 1:00pm on Wednesday Oct 2 1996. Mail a shar file containing a Makefile and your source files to cs143-pa-one@eecs.harvard.edu. We must be able to simply un-shar it, type make, and run the programs client and server.

To create a shar file from your files and mail it to us, try something like this (but the arguments to shar should be the names of your source files):

scws40% shar client.c server.c common.h Makefile > shar.out
scws40% Mail cs143-pa-one@eecs.harvard.edu < shar.out

The late policy for the entire course is that you get a total of five late days. You may use them for any assignment. For instance, you could hand one assignment in an hour late, another 95 hours late, and the others on time. When you've used up all your late time, we won't accept late homework at all except if you have a terrible emergency.

While you may discuss this assignment with other CS143 students or the TFs, everything you hand in must be your own work.