previous next

Program Specifications

Program invocation

The program will be started using the command

java P2PFTP workspace-name workspace-path name-svc-host name-svc-port

workspace-name is the name of the workspace, workspace is the name of the directory on the local host where the shared files are located.  name-svc-host is the name of the host where the name service is running.  name-svc-port is the port where the name service is listening for requests from clients. 

Make sure that you do NOT share any files that you do not want other people to see or copy. This includes, but is not limited to, files in the following categories:
  • Files that you don't have permission to distribute. This includes any files protected by the copyright laws.
  • Source code for this project or any other lab/project. Remember that java's .class files are relatively easy to de-compile
  • Personal files.

If the program is not invoked correctly from the command line, an appropriate error message should be displayed on standard output and the program will terminate without producing any additional output.

Your program must provide the following features:

  1. Every workspace has a name associated with it.  The name will be used by remote clients to locate the workspace.
  2. Only the files contained in the directory specified on the command may be placed into the shared workspace.  Any files that are copied from a remote workspace into the local workspace must also be placed in this directory.
  3. The user should be able to view the contents of any known workspace when running the application. 
  4. The user can copy (read) files from any remote workspace into their local workspace.
  5. It is not possible to place (write) files into a remote workspace.
  6. It should be possible to search the combined global workspace for a file by name.  All matches should be displayed along with the name of the workspace that contains the file.
  7. The user should be able to enable and disable their file sharing service while still using the client to connect to others' services.
  8. The program must be GUI driven.
  9. The program must provide online documentation.
  10. The client and server portions of the program must run as separate threads.  The server must be multi-threaded so that multiple requests can be processed concurrently.

Name Service

Each server will register itself with a name service.  The clients will then query the name server to obtain the location of the servers known to the system. 

The name service allows one to register a name, IP address, and port.  Each entry will be held in the table for a fixed period of time.  If the entry has not been renewed before the time period expires it will be automatically removed from the table.  Users may query the name service for entries in the table.  Clients that have valid entries in the table will receive periodic update messages from the name service that contain the current entries in the table.

The server is currently running on holly.cs.rit.edu and is maintaining a log file that can be used for debugging purposes.  The log file can be viewed at http://www.cs.rit.edu/~ptt/logs/NSlog.txt The first entry in the log file identifies the port on holly that the server is attached to:

10/13/04 8:34:05 AM:  Log started
10/13/04 8:34:05 AM:  NameServer@holly:59293 capacity=128 duration=512 update=500

More conveniently, you can look at the last 50 lines of the log by using the tail command like:

tail -50 ~ptt/public_html/logs/NSlog.txt

The name server uses UDP to communicate with its clients.  There are six different types of packets used in the protocol.  The first byte in every packet identifies the type of the packet.  The contents of each packet are given in the table that follows:

Packet Name Description Contents
REGISTER Sent by the client to add an entry to the table.  The IP address for the entry will be taken from the UDP packet.  The entry will not be accepted if the name or address (IP address:port) are already in the table.  If the entry is accepted, the entry will be assigned a unique ticket number. Type = 0 (byte)
Name = UTF String
Port = int
TICKET The server sends a TICKET packet to the client in response to a REGISTER request.  The ticket packet contains the ticket number and the number of milliseconds until the entry expires.  A negative ticket number indicates that the server did not accept the entry. Type = 1 (byte)
Ticket = int
Time = int
RENEW Sent by the client to renew an entry maintain by the name service.  The packet contains the ticket number of the entry.  The server will respond by sending a new TICKET packet. Type = 2 (byte)
Ticket = int
QUERY Sent by the client to obtain registered names.  Any registered name that begins with the same characters as in the query string will be sent to the client in a single REPLY packet. Type = 3 (byte)
Query = UTF String
REPLY Sent in response to a query request.  Contains the name and address of any entries that matched the query.  Note that a valid REPLY packet may contain 0 entries. Type = 4 (byte)
NumEntries = int
  • Name = UTF String
  • Host = UTF String
  • Port = int
    (repeated NumEntries times)
UPDATE Sent to all clients that have valid entries at periodic intervals.  Each update packet contains a serial number which can be used to uniquely identify the packet. Type = 5 (byte)
Serial = int
NumEntries = int
  • Name = UTF String
  • Host = UTF String
  • Port = int
    (repeated NumEntries times)

File Transfer

File transfer between p2p clients is done using a subset of the standard FTP protocol.  The official specification for FTP is contained in RFC 959.  The program that you write will provide a minimum implementation of FTP as defined in section 5.1 of RFC 959 with the following exceptions:

Other than the exceptions listed above your FTP server must be fully complaint with RFC 959.  In fact it should be possible to connect to your FTP server with a standard FTP client and transfer files.


previous next
version $Revision: 1.1 $, $Date: 2004/01/25 04:46:54 $, © by csfac@RIT All rights reserved.