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.

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.

connectable

First of all thanks for writing this How To:

And to all who are making this beautifull white box into a monster ... You are doing a hell of a great job

I have a little problem with my firewall...
when I disable the firewall on the webpage all is going great
when I enable the firewall and set portforwarding 2700:2710 --> 192.168.1.1(Router) It gives me a error in enhanced-ctorrent because I'm downloadin from private trackers and they can't connect to me so can't downlaod from them

My question is how to set up my firewall correct in this beast so everything is protected

Grtzz
Ron

(EDIT) did someone already testet how many torrent's can be ran at the same time ??
I'm currently running 6 torrents all is going well ad my box makes a lot of noise AND fast speeeeeeeds

I have a little problem with my firewall...
when I disable the firewall on the webpage all is going great
when I enable the firewall and set portforwarding 2700:2710 --> 192.168.1.1(Router) It gives me a error in enhanced-ctorrent because I'm downloadin from private trackers and they can't connect to me so can't downlaod from them

Isn't it better to OPEN the ports to your WAN address than to forward them to the LAN?

see my other post in iptables topic, but generally
iptables -I INPUT 7 -p tcp --dport 2700:2710 -j ACCEPT
should do the job for 2700-2710 work

Anyway, due to masquerade is could work also with FW on and no port open

BTW: enhanced-ctorrent uses 2706-2106 as default

Unofrtunately, I am almost unable to get any download to reasonable speed (5-10 times slower than utorrent behing the router) - even disabling the firewall does not work :-(

I'm not downloading that much to check - but I suspect that utorrent DHT feature makes the difference (it sees much bigger number of peers). As my line speed is 10Mbit symmetrical it can boost the DL speed to over 500kbit/s with some torrents whereas enhanced-ctorred gets maximally 60-70.

Other reason could be the torrents/trackers I'm downloading from - usually public with few seeds/peers (I guess that's where DHT helps utorrent to find other peers/seeds).

as I mentioned before I only download from private trackers so I have DHT always disabled
My line speed is adsl2+ max20Mb a good 1600KB down and max 120KB up
when I download on my pc I gat a speed of 1000 down agains 55 up
but when I download with my router the speed is changing to 700 down and 250 up... How can my router upload @ 250 when my max up speed is 120

Probably has to do with how many connections the router can handle at any given time. DHT can help but it wont matter if the client/router can't connect to atleast 50-100 peers if there is that many in the swarm.

Here is are 2 dumb question:
1. Since enhanced ctorrent seems to be command line compatible with the asus ctorrent program, why not just replace the ctorrent executable in the custom firmware with your enhanced ctorrent version? That way the asus utilites should work together with the improved torrent client?

2. OR install enhanced ctorrent to the opt directory and change the name to ctorrent. That way if the system finds this ctorrent before the built in asus version it will use the fixed version without the file size limitation?

Here is are 2 dumb question:
1. Since enhanced ctorrent seems to be command line compatible with the asus ctorrent program, why not just replace the ctorrent executable in the custom firmware with your enhanced ctorrent version? That way the asus utilites should work together with the improved torrent client?

2. OR install enhanced ctorrent to the opt directory and change the name to ctorrent. That way if the system finds this ctorrent before the built in asus version it will use the fixed version without the file size limitation?

hey guy´s i checkt on that error message a lot people get when they try to download stuff with ctorrent. I sent a email to one of the guy´s who made that programm. To get all the answeres they need to help us, I need the help of you guy´s who implemented that programm in the firmware. Here you go with the stuff they need:

Email:
> > hi,
> > i checked out your programm (enhanced ctorrent) well, when i tryed do
> download a file, i typed in like enhanced-ctorrent filname.torrent it shows
> me all of the file info, but no progress or stuff. on the very button it
> shows this message: "Segmentation fault" (i made a screenshot of it:
> http://home.mnet-online.de/luckynuts/torrent.JPG ) Why doesn?t it download or stuff?
> >
> ------------------------------------
> First, please verify that you're using release dnh2.2 (the first line
> of output when running ctorrent with no parameters will indicate the
> version); versions prior to dnh2 could not handle torrents over 4GB.
> Also let me know what parameters (options) you are using.
>
> Assuming you're on dnh2.2, we'll need to try to get some debugging
> information. Please insure that your ctorrent binary has not been
> "stripped"; a 'make install' or package installation may do this.
> The binary should be around 350K. If it is significantly smaller,
> recompile the program and copy "ctorrent" from the work directory
> rather than performing an install.
>
> When the problem happens, you should get a core dump; run a gdb
> backtrace on it, as follows. You'll likely need to specify the
> full path to ctorrent, and the path and name of the core file if
> not in the current directory.
> 1. $ gdb -se ctorrent -c *.core
> 2. (gdb) bt
> 3. (gdb) quit
>
> Please send me a copy of the output from the "bt" command (cut and
> paste is fine). Keep a copy of the ctorrent executable and the core
> file if possible in case some additional information is needed.
>
> +----------------+-----------------+----------------------------------+
> | Dennis Holmes |dholmes@rahul.net| "We demand rigidly defined areas |
> | San Jose, CA +-----------------+ of doubt and uncertainty!" |
> +----=>{ Meanwhile, as Ford said: "Where are my potato chips?" }<=----+