| OpSys Fall 2005 - HW6 |
|   OpSys Home   |   Assignment   |   Requirements   |   Submitting   |   Notes |
- TCP based file transfer client and server
The objectives of this assignment are:
You need to design a TCP based file transfer protocol, document your protocol and implement it (write both a client and server). Your client/server pair must support reading files (the server sends a file to the client) and writing files (the client sends a file to the server).
Your server should run in the foreground (a real server would be run as a daemon, but this would make it hard to grade...). Your server can be an iterative server, meaning that it does not need to handle two clients at the same time, but can instead handle one client completely before even looking for another client.
Your server should ask the OS for 'any available port'
(specify a port number of 0 for the server), and must print
the port number assigned (when bind is called)
to standard output as soon as the server
starts. The server will use this port for all transactions,
so the client will need to know what it is.
Your server should print out information (to stdout) about each request it receives.
If the server receives a read request for a file that does not exist, it must send some kind of error indicator to the client, so that the client can inform the user of the problem.
If the server receives a write request for a file that already exists on the server (in the CWD of the server process), it must send some kind of error indicator to the client, so that the client can inform the user of the problem.
The two conditions above mean than when testing your program you will need to run the client and server in different directories!
Your client must be an interactive program (sort of like the command line ftp client). The command line for the client must support two paramenters: the server name (or IP address) and the server port number. For example, the client could be started like this:
./client monica.cs.rpi.edu 8776
If the client cannot connect to the server specified on the command line it must print an error message and quit.
The client reads commands one line at a time from standard input, and reports on the status of each command. If an error occurs the client must indicate that the command was not successful. If the command was successful the client must report on the number of bytes transferred (the file size). The client must support multiple file transfers in a single session (the client supports an interactive session during which the user can issue many reads or writes. The only commands you need to support are:
read filename: the client requests that the
server send the file specified (the server only need look in it's
current working directory for the file). If this is successful the
client will now have an identical copy of the file. You
must not assume that files contain ASCII text, it must be possible
to receive binary files (programs, images, etc).
write filename: the client requests that the
server create a new file in the server's working directory, using
the filename specified. The client must send the contents of the
file (assuming the server approves of the write command). The client
program should look for the file in it's current working directory.
The server
must not allow the client to overwrite a file, so the server must
refuse the request if the file already exists.
Feel free to add any additional commands to the client if they help you develop/debug your code. If you do this, please have the client print out a list of all the commands when it initially starts up (and include this in your protocol description).
Part of this assignment involves the creation of an application protocol to support the interactions between the client and server. This protocol establishes the rules for what is sent from the client to the server when making a request, how errors are communicated, and how files are transferred. You must document your protocol in your README file in sufficient detail that a programmer could write a client that could work with your server (and vice-versa).
We don't expect an elegant application protocol, anything that works is fine. An English description of your protocol is OK, although it's generally easier and more accurate to describe your protocol in some formal way (for example, show the grammer of valid communications and list all possible error conditions).
Keep in mind that your description must be complete enough so that any network programmer could write a program that works with your programs!
- Project Requirements
The following are the requirements for the project:
Your programs can be written in any language that we have
access to on the CS department FreeBSD machines
(freebsd.remote.cs.rpi.edu).
Your programs must be socket programs, you cannot use any other network programming API (no RMI/RPC,etc).
Your submission must include a file named README that includes the following information:
Grading: Your code will be graded according to the formula below. Note that to get full credit we must be able to understand your code (it must be commented!)
| 25% | Protocol (Description) |
|---|---|
| 40% | read (file transfer from server to client) |
| 25% | write (file transfer from client to server) |
| 10% | Code quality (comments, organization, how hard is it to understand ?). |
You can get partial credit for any part.
If your code does not compile and run under FreeBSD, you will lose at least 1/2 the relevant points ( partial credit will be awarded based on visual inspection of the code).
- How to Submit
Log in to WebCT at webct.rpi.edu using your RCS id and password. Once you get to MyWebCT click on "Operating Systems", and from there go to the homework drop boxes. Submit your files (individually, zipped or tarred) to the drop box labeled HW6.
- Notes:
The listing below indicates what a client session might look like. Note that this in no way defines the application protocol, this is just showing what kind of behavior is expected when running the client.
> ./client monica.cs.rpi.edu 8776
Fatal Error : can't connect with server.
> ./client ashley.cs.rpi.edu 8776
Connection successful. Enter a command:
read filename
write filename
% read foo
Successful transfer of file foo from server to client - 127 bytes.
% write foo
Server says No.
% write fred
Successful transfer of file fred from client to server - 182736 bytes.
|