lightTracker: BitTorrent Tracker Implementation using web.py

Alex Dong

http://www.alexdong.com/

Self introduction

Project Logistics

  • http://sourceforge.net/projects/lighttracker
  • Beta Status
  • SVN coming soon
    • database schema: db.sql
    • main source code: lightTracker.py
    • wrapper: runserver.py
    • automated integration test: testtracker.py
  • A quick demo
  • Contribution is encouraged. (CSDN competition?)

BitTorrent 101: Components

  • peers
  • torrent file
  • seeding
  • tracker
  • True P2P with DHT

BitTorrent 101: Scenario

  1. create .torrent file
  2. initial seeding
  3. peers contacts tracker
  4. inter-peer communication
  5. seeding after completion
  • Reference: bitTorrent Economics Paper[PDF]
  • Tracker Protocol Specification

    Why lightTracker

    • Not scalable: local pickled file.
    • Twisted based: powerful but difficult to understand
    • Tracker is a typical web application
    • Which web framework then?
      • web.py: one single very light web framework.
      • django: great community support. comprehensive.
    • We choose web.py because easy to deploy and its lightweight nature.

    web.py 101

    • Three fundamental elements:
      1. How data is retrieved and passed around.
      2. How presentation layer works with data.
      3. How URL, cookie, and session are supported.
    • web.py's 'Pythonic' answer:
      1. lightweight database gateway and the magic storify
      2. HTML based "cheetah" template, bound with objects
      3. Thinnly wrapped via storify objects.

    Code Walkthrough

    • database schema
    • runserver.py
    • lightTracker.py
      1. Section: Book keeping
      2. Section: Prepare response
    • testtracker.py: unittest based.
      1. class MetaInstruction
      2. _status_assertion (idea to make it less verbose?)

    Questions?