Programming Assignment 4

This assignment is to be done individually. Do not show your code to others and do not look at other students' code. Prevent other students from accessing your code (do not put it in a public directory). However, you are free to use any tools you like (library, search engines), to discuss problems with others, and to seek the help of the TA or the instructor.

Objective

The objective of this assignment is to familiarize yourself with a model different from the client-server paradigm. The resulting software will also serve as the basis for programming assignment 5!

Assignment: Peer-to-Peer File Sharing

In this assignment you will implement a P2P file sharing application according to the specification given below. The application will consist of two components: (a) a server discovery component and (b) a file transfer component. You can choose any programming language.

Protocol Description

Your P2P protocol will use the centralized index approach. You will implement two programs, a centralized 'p2pregistry' and a client/server application 'p2pservent'. Your protocol will implement the four key operations of P2P applications: join, publish, search, and fetch.

Join: The registry will listen to a TCP socket at a well-known port. A new servent will contact the registry at this port and indicate its presence. In addition, the registry also listens to a UDP socket and every 60 seconds the servent issues a 'HELLO' message to the UDP port of the registry. If the registry has not received a HELLO message from a servent in 200 seconds, the servent is removed from the list of available servents.

Publish: After registration, the servent sends a list of files available at the servent to the registry (e.g., all files in a directory specified as command-line parameter).

Search: A servent looking for a file contacts the registry. The registry looks for the file in its database (matching names) and returns the contact address of the servent if an entry was found (the first matching entry).

Fetch: The searching servent contacts the servent with the file and requests the transfer of the file across a reliable socket and places the file in the same directory as the shared files.

Implementation Details

You can use code from previous assignments. All communication will be across TCP sockets except the HELLO messages which are UDP datagrams. The registry has to listen to a well-known ports for registration of new servents and for file queries. Each servent also listens for requests for file transfers on a TCP socket.

Error Handling

The following error handling is expected: all return values of the system calls have to be checked and the correct number of command-line parameters for the client (if any). If the registry cannot find a requested file, the client prints a simple error message. Similarly, if a servent does not respond to a file request, the client prints a simple error message.

Evaluation

Start your registry and two servents (on at least two different nodes). Each servent registers at least 3 different files (e.g., simple short text files such as your source files). In your evaluation show the structure or content of your database at the registry after the registration of the two servents.

Grading

The grading will be according to the grading policy on the course webpage.

Submission

The due date for this assignment is April 4, 2005, 11.59pm EST. You will use the drop-off boxes (you will find a box with your login name). Make a directory called "project4" and place all required files into this directory (either individually or as one tar file). The required files are: all source files, a Makefile, one run script for the required test case, the shared files, and a document called README (ASCII file) or readme.ps or readme.pdf (postscript file), which contains a project summary, your solution approach, any encountered problems and how you solved them, any unresolved issues, and a usage explanation. The document should be not more than 2 pages.
Late submissions: 25% penalty after the deadline and another 25% for every 24h after the deadline.