Get MLDonkey to boost its performance under a PPPoE connection to the internet

By Ignacio Garcia: y123456o@ignasi.com (Delete 123456 to get the right email address)

Abstract: This document will help you boost the performance of MLDonkey to get the most of the donkey P2P network, connecting to the internet through an ADSL connection with PPPoE. MLDonkey will run under Linux. The distro I used for this experiment is SuSE 8.2. These guidelines should work with any distros, but I haven´t tested it.


NOTE: This document assumes that you, the reader, are proficient with Linux. I will not get into basics of Linux usage and configuration. I will not get into many details on how to configure MLDonkey. Most default settings are all-right. If you like to add details to this document, feel free to email them to me and I will include them.

NOTE: I only use the edonkey P2P network to download free files, such as Open Source Software, Shareware and Freeware.

First, a brief introduction to MLDonkey.

MLDonkey is an alternative to other programs that connect to the donkey P2P network, such as Emule, Edonkey2000, etc. MLDonkey is OSS (therefore, its source code is available), and runs on many operating systems, such as most UNIX derivatives, including Linux, FreeBSD, MaxOS X, and Windows.

MLDonkey´s web page is http://mldonkey.berlios.de. There you will be able to find the code, among other programs and plug-ins, including links to popular frontends for many OS. These frontends will help you use MLDonkey more comfortably. However, MLDonkey also comes with a web-based frontend and telnet access as well.

Download and Install MLDonkey

You can download and compile for yourself MLDonkey. You´ll need to download and compile as well the ObjectCalm packages to compile MLDonkey. Another option is to download the latest snapshots, in binary form. Although I have always preferred to compile the programs I like to use, I´m going to make an exception here. MLDonkey is a pain-in-the-butt program to compile, and SpiralVoice is doing a great job releasing the latest CVS snapshots, which include the latest features and support for the latest Lugdunum (edonkey) servers. You can download these snapshots here.

In order to install these packages I decided first to customize my system a little bit for extra security.

As root, create a mldonkey user:

adduser -d /home/mldonkey -s /dev/null mldonkey

Now decompress the SpiralVoice´s snapshot inside that directory. chown all files to mldonkey and create the start and stop scripts in that same directory. (I haven´t written these 2 scripts, I just saw them somewhere and applied some modifications):

start

#!/bin/sh
#
# Start script for mldonkey, written by mlroot
# you can add your own commands at the end of file
#
# variables
MLPATH=/home/mldonkey
MLBIN=mlnet
SLEEP=/bin/sleep
NC=/usr/bin/netcat
umask 0000
###########################
# you should not change this lines...
cd $MLPATH
./$MLBIN > /dev/null 2>&1 &
$SLEEP 10
###########################

# Overnet Support
OVER_IP1=`resolveip overnet.dyndns.org | awk '{print $6}'`
OVER_PR1=4665
OVER_IP2=`resolveip fudge.punkcookies.com | awk '{print $6}'`
OVER_PR2=12000
boot $OVER_IP1 $OVER_PR1
boot $OVER_IP2 $OVER_PR2


# you can change or add commands below STOPHERE and upper STOPHERE
#
# open Connection to telnet interface
sh -c "$NC localhost 4000 <<STOPHERE
clh
set max_hard_download_rate 35
q
STOPHERE"
# set max_hard_download_rate 35 is to start mldonkey at a initital 35k download speed.

# Delete it or adjust it to your needs.

stop

#!/bin/sh
#
# Stop script for mldonkey, written by mlroot
# you can add your own commands at the end of file
#
# variables
MLPATH=/home/mldonkey
NC=/usr/bin/netcat
###########################
cd $MLPATH
###########################

# if you want, cou can put commands like commit
# above close_fds
#
# first try to let the donkey kill itself
sh -c "$NC localhost 4000 <<STOPHERE
close_fds
kill
STOPHERE"

Use these 2 scripts to start and stop the mldonkey daemon. Set your mldonkey configuration to run the program as user mldonkey, in order to avoid potential security problems.

 

Get the most of MLDonkey

I´m not going to explain how the mldonkey P2P network works, but I will tell you that when you connect you can get either a low or a high ID. With low IDs you can only connect to people with high IDs. With high IDs you can connect to anyone. Also, some servers will not accept or give acess to low id clients up to a percentage of maximum connected users. In few words, it´s better if you can get a high ID.

In order to get a hihg ID you need to have a direct connection to the internet. If you have an ADSL connection, that means that either you need to use a regular modem (not router) for connecting just one computer, or you have a router with port redirection to the computer you have mldonkey installed, or have the routing capabilities of your router disabled and connect using the bridge mode.

Personally, I prefer the last and 1st options, in this order. If you have a router with port redirection, be aware that most routers have only 256 connection slots, and that might be not enough to take full advantage of MLDonkey, and doing some other stuff, like browsing the web or checking your email, at the same time. Here´s a sample configuration (This is probably not the most secured configuration; later I´ll show you how I have done it for myself.)

ADSL: 512kbps downstream and 128kbs upstream

Router: SpeedStream in bridge-mode (so it works just as a regular modem)

Linux MLDonkey system connected directly to the router with a real IP (and no firewalls).

If your ADSL connection runs through PPPoE, that means that you probably get dinamic IPs when you connect to the internet. Also, that means that when you IP changes your connection to the edonkey network will suffer from it. MLDonkey can detect your system´s IP changes, but it takes a long time just to detect it and act accordingly.

SuSE´s yast installation and configuration program can set up an ADSL PPPoE connection very easily. However, I prefer to use the rp-pppoe package included in the distribution. The greatest advantage is that, if your connection is lost, you can set it up to automatically connect again and run a set of programs or scripts after reconnection. For instance:

Create a script /usr/local/bin/myip, as follows:

#!/bin/sh
# This script will give you the IP Address of your system

/sbin/ifconfig ppp0 | awk '/inet addr:/ {split($2, arr, ":")
print arr[2]}'

Run the script. It will print in your console your IP address

Now create this other script /home/mldonkey/new_ip_mldonkey

#!/bin/sh
#
# Tell MLDonkey about our new IP
#
# variables
NC=/usr/bin/netcat
IP=`/usr/local/bin/myip`
DATE=`date`
# you can change or add commands below STOPHERE and upper STOPHERE
#
# open Connection to telnet interface
sh -c "$NC localhost 4000 <<STOPHERE
set client_ip $IP
c
q
STOPHERE" > /dev/null
echo "IP changed to " $IP "on" $DATE>> /tmp/new_ip_mldonkey

The last line creates or appends a value to a file in /tmp. I just have it to keep track on how often mldonkey has to change its IP configuration.

MLDonkey takes some minutes to reflect that change, but this certainly is faster than letting it notice it and do it for itself.

Now, just link the last script in /etc/ppp/ip-up.d/ and every time your internet connection is restarted, your MLDonkey will instantly know about the system´s new IP.

 

My personal configuration

My brother and I live in a building with just our 2 apartements. We have the whole building wired with ethernet connections to a small room where we keep our ADSL connection and a small machine (from now on, I´ll call it the server) with SuSE Linux 8.2 running the firewall/router (shorewall), mldonkey, dhcp, and samba services. We share an ADSL connection with 512kbps downstream and 128kbps upstream. Details on our configuration follow:

I´m not going to get into details on how to configure the server´s firewall, dhcpd, or samba. I´ll show you some tricks on how I have my server set up for continous 24-hour-a-day connection to the edonkey P2P network and get download speeds in the 35 to 55 K/sec. range continuously.

I have my firewall rules set up so the server will accept connections for most protocols handled by MLDonkey. Common ports are:

TCP: 5036,3999,6882,6346,6347,4002,4242,4661,4662,6667,4665,13000,17592,6347

UDP: 5035,3999,6882,6346,6347,4002,4242,4661,4662,6667,19500,4665,13000,17592,6347

It might happen that some ports might not be used by both tcp and udp protocols, but to be honest I was too lazy to figure out which, so I opened those ports for both protocols.

I have the same scripts explained above set up in the server. Then, I created a rc.local file in /etc/init.d, and linked it to rc3.d to load the /home/mldonkey/start script each time the computer turns on.

The moment MLDonkey starts it will search for edonkey-servers. My MLDonkey here has a limit of 3 simultaneous edonkey-server connections. It is not good to have many edonkey-servers connected at the same time. Keep a list with the best ones only!

I have checked in MLDonkey that files are placed automatically in the incoming folder after completion. The moment a file is complete we, from our Windows workstations, can access the file through samba using a mapped drive that points to the incoming folder in the server.

Since my brother and I are not always surfing the web I have created a set of rules to balance the use of our internet bandwitdth. From midnight to 2 pm on workdays we hardly use our computers. From 2 pm to midnight there is a chance someone in the building might want to surf the web. Therefore, I have set up 2 scripts that balance the maximum download and upload speeds avalaible for MLDonkey, and have put them in the crontab accordingly. The scripts are as follow:

maxspeed

#!/bin/sh
#
# Set max speed at nights
#
# variables
NC=/usr/bin/netcat

# you can change or add commands below STOPHERE and upper STOPHERE
#
# open Connection to telnet interface
sh -c "$NC localhost 4000 <<STOPHERE
set max_hard_download_rate 55
set max_hard_upload_rate 12
q
STOPHERE" > /dev/null

 

normalspeed

#!/bin/sh
#
# Set normal speed for regular hours
#
# variables
NC=/usr/bin/netcat

# you can change or add commands below STOPHERE and upper STOPHERE
#
# open Connection to telnet interface
sh -c "$NC localhost 4000 <<STOPHERE
set max_hard_download_rate 40
set max_hard_upload_rate 7
q
STOPHERE" > /dev/null

 

Since our ADSL´s upstream bandwidth is so low, we need to lower the upload rate to an unfortunately low value from 2 pm to midnight :-( MLDonkey is not as Emule, that will ratio your download rate against your upload rate if upload rate is less than 10K/sec. In fact, in MLDonkey you can set the upload rate to 0. This is something you should not do. The concept of a P2P network is to share, not to download only. Besides, if people did that, nobody would be able to download files. Be reasonably generous and set the upload rate accordingly to your upstream speed.

That is all... :)