Now: Tutorial for Web and Software Design > OS > Linux > OS Content
> Distributing Content with BitTorrent [Bookmark it]
Distributing Content with BitTorrent

Distributing Content with BitTorrent

Installing the torrent onto the web server

You need to make a minor addition to the web server's configuration settings to include the .torrent file extension as a new MIME type. Otherwise, the browser may attempt to read the torrent as a text file. If you're using Apache httpd, add the following to your httpd.conf file (and don't forget to restart the web server!):



AddType application/x-bittorrent .torrent

Upload the torrent to your web server. You can install a link on any of your web pages referring the torrent much in the same manner as you would for an ordinary HTML page:

<HTML>

<TITLE>Torrent Example</TITLE>

<BODY>

This is the <A

HREF="./pg_live1.3.3-SRA.iso.torrent">torrent</A>.

</BODY>

</HTML>

Setting up the tracker

Think of the tracker as the middleman to a financial transaction; he doesn't add anything to the product itself, but he makes it possible for both seller and the buyer to meet and carry out the transaction.

The Debian wrapper for the Python program bttrack.py is bttrack. This invocation puts the tracker on port 8090, recording all download activity in the file mydownloadlogfile.txt:

$ bttrack --dfile mydownloadlogfile.txt --port 8090

The switches control the logging information describing how to track the shared information. For further information, please refer to the source code or, in my case, the man pages, which the Debian distribution always includes.

Setting up the seed

The last piece of the puzzle is running the client itself. As I mentioned earlier, you need to run a client yourself if you are preparing to share a file for the first time; otherwise there will be no sharing. There are two kinds of command-line utilities that handle file sharing: single (btdownloadheadless.py) and multiple (btlaunchmany.py) file downloads. I will concentrate on the former.

The Debian command-line invocation is:

$ btdownloadheadless [ option ... ] torrent

The torrent can be either the URL or a file path. This invocation, used on my test platform, calls the torrent file directly from the web server. The --url switch refers to the torrent file, while the --saveas switch indicates the file path of the existing file I want to share with the world:

$ btdownloadheadless --url \

	http://localhost/pg_live.1.3.3-SRA.iso.torrent --saveas \

	./pg_live.1.3.3-SRA.iso

The client now connects with the tracker, informing it that it is ready to share a copy of pg_live.1.3.3-SRA.iso.

Here's another client invocation that I could have used. This looks for the torrent file on the client's own machine located in the current directory:

$ btdownloadheadless --saveas ./pg_live.1.3.3-SRA.iso \

	pg_live.1.3.3-SRA.iso.torrent

The client connects to the tracker, where it will synchronize its data. The larger the file, the longer it takes. My test machine took about two minutes before the sync completed. Here's a sample of the messages:

saving:         pg_live.1.3.3-SRAA.iso (382.6 MB)

percent done:   100

time left:      Download Succeeded!

download to:    /home/robert/tmp/pg_live.1.3.3-SRAA.iso

upload rate:    0.00 kB/s

upload total:   0.0 MiB

Optimizing BitTorrent

BitTorrent has an amazing amount of flexibility. You can control upload and download bandwidths, the ports you use for socket connections, the number of connecting clients, and the refresh rate reflecting changed or new torrents that become available on the tracker. You can even configure the system to take into account clients who are behind firewalls.

This next section covers only some of the neat tricks that you can use with BitTorrent. Refer to the BitTorrent documentation for a complete listing of what you can do.

Stats reporting from the tracker

Getting tracker statistics from my tracker is easy. I just direct my browser to the tracker's port, http://localhost:8099. The resulting HTML page returns data similar to:

BitTorrent download info



* tracker version: 3.4.2

* server time: 2005-03-29 13:50 UTC



               info hash                 complete downloading downloaded

4e98ea442573f5b8868537e970fd3ce6321e9e81        1           0          0

                                   0 files      1/1         0/0        0/0

                                                           

* info hash: SHA1 hash of the "info" section of the metainfo (*.torrent)

* complete: number of connected clients with the complete file 

  (total: unique IPs/total connections)

* downloading: number of connected clients still downloading 

  (total: unique IPs/total connections)

* downloaded: reported complete downloads (total: current/all)

* transferred: torrent size * total downloaded 

  (does not include partial transfers)



Prev  [1] [2] [3] Next

[Bookmark][Print] [Close][To Top]
  • Prev Article-OS:

  • Next Article-OS:
  • Related Materias
    Mastering Windows New Fire
    Creating Visual Studio Pro
    Better Registry Searching
    Windows XP File Sharing My
    Building Photo Uploaders w
    How to Remove Startup Prog
    Windows XP File Sharing My
    Registry Hacks for Servers
    Best Windows Admin Downloa
    How To Recover from Regist
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial