Homework 4: An event-based BitTorrent client

In this assignment, we create our own BitTorrent client. All the work is IPv4, no IPv6. The template already does much of the heavy lifting. However, the template is multi-threaded, and can only leech. Your job is to:

  • Modify the template to no longer use threads. Instead, use select() to listen for incoming packets on multiple sockets simultaneously.Handle broken connections and other peer behaviors to ensure a reliable download.
  • Announce available pieces to peers and handle incoming piece requests to maximize performance.
  • Request pieces in the ideal order to minimize download time.
You'll find the template in svn://cs450.cs.uic.edu/pub/homeworks/hw4. Details of the bittorrent protocol can be found here: https://wiki.theory.org/BitTorrentSpecification.

Performance expectations

For full points, your solution should produce a correct file for a given .torrent. It must not rely only on seeds: its should download pieces from many peers, and it should finish significantly faster than simply getting all the pieces from the seed. Your program will be tested on the .torrent files in the hw4 directory only, but it is likely to work with many other .torrent files as well.

Turn-in requirements

Check in the source code and Makefile in a directory named hw4 in your turn-in directory. Here is an example run:


./hw4 cs450files01.torrent


There's no grading script for this homework. Points will be given as follows:

  • 6 points if no trace of pthreads in the program. try grep pthread and remove -lpthreads from the Makefile
  • 2 points for consistently finishing download of cs450files01.torrent (not the cs450files.torrent version)
  • 2 points for significant upload activity (measured with tcpdump)
  • 2 points for finishing faster than with only the seeds

  • -6 points if concurrent connections are not supported
Topic revision: r11 - 2013-03-16 - 17:19:49 - Main.yjin25
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF