CS 580 Client-Server Programming

Spring Semester, 2005

Assignment

Assignment Index

© 2005, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 2/3/05

Assignment 2

Due Feb 15

1. Write and test a decoder that decodes a Bencoded string. The decoder needs to recreate the objects represented in the Bencoded string.

2. Add to your library the ability to read a file and produce a Bencoded string of the file’s meta-information as given below. Note that you will be building a client and a server that needs to create such information. They will both use the information in the file meta-information.

File Meta-Information

Information about files is bencoded. The information is a bencoded dictionary, containing the keys listed below. All string values are UTF-8 encoded.

length: length of the file in bytes (integer)

name: the filename of the file (string)

pieceLength: number of bytes in each piece (integer). This should be a power of 2.

pieces: a list consisting of all 20-byte SHA1 hash values, one per piece (a list of bencoded raw binary strings)

md5Sum: a 32-character hexadecimal string corresponding to the MD5 sum of the file

keywords: list of keywords for the file, keywords are provided by a client when they submit a file to the server. (list of strings)

id: string given to the file by the server which is use to identify the file. (string)

Note that this is not the same as the BitTorrent file meta-information. When a file is transmitted between client and server (or peers in BitTorrent) it is broken in to small parts. To ensure that the data is transmitted without error and that the data has not been altered the file meta-information contains both the md5Sum of the file and SHA1 of pieces of the file. The SHA1 allows one to validate parts of the file. If one piece is invalid one does not have to download the entire file, but just that piece.

Grading

Item

Percent of Grade

Working Code

50%

Unit Tests

20%

Quality of Code

30%

Working Code. How well your code meets the functional requirements listed above accounts for 30% of the grade for the assignment.

Unit Tests. Having unit tests that cover the functionality of your code accounts for 20% of your grade. The unit tests are to be scalable. Tests using just print statements are not scalable.

See http://www.junit.org/ for more information about JUnit. For C++ and C# you can get the equivalent testing framework at http://www.xprogramming.com/software.htm

Quality of Code. Having good quality of code counts for 30% of the grade. Quality of code includes formatting, names and modularity.

What to Turn in

Turn in the source code and your unit tests. You also need to place the source code in your course repository.