lightTracker: BitTorrent Tracker Implementation using web.py
Alex Dong
http://www.alexdong.com/
Self introduction
- Chinese name: 董洵
- Sr. Architect from Objectiva Software Solution
- Microsoft "Solution Architect" MVP for 2005-2007
- Experience: .NET, Java and C++
- Python Experience: 2 years with limited hands-on experience
- Python as algorithm language: 无废话阅读
- lightTracker to learn web frameworks. web.py and django
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
- create .torrent file
- initial seeding
- peers contacts tracker
- inter-peer communication
- 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:
- How data is retrieved and passed around.
- How presentation layer works with data.
- How URL, cookie, and session are supported.
- web.py's 'Pythonic' answer:
- lightweight database gateway and the magic storify
- HTML based "cheetah" template, bound with objects
- Thinnly wrapped via storify objects.
Code Walkthrough
- database schema
- runserver.py
- lightTracker.py
- Section: Book keeping
- Section: Prepare response
- testtracker.py: unittest based.
- class MetaInstruction
- _status_assertion (idea to make it less verbose?)
Questions?