aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: 1 [2]

Author Topic: UploadSpeedSense  (Read 9636 times)

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: UploadSpeedSense
« Reply #15 on: May 27, 2005, 06:40:26 PM »

Mr Faber,

I would like to invite you to write some lines about your experience with traffic shaping and aMule, and maybe explaining your configuration. We could put your essay in aMule wiki, and I believe we could all benefit from your experience.

thedude0001,

I think that the old 4K bug is saturating the uplink, and as most people don't know about it, it "seems" like the new aMule is performing better, but in most cases, setting the upload limit 4K below would have had the same results.

Cheers!
Logged

Mr Faber

  • Full Member
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 229
Re: UploadSpeedSense
« Reply #16 on: May 27, 2005, 07:21:46 PM »

I can post my config but I think GonoszTopi and lfroen are the experts so they can it better I think (http://forum.amule.org/thread.php?threadid=5466&sid=).
I have used a part of Fairnat and tweaked it to my needs.
I use four wondershaper classes but only two are needed for normal use. One for aMule and one for normal traffic. Both classes are seppareted through the wondershaper script in two classes. One for interactive and one for bulk traffic.
I have made some little changes to the wondershaper script but I am no expert so I don't know if this is needed for everyone.
By the way I have relativelly much upload (theoratically 64 KB but I used only 60 KB for the script because with it I have always a ping between 9-16 ms to my provider while aMule uploads as much as it can) so I don't know if it works as good for slower connections.
[EDIT]Hm, 61 KB/s seems to work as good as 60 but I haven't made a long test. Before I used tc I thought that my connection can only effort a little more than 50 KB (~55 maximum) because eMule couldn't upload more.
Now my system monitor shows always a changing upload of 58 KB to 61 KB so it seems to work. Linux and aMule rules :) [/EDIT]
If you really think that my configuration script is needed I can post it.

cu
Mr Faber
« Last Edit: May 28, 2005, 10:21:17 AM by Mr Faber »
Logged

Mr Faber

  • Full Member
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 229
Re: UploadSpeedSense
« Reply #17 on: May 28, 2005, 11:51:53 AM »

I will post my script here with some basic changes. I have removed two of the four classes because they aren't needed for most people. I have removed the download shaping too because it haven't any effect on aMule. To let the wondershaper function still work with nat I have made a dirty hack. I haven't the time to looking deeper into it and create two wondershaper functions. Maybe later but I think that experts can wrote it in some seconds :)

I use wondershaper classes in my script but I have changed some things. I removed the burst for the non interactive class because it could increase my ping from time to time as far as I know.
IMHO 90% is to low for the non interactive class so I replaced it. Since tc works nearly in real-time 99% shouldn't be to much for my connection but everyone can choose which percentage he wants.

The script isn't well designed and maybe has bugs but it works for me fine in the original version.
I am a newbie on linux and in traffic shaping so don't be to cruel :D . I hope that this will help someone.

Code: [Select]
# based on parts of Fairnat ([URL]http://www.metamorpher.de/fairnat/[/URL])
# and the wondershaper script ([URL]http://lartc.org/wondershaper/[/URL])

WAN_INF=eth0

percent=99   #percent of bandwith for non interactive classes
   
UPLOAD_LIMIT=488

UP_RATE_NORMAL=88
UP_RATE_AMULE=88

wondershaper()
{
# Make the positional parameters more readable.
# Use UC_ prefix to make sure that these variables belong to User_Class.
    UC_DEV=$1
    UC_PARENT=$2
    UC_MARK=$3
    UC_MARK1=$4
    UC_MARK2=$5
    UC_RATE=$6
    UC_CEIL=$7
   


# Add HTB class:
tc class add dev $UC_DEV parent 1:$UC_PARENT classid 1:$UC_MARK \
                  htb rate ${UC_RATE}kbit ceil ${UC_CEIL}kbit

# Add filter for this user.
tc filter add dev $UC_DEV parent 1: protocol ip \
                   handle $UC_MARK fw flowid 1:$UC_MARK

# high prio class 1:10:

tc class add dev $UC_DEV parent 1:$UC_MARK classid 1:$UC_MARK1 \
    htb rate ${UC_RATE}kbit ceil ${UC_CEIL}kbit burst 6k prio 1

tc class add dev $UC_DEV parent 1:$UC_MARK classid 1:$UC_MARK2 \
    htb rate $(($UC_RATE*$percent/100))kbit ceil $(($UC_CEIL*$percent/100))kbit prio 2

# all get Stochastic Fairness:
    tc qdisc add dev $UC_DEV parent 1:$UC_MARK1 handle $UC_MARK1: \
                  sfq perturb 10
    tc qdisc add dev $UC_DEV parent 1:$UC_MARK2 handle $UC_MARK2: \
                  sfq perturb 10

# TOS Minimum Delay (ssh, NOT scp) in 1:10:

    tc filter add dev $UC_DEV parent 1:$UC_MARK protocol ip prio 10 \
                   u32 match ip tos 0x10 0xff flowid 1:$UC_MARK1

# ICMP (ip protocol 1) in the interactive class 1:10 so we
# can do measurements & impress our friends:

    tc filter add dev $UC_DEV parent 1:$UC_MARK protocol ip prio 10 \
                   u32 match ip protocol 1 0xff flowid 1:$UC_MARK1


# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class:

    tc filter add dev $UC_DEV parent 1:$UC_MARK protocol ip prio 10 \
                   u32 match ip protocol 6 0xff \
                       match u8 0x05 0x0f at 0 \
                       match u16 0x0000 0xffc0 at 2 \
                       match u8 0x10 0xff at 33 \
                       flowid 1:$UC_MARK1

# Default: Put stuff in class 2.

    tc filter add dev $UC_DEV parent 1:$UC_MARK prio 100 \
                   protocol ip handle $UC_MARK fw flowid 1:$UC_MARK2
}

# removing old entries
tc qdisc del dev $WAN_INF root
################################################
##### WARNING - IT REMOVES EVERY MANGLE CLASS! IF YOU HAVE A FIREWALL IT CAN LACK SOME CLASSES! ####
################################################
iptables -F -t mangle
iptables -D -t mangle

# 1: Set TOS for several stuff.
    iptables -t mangle -A PREROUTING -p icmp -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --sport telnet -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --sport ssh -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --sport ftp -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --sport ftp-data -j TOS --set-tos Maximize-Throughput
    iptables -t mangle -A PREROUTING -p tcp --dport telnet -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --dport ssh -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --dport ftp -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A PREROUTING -p tcp --dport ftp-data -j TOS --set-tos Maximize-Throughput

# 3: Correcting TOS for large packets with Minimize-Delay-TOS
    iptables -t mangle -N CHK_TOS
    iptables -t mangle -A CHK_TOS -p tcp -m length --length 0:512  -j RETURN
    iptables -t mangle -A CHK_TOS -p udp -m length --length 0:1024 -j RETURN
    iptables -t mangle -A CHK_TOS -j TOS --set-tos Maximize-Throughput
    iptables -t mangle -A CHK_TOS -j RETURN

    iptables -t mangle -A PREROUTING -m tos --tos Minimize-Delay -j CHK_TOS

# 4: Modifying TOS for TCP control packets: (from [URL]www.docum.org[/URL] / Stef Coene)
    iptables -t mangle -N ACK_TOS
    iptables -t mangle -A ACK_TOS -m tos --tos ! Normal-Service -j RETURN
    iptables -t mangle -A ACK_TOS -p tcp -m length --length 0:256 -j TOS --set-tos Minimize-Delay
    iptables -t mangle -A ACK_TOS -p tcp -m length --length 256: -j TOS --set-tos Maximize-Throughput
    iptables -t mangle -A ACK_TOS -j RETURN
    iptables -t mangle -A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK ACK -j ACK_TOS

# 5: Networks
#normal traffic
########dirty hack##########
#since my standard script uses four wondershaper classes I used always marked packets. Due to the fact that my wondershaper function only works with marking I made this dirty hack. It seems to work but if someone is interested he can create two wondershaper classes instead or made something different (I don't know).
iptables -t mangle -A OUTPUT -d 0.0.0.0/0 -j MARK --set-mark 11
iptables -t mangle -A PREROUTING -d 0.0.0.0/0 -j MARK --set-mark 11
############################
#amule traffic
iptables -t mangle -A OUTPUT -m owner --cmd-owner amule -d 0.0.0.0/0 -j MARK --set-mark 12
iptables -t mangle -A OUTPUT -m owner --cmd-owner amuled -d 0.0.0.0/0 -j MARK --set-mark 12

tc qdisc add dev $WAN_INF root handle 1: htb default 11

tc class add dev $WAN_INF parent 1: classid 1:1 htb rate ${UPLOAD_LIMIT}kbit ceil ${UPLOAD_LIMIT}kbit
  #normal traffic
  wondershaper $WAN_INF 1 11 111 112 $UP_RATE_NORMAL $UPLOAD_LIMIT
  #amule traffic
  wondershaper $WAN_INF 1 12 121 122 $UP_RATE_AMULE $UPLOAD_LIMIT

cu
Mr Faber
« Last Edit: September 04, 2005, 02:38:11 PM by Mr Faber »
Logged

KingFish

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: UploadSpeedSense
« Reply #18 on: June 04, 2005, 09:56:40 PM »

Hi.
What's the main benefit of UBT in comparison to the old method?
I never had problems with upload bandwidth with aMule.. ok, maybe I'm the wrong one to say that (old line was 512kbit up, aMule set to 50k, 7k per slot; new line is 2mbit up, aMule set to 200k, 10k per slot :])
Logged

KingFish

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: UploadSpeedSense
« Reply #19 on: June 05, 2005, 01:28:39 AM »

Ok, I tried out recent CVS and now I know that it's a great addition! My average uploadrate is nearing my max setting even on the high setting of 200k smoothly. Thx alot for implementing it!
Logged

Mr Faber

  • Full Member
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 229
Re: UploadSpeedSense
« Reply #20 on: June 05, 2005, 03:16:20 PM »

Don't get me wrong but if you use traffic shaping you can upload nearly 256 Kilobyte with your 2 MBit connection without having a bad ping. That would be at least four slots more :D And if you need nearly all the bandwith aMule uploads only 10 KB or what you have configured with tc.

cu
Mr Faber
Logged

KingFish

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: UploadSpeedSense
« Reply #21 on: June 15, 2005, 06:41:50 PM »

WOOOOAAAAA~
Thx such alot, Mr Faber.
Just recompiled my kernel with netfilter and qos modules and used your script to setup the chains and all.. even after 5 minutes of webbrowsing it seems to do magic!
I set to UPLOAD_LIMIT=1920 in the script, you think it's a sane value for 2mbit?
Atm amule still runs with a fixed max of 220k, maybe I'll try something different (= higher) later today/tonight.
Logged

Mr Faber

  • Full Member
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 229
Re: UploadSpeedSense
« Reply #22 on: June 15, 2005, 07:36:57 PM »

I am happy that my script helped someone :). But please consider that it is a really basic script and I am no expert.
2 MBit = 1024 Kbit * 2 = 2048 KBit
I don't know your real limits so I would start with 2040 (one Kbyte lower). You can test your connection through pinging your provider. I would at first ping without the script and without aMule. After that I would run the script and start aMule.
You have to wait some time until aMule reaches the maximum upload and ping your provider. If the ping is much higher, lower your upload limit and rerun the script and wait a moment. Repeat this until your ping is normal or at least nearly normal.
To test purposes I would use 100% instead of 99%t. If you find your limit set it back to 99 or the value you want.

According to your post you have all needed modules. To verify this I would use the command "tc -s class ls dev eth0" (replace eth0 with your internet interface).
You can check in expample that the aMule classes aren't zero or when you ping that the rate of interactive normal traffic class (the first one) increases.

cu
Mr Faber
Logged

KingFish

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
Re: UploadSpeedSense
« Reply #23 on: June 15, 2005, 11:37:30 PM »

I noticed that remote work on my comp is much slower now (ssh, scp). Guess I'll have to play a bit to get optimum settings/classes for me :)
Thx alot so far!
Logged

Mr Faber

  • Full Member
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 229
Re: UploadSpeedSense
« Reply #24 on: June 16, 2005, 06:47:42 PM »

At first you should check that the separation in classes works fine (tc ...) and than use ping and not ssh or something like that to get the optimal value as I described. If your connection is stable you have nothing to change after finding the optimal value.

cu
Mr Faber
« Last Edit: June 16, 2005, 06:48:46 PM by Mr Faber »
Logged
Pages: 1 [2]