UPDATE: Sorry to everyone who tried to download the source. I forgot to include the images used in the project! It should build without errors now. |
Torrantula is a BitTorrent client for Mac OS X and Windows written entirely in REALBasic. It is capable of downloading and seeding single and multifile torrents, and has an advanced user interface for monitoring download progress. It also has a web interface (currently under development) which allows torrents to be started remotely and viewed once they have downloaded.
|Download with Source|
Why REALBasic?I spent most of the summer working on a BitTorrent tracker. I read hundreds of pages of research about BitTorrent, and it sparked my curiosity. I wanted a client that I could play with: one that I could easily change and use to experiment with different piece selection algorithms and endgame modes, etc...
For that purpose, REALBasic seemed the obvious choice. I searched the web for existing implementations and didn't find any, so I designed and wrote the entire client from scratch. I wanted to get my hands dirty and learn about BitTorrent, and it worked. Like most REALBasic applications, Torrantula chews up memory and processor cycles like crazy - but it gets the job done, and it only took me a week and a half.
CapabilityI wouldn't recommend using this as your primary BitTorrent client. It's slow and heavy. However, if you're looking to implement BitTorrent in your REALBasic application, this will do everything you need. For those BitTorrent junkies, here's a more complete list of features:
- Torrents: Torrantula reads standard bencoded torrent files. You can open torrent files directly or specify a torrent url and let it download them. Single and multifile torrents are fine. It also checks for existing data if the file(s) already exist.
- Tracker Communication: Torrantula sends standard announce requests and can read compact and non-compact responses from a tracker. It does not send scrape requests and does not use any secondary trackers listed in the torrent file. It obeys the interval property returned by the tracker.
- NAT-PMP, STUNT: Torrantula doesn't implement any NAT traversal. In other words, it can't get through your router unless you manually configure port forwarding/DMZ. I don't think it is possible to do in REALBasic. At least not easily.
- Peer Search: Torrantula doesn't implement PEX or DHT. All peers must be returned by the tracker or injected manually.
- Peer Communication: Torrantula sends all the standard messages associated with the BitTorrent protocol as defined here:
http://wiki.theory.org/BitTorrentSpecification. It maintains a copy of each peer's bitfield and can display it as an image. It keeps track of "debt" to each peer as pieces are recieved, so it could be setup to more accurately determine which peers it should send data too. It logs data very aggressively and will display requests sent out and pieces recieved.
- Statistics Collection: I was interested in collecting block transfer statistics. Torrantula logs the throughput of every peer on a block-by-block basis. It does not calculate overall transfer rate, though.
- Piece Selection: The client was designed to be easy to modify. Piece selection is pretty straightforward and this version
supports two methods: In spread mode, pieces are sorted according to their rarity and then blocks are chosen from the rarest. Any piece which is partially
complete will be completed as quickly as possible. In streaming mode, earlier pieces are chosen first. I am working on a killer implementation of this which
uses a sliding "target" region and sends duplicate requests for late pieces, but it isn't finished yet.
In both modes, endgame begins when all pieces have been requested. Duplicate requests will be forced in order to keep all peers busy and get the data as quickly as possible.
Known IssuesTorrantula crashes occasionally when you start multiple downloads. At the moment, I am not sure why. REALBasic gives no reason, and the application quits without any notice. I'm not sure when it started happening. I believe there is a socket double-disconnect problem that is causing it.
Block requests are not "stacked" on peers. One request is sent, data is recieved, another request is sent, etc.. When I wrote the client I did not realize that most clients keep a request queue on the remote peer to improve performance.
DependenciesTorrantula requires the Monkey Bread Software plugin to compute SHA1 hashes of piece data. The GUI also uses Einhugur's IconLib to display OS-native file icons. I don't actually own the MBS plugin, so the downloadable beta version display's reminder messages occasionally.
Future DevelopmentThis is more or less the end of the road for Torrantula. I have learned an incredible amount about BitTorrent, and I feel this is a good basic implementation. However, I don't think REALBasic is powerful enough to create a beautiful and high quality client like Transmission or Azureus. I use a lot of other programming languages, and I think C++ or Objective C would be a much better choice if I were to develop a production quality client. I wrote this to learn about BitTorrent, and I think it could be a great resource for anyone looking to do the same. If you're interested in writing a BitTorrent app in REALBasic, or perhaps building BitTorrent capability into a game, etc..., this will take care of almost all the dirty work.
Copyright 2007 - J. Benjamin Gotow. You may reproduce this work however you want. Please drop me an email if you find it useful. I love being in about boxes!
Looking for more of my work? Visit http://www.gotow.net/