CPE 401/601 Computer Communication Networks

Spring 2011

Peer-to-Peer File Distribution System

Project due on Monday, Apr 18 at 1:00 pm

In this project, we will develop a simplified version of peer-to-peer file distribution system. The goal of the project is to develop a Napster-like filesharing system.

You may work in groups of two. The groups should be reported by Wednesday, Mar 23rd.


To keep the user interface simple, you should build two simple programs one for server and one for the peers.

The server program is responsible for (1) building and maintaining a list of active peers in the network, (2) building a database of files each peer is sharing, and (3) respond to search queries from peers.

The peer code should be started with the number for the peer's own control port, the name and port number of a central server, and a list of files to share. The peer will accept file requests from other peers through the control port and respond to them.

We will only exchange ASCII files in the system.

All server communication should use UDP as transport layer protocol whereas file transfer between the peers should use TCP.

Following are the application level messages sent from/to the server using UDP sockets:

Note that, there is no space after each message.

Following are the application level messages sent between peer using TCP sockets:

Note that, each file request is handled by a seperate active socket. This socket should be terminated when the file transmission is completed.


Report all major actions as the program communicates with other server/peers.

We assume file size to be at most 16K characters.

We assume a client to share at most 255 files.

We assume file names to be at most 64 characters without any white space characters.

When a malformed message is received report it in a log file named error.log.

If you are developing advanced features such as load balancing by dividing files into chunks, develop two versions of code. One with the required functionality and nothing more and another one with advanced features that you added.


You must submit all the source code with sufficient comments to help understand the code.

You must include in your submission a file named README that includes your name and a brief description of your submission, including the name of each file submitted along with a one line description of what is in the file.

If your code is not complete, tell us what works and what doesn't. If you are submitting code that does not compile, please tell us that as well. If you borrow code from someone else, you are required to tell us about it (this must also be documented in the code itself).

Finally, feel free to include a description of any problems you had or anything else you think might be helpful to us.


Your project will be tested to make sure it works properly. We will test your clients and servers against each other. That is, your server should be able to exchange files with clients developed by someone else.

Your grade will depend on the functionality and the code quality. Hence, please pay careful attention to clean, modular and extensible design as you implement the project. This is also an opportunity to experiment with rapid prototyping languages such as Python, Ruby, and others.

There will be bonus grades for extra functionality not required by the project (optional and at the discretion of the instructor).

Submitting your files

Submission of your project is via WebCT. You must submit all the required files in a single tar or zip file containing all the files for your submission.