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:
|
![]() |
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:
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
|
| 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
|
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.