If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

How-to: Use your router as a BitTorrent Client

The main reason for me to choose for the Asus router was the BitTorrent client that was mentioned in several hundred reviews. However, as we all know, the one supplied by Asus is "less then perfect" and we still end up having to run our PCs 24x7 to get all those Linux distributions (or other type of downloads.... )

Thanks to the excellent work of K.C. (kfurge), we’ve gotten a whole lot closer to this dream. Now we have a descent telnet service and the option to install packages. It is now possible to run a torrent client on our server!

Several people already worked out how to get the below to work and hal2k1 already did quite a good job to explain how it’s done, but by putting it in the how-to section and explaining it in a bit more detail, it will hopefully be more accessible for other users as well.

For this how-to, I assume that you have some basic Linux knowledge. Like the ability to start a program or to traverse through directories.

3. Now you have all that running you’ll need to install 2 more packages: “screen” and “enhanced-ctorrent”.

Before you install these 2 programs, let me explain what they do:

The screen program is a virtual telnet session to your router. A bit like terminal services on Windows, but then textual based. So you can start a program inside this virtual telnet session, logout and later resume the session (even from another computer). The screen program has been around for a long time and is used for programs that need a long time to run like compiling a big program or to analyse SETI-data. The BitTorrent client is in the same category: It doesn’t require much interaction with the user, but from time to time you want to see the progress.

The enhanced-ctorrent client is a variation on the ctorrent program. The ctorrent program is actually the program that our ASUS router was using. This program was ok for it’s time, but the project is now asleep. Logically the enhanced version is better and still maintained so a much better way to go.

Now you know the 2 programs, it’s time to install them:

4 . The command for this is:

ipkg install screen
ipkg install enhanced-ctorrent

Testing the screen program:
Now you have the programs installed, you can try out the screen program. To start it, just type “screen” (without the quotes). As you see, the program simply starts with a fresh screen in your telnet session. Type a simple command like “ls”, just to get something on the screen.

Now press ctrl+d and ctrl+a

You should now see on your screen “[detached]” and the prompt again. Now you type exit to close your telnet session.

Start again your telnet session and logon to your router. Now type “screen –r” (the R stands for resume) to resume an earlier screen session.

As you can see the output of your earlier ls command is still there, including all the settings etc. So by pressing ctrl+d and ctrl+a again, you’ll detach the screen and “screen –r” you get back to it. If you don’t need the virtual screen anymore, you can simply type “exit” when you are inside the virtual screen and the virtual screen will stop (so no more screen to resume to).

I hope that the above makes it clear how the screen program works and how it is useful for all kind of long running programs.

Testing the enhanced-ctorrent program:
Before we can test this program, we’ll need a torrent file. To test this, find a torrent file that points to something popular and small. Ebooks are usually a good one to use. Download the torrent file with your webbrowser and place it somewhere on your router shared directories.

For example, place the file here: \\WL700gE\Myshare1\Download

(I assume that you are still logged into your router via telnet).

Go to that same directory: cd /shares/MYVOLUME1/MYSHARE1/Download

The enhanced-ctorrent program doesn’t need any complicated parameters to start.

Just type “enhcanced-ctorrent filename.torrent” and the download will start.

The first thing it will do list the content of the torrent file: Which files does it contain.
For all these files it will reserve the space already on your router. If you download for example an ISO file of a DVD, a 4gb file will be made in your hard drive, but will not actually contain anything yet.

At the bottom of the screen, you’ll see something like this:

Already/Total: 0/9 (0%)
Listening on 0.0.0.0:2706

So, you’ve already downloaded 0 of the 9mb of the file (since you just started with it) and that the program is listening on that port for clients.

The next line will be something like:

\ 0/18/0 [1/719/686] 0MB,0MB | 0,0K/s | 0,0K E:0,1

Have a look here (http://www.rahul.net/dholmes/ctorrent/userguide.html) for more details on what this exactly means, but it will give you very basic information and see that the download is in progress. The first character changes from / to – to \ to | just to give you a limited indicator that the process is still alive.

Like most torrent downloads, they seem to work best if you don’t look at them, this is where the screen program comes in.

For now, just press ctrl+c to stop the torrent client. You will now have your prompt again.

Start the screen program and now start the enhanced-ctorrent program again with the same command as before.

The first thing the torrent client will do is to check the file that was earlier downloaded. You’ll see something like this: “Check exist: 3/9”.

Once the entire check has been completed, it will resume the download and will show something like this:

Already/Total: 3/9 (33%)
Listening on 0.0.0.0:2706

The download continues now until it’s completed. Once that is done, it will tell you that on the screen and will still continue to seed for 72 hrs. After that point the program will automatically exit.

You can change the way the enhanced-ctorrent client works with a couple of parameters, this page (http://www.rahul.net/dholmes/ctorrent/userguide.html) will give you the parameters. Specially the upload and download limits would be useful. For example, adding “-U 15 –D 60” will limit your upload to 15 KB/s and download to 60 KB/s.

I hope that you understand how using this program together with screen will help you download stuff on your router without your PC running.

I know it’s not as nice and fancy solution as a program like utorrent or Azureus, but it does the trick.

Good luck with the download and let me know if I forget to include something in this here.