User Tools

Site Tools


bt-tutorial:local-setup

A first BitTorrent experiment

Preamble

In this tutorial we will assume that you have a small VCT testbed with three nodes and one sliver up, running as we describe on the second part of this tutorial. Also, we assume that all the commands will be executed from the ~/confine/utils/vct directory.

After finishing this tutorial we will have one CONFINE virtual node running an opentracker and two CONFINE virtual nodes running a Transmission command-line application and sharing a small file among them.

These are the steps we will follow to deploy our experiment:

  • Install the BitTorrent tracker (opentracker).
  • Install the BitTorrent clients (Transmission) in two different slivers.
  • Set up the sliver containing the BitTorrent client that will seed the file.
  • Run the experiment.

Installing opentracker

We are going to install the opentracker on the 0123456789ab_fd01 sliver. So, first of all start it (if you did not do so on the previous tutorial) and log in using VCT. An convenient step before starting ot work with a new Debian distribution is to update the package list.

~$ ./vct_sliver_start 0123456789ab fd01
 
~$ ./vct_sliver_ssh 0123456789ab fd01
 
root@0123456789ab_fd01:~$ apt-get update

The next step is, of course, installing the necessary dependencies to compile libowfat and the opentracker software. Now we will follow the opentracker website tutorial to install the software inside our sliver.

root@0123456789ab_fd01:~$ apt-get install make cvs zlib1g-dev
 
root@0123456789ab_fd01:~$ cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat
root@0123456789ab_fd01:~$ cd libowfat
root@0123456789ab_fd01:~/libowfat$ make
 
root@0123456789ab_fd01:~/libowfat$ cd ..
 
root@0123456789ab_fd01:~$ cvs -d:pserver:anoncvs@cvs.erdgeist.org:/home/cvsroot co opentracker
root@0123456789ab_fd01:~$ cd opentracker
root@0123456789ab_fd01:~/opentracker$ make

Notice that we did not modify the Makefile file, so opentracker has been compiled only with IPv4 support. To start testing it, just execute it on TCP/UDP port 80 of TRACKER_ADDR, the address of the sliver's IPv4 public interface pub0 (in our case TRACKER_ADDR has the value 10.241.0.7, please check yours with ip -4 addr show dev pub0). For an explanation on sliver interfaces and addresses, see the node architecture.

root@0123456789ab_fd01:~/opentracker$ ./opentracker.debug -i TRACKER_ADDR -p 80 -P 80

The default opentracker web interface is enabled on http://TRACKER_ADDR:80/stats and will show 0 torrent files, 0 conencted peers and 0 files shared.

Keep it running.

Installing Transmission

We are going to install the Transmission software on the 0123456789ab_fd02 and 0123456789ab_fd03 slivers. So, open a new terminal window, start the slivers – if you didn't before – and log inside them to replicate the next part of the tutorial on both nodes. As an example, we will execute next commands on the sliver running on node fd02.

~$ ./vct_sliver_start 0123456789ab fd02-fd03
 
~$ ./vct_sliver_ssh 0123456789ab fd02

As we did on our first sliver, we have to update the packages list first, and install all the necessary software. Luckily, all we need can be provided by the APT package manager.

root@0123456789ab_fd02:~$ apt-get update
 
root@0123456789ab_fd02:~$ apt-get install vim transmission-cli transmission-common transmission-daemon

The *NIX editor is necessary in order to modify the transmission configuration file. We chose Vim because we are more familiar with it, but you are free to use your preferred text editor.

Each time the Transmission daemon is started, it loads its configuration file. So, we need to stop it first.

root@0123456789ab_fd02:~$ service transmission-daemon stop
service transmission-daemon stop
 
root@0123456789ab_fd02:~$ vim /var/lib/transmission-daemon/info/settings.json

The settings.json file controls the whole daemon configuration. There are a lot of available options – most of them self-explanatory – but we wil focus on RPC options that control the web interface access.

:!: Note that we do not modify the bind interfaces options. As we are going to use the sliver as our base template later, the network interface will change.

Your default Transmission configuration file will look like this:

{
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": false,
    "dht-enabled": true,
    "download-dir": "/var/lib/transmission-daemon/downloads",
    "download-limit": 100,
    "download-limit-enabled": 0,
    "encryption": 1,
    "incomplete-dir": "/root/Downloads",
    "incomplete-dir-enabled": false,
    "lazy-bitfield-enabled": true,
    "lpd-enabled": false,
    "max-peers-global": 200,
    "message-level": 2,
    "open-file-limit": 32,
    "peer-limit-global": 240,
    "peer-limit-per-torrent": 60,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": 0,
    "pex-enabled": true,
    "port-forwarding-enabled": false,
    "preallocation": 1,
    "proxy": "",
    "proxy-auth-enabled": false,
    "proxy-auth-password": "",
    "proxy-auth-username": "",
    "proxy-enabled": false,
    "proxy-port": 80,
    "proxy-type": 0,
    "ratio-limit": 2.0000,
    "ratio-limit-enabled": false,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "{d5d639bf9662b82f7d4810b50cb4c129c60d552bhERHBes4",
    "rpc-port": 9091,
    "rpc-username": "transmission",
    "rpc-whitelist": "127.0.0.1",
    "rpc-whitelist-enabled": true,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "start-added-torrents": true,
    "trash-original-torrent-files": false,
    "umask": 18,
    "upload-limit": 100,
    "upload-limit-enabled": 0,
    "upload-slots-per-torrent": 14
}

We have to set to false the rpc-whitelist-enabled parameter to allow users from anywhere to connect to the Transmission web interface.

    "rpc-whitelist-enabled": false,

Now we are ready to save the changes, start the service and log into the web interface.

root@0123456789ab_fd02:~$ service transmission-daemon start
Starting bittorrent daemon: transmission-daemon.

The web interface will be accessible then through the URL http://PUB_ADDR:9091/, where PUB_ADDR is the address of the sliver's IPv4 public interface pub0 (in our case PUB_ADDR has the value 10.241.0.8 for the sliver at node fd02 and 10.241.0.9 for that in fd03, please check yours with ip -4 addr show dev pub0). If you did not change the rpc-username and rpc-password options you should be able to authenticate using transmission both as username and password.

The queue is, of course, empty because we have no files to download.

Running the experiment

To test our experiment, we need a complete file seeded by one of the clients (in our case, the sliver at node fd02) and another one downloading it (that at fd03). Let us prepare the seeder sliver first.

Seeder setup

Log inside the sliver at node fd02 and install the extra packages needed to download our shared file.

root@0123456789ab_fd02:~$ apt-get install wget

Then we need a file to download. It should be large enough to take some time to download it, but not too much (because we are running on our free space). So, we choose the VCT container image from our public images repository. Download it and place on transmission download directory.

root@0123456789ab_fd02:~$ wget http://images.confine-project.eu/vct-container,2012051700.tar.xz
 
root@0123456789ab_fd02:~$ mv vct-container,2012051700.tar.xz /var/lib/transmission-daemon/downloads/file.tar.xz

One advantage of Transmission over other BitTorrent clients is that, additionally to its web-based interface, it also provides useful command line tools. We will use some of them to create our torrent file and publish it.

First, make sure your opentracker is still running, and execute the next command pointing to your tracker interface (TRACKER_ADDR defined above).

root@0123456789ab_fd02:~$ transmissioncli -n /var/lib/transmission-daemon/downloads/file.tar.xz -c "Example file" -a http://TRACKER_ADDR:80/announce file.torrent

A new file.torrent file should have been created containing the necessary information to contact the opentracker and download this file from the peers. It is time to publish it!

root@0123456789ab_fd02:~$ transmission-remote -n transmission:transmission -a file.torrent -t daemon

If you check your opentracker or Transmission interfaces, you will see your file available.

There is, of course, one torrent file announced in the tracker, with 1 peer connected (the client in sliver at node fd02, which has the whole file).

Starting the experiment

Our experiment consists in downloading a file from multiple clients inside a BitTorrent network. For now, we have configured a tracker and a torrent client on different CONFINE virtual slivers at nodes fd01 and fd02. We also configured a third sliver at node fd03, from where we will download the announced file. But before that, we need to get the torrent file descriptor.

Now, from inside the sliver at node fd03 type:

root@0123456789ab_fd03:~$ scp root@PUB_ADDR:/root/file.torrent .

Where PUB_ADDR is that of the sliver in node fd02 as defined above. Remember that the user and password on Debian slivers are, by default, root:root.

Finally, we can start our experiment, just use the torrent file to subscribe to other peers and download the file:

root@0123456789ab_fd03:~$ transmission-remote -n transmission:transmission -a file.torrent

The opentracker and Transmission web interfaces show now the new update.

bt-tutorial/local-setup.txt · Last modified: 2014/04/22 18:15 by esunly