Project 2 - A Simple File Transfer Protocol
The project requires three pieces of work: a network protocol specification, a client program
that implements the client side of the protocol, and a server program that implements the
server side of the protocol. As beginners in network programming, most students tend to
overlook the importance of correct protocol design and specification. They often write a
"protocol" after they have written up the client and the server programs. This is akin to
building a palace without an architectural plan and then drawing up a blue print after the
palace is already erected (or more likely after the palace is crumbled). Correct specification of
the communication protocol is required in this project, and you can expect to lose many
marks if your protocol specification is not complete or correct or not corresponding to what
you have implemented! Having said that, programming wise, it is relatively straightforward to
implement the code once the network protocol is correctly specified.
Design and implement a simple network protocol that can be used to download files from a
remote site and to upload files to a remote site, and a client and a server programs that
communicate using that protocol. The protocol should use TCP as its transport layer protocol.
The server must be able to serve multiple client requests simultaneously. For simplicity, do
not consider any authentication process in this project, hence the server will provide its
service to any client with the right site address and port number.
To simplify project marking, please name your server program myftpd with the following
command line syntax (here the letter d in myftpd stands for daemon, since the server should
run as a daemon process:
myftpd [ initial_current_directory ]
The server process maintains a current directory. Its initial value should be the one inherited
from its parent process unless the optional
initial_current_directory
is given. In the latter case, the user supplied path should be used to set the initial current
directory of the server. This can be done using the function chdir. A client can use the cd
command to change the (child) server's current directory later.
The client program should be named myftp with the following command line syntax:
myftp [ hostname | IP_address ]
where the optional hostname (IP_address) is the name (address) of the remote host that
provides the myftp service. If the hostname or IP_address is omitted, the local host is
assumed.After the connection between the client and the server is established, the client should display
a prompt > and wait for one of the following commands:
• pwd - to display the current directory of the server that is serving the client;
• lpwd - to display the current directory of the client;
• dir - to display the file names under the current directory of the server that is serving
the client;
• ldir - to display the file names under the current directory of the client;
• cd directory_pathname - to change the current directory of the server that is serving
the client; Must support "." and ".." notations.
• lcd directory_pathname - to change the current directory of the client; Must support
"." and ".." notations.
• get filename - to download the named file from the current directory of the remote
server and save it in the current directory of the client;
• put filename - to upload the named file from the current directory of the client to the
current directory of the remove server.
• quit - to terminate the myftp session.
The myftp client should repeatedly display the prompt and wait for a command until the quit
command is entered.
This project consists of three components:
1. Protocol Specification:
You must specify a protocol for communication between the myftp client and the
myftp server. This protocol will become the sole reference to which the client
program and the server program can be separately implemented. This means that, by
referring to the protocol, the client and server can be implemented independent of
each other. The design and implementation of the client (server) should not depend
on (1) what strategy and algorithms were used to implement the server (client), (2)
what programming language were used to implement the server (client), and (3) what
operating system the server (client) is running on. The protocol must be complete,
i.e., it contains all the necessary information required by both parties to communicate,
such as the format and sequence of data exchanges between the client and the server,
the transport layer protocol (TCP or UDP) used to deliver the data, and the server port
number. However it should not contain anything that unnecessarily constrains the
implementation of the client or the server. For example, there is no point to limit the
implementation language to a particular programming language in the protocol, or to
require the client or the server to be implemented with a particular data structure.
Before you attempt this project, you should first complete the first two exercises in
Lab 11. You may also read the Trivial FTP Protocol given in Appendix 17A of the
textbook (Stallings: Chapter 17 of Online Chapters). Note TFTP uses UDP, while
myftp protocol must use TCP.
2. Client Program:
You need to implement a client program according to the myftp protocol. Note that
the client should never rely on any undocumented internal tricks in the server
implementation. Apart from the myftp protocol, you should not make any other
assumption about the server program in your client program.
3. Server Program:You need to implement a server program according to the myftp protocol. Note that
the server should never rely on any undocumented internal tricks in the client
implementation. Apart from the myftp protocol, you should not make any other
assumption about the client program in your server program.
Note the following additional requirements/explanations:
• The name of the client executable program must be myftp. The name of the server
executable program must be myftpd.
• To avoid potential conflict in the use of the server's ``well known'' port number when
several students use the same machine (such as ceto), you should use the port
allocated to you as the default server listening port.
• Tests should show the cases where both the client and the server are on the same
machine as well as on different machines (you may want to use ceto.murdoch.edu.au
to do the testing, however you must kill your server at the end of the test). They
should also show that more than one client can obtain the service at the same time.
You may use the command script to record the terminal I/O. When debugging your
network program on a standalone machine (e.g., on your home Linux), you may use
localhost as the ``remote'' host name.
• Tests should show that the program can transfer not only small files (e.g., 0, 10 and
100 bytes) but also large files (at least several mega bytes), and not only text files but
also binary files. In addition, you must show that the transferred file and the original
file are identical not only in their sizes but also in their contents (use diff command).
• The specification of the protocol is an important part of this question. Please provide
a full specification of the protocol in a section separated from the client and server
implementations. You should complete this specification before starting the
implementation of the client and server programs.