Latency/burst problem with HTB

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    Hi all :)

    I'm new to this list, as I'm new too to traffic shaping ;) I've
set up an FTP server in my ADSL line and I wanted it to serve as fast
as possible as long as I don't use my outgoing ADSL bandwidth, and
I'm currently using HTB for that (succesfully, I must add).

    The problem is (when the FTP server is serving higher than its
"rate" and near to its "ceil") that protocols like SMTP or POP-3,
when I use them as client, slow to a crawl because being short-burst
in nature never use the speed I have configured for them :(( I don't
know if I'm missing something, but other protocols seems to work OK.
For example, when I browse the web, pages start to download slowly,
DNS queries are very slow but once the pages start dowloading, speed
is pretty good.

    My setup is for a few PC connected to an ADSL router using
Ethernet cards, and I'm only shaping outgoing traffic in one box, the
one serving FTP. The other boxes are more or less inactive. My
shaping has an HTB discipline at root:

tc qdisc add dev eth0 root handle 1: htb default 110

    I've played with r2q, because it assigns too big a quantum to
some classes and too small a quantum to others, until I noticed that
using the default r2q assigned a very big quantum to classes that I
want big quantums for and very small quantum to classes I want very
small quantums for.

    After that I add a base class to be able to borrow bandwith,
althoug I'm not sure now if that's a good idea:

tc class add dev eth0 parent 1: classid 1:1 htb rate 100Mbit ceil 100Mbit

    This class has the speed and ceil of my Ethernet card (100Mbit).

    Now I add two major classes, one for general LAN traffic and
other for Ethernet traffic to the ADSL router:

# Hi speed class
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 95Mbit ceil 95Mbit
tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10

# Low speed class (ADSL)
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 256kbit ceil 256kbit

    As you can see, bandwidth cannot be borrowed, so I think I could
get rid of 1:1. Anyway, this shouldn't make any difference for
bursted protocols that now are slow. In the hispeed class I use 95 as
rate and ceil because being averaged values, I prefer to slow down
LAN traffic and ensure I always have a bit of unused Ethernet slots
so the low speed (ADSL) class doesn't have to wait. Should I specify
(100M-256k)bit for rate and ceil here?

    The low speed class gets 256kbit although my ADSL is capable of
upload at 300kbit. I give a bit for the other box that may use the
ADSL and runs an operating system without shaping ;) I want to make
sure that box has at least 50kbit more or less, no matter if I'm
serving FTP in my box.

    For general LAN traffic I've chosen an SFQ queue discipline since
I sometimes use many protocols at a time and adding a bit of fairness
is desirable, although a pfifo_fast will probably work here, too.

    Last, I add two classes below the ADSL class, one to shape FTP
traffic, the other class to shape the rest of traffic.

# Other ADSL traffic
tc class add dev eth0 parent 1:11 classid 1:110 htb rate 192kbit ceil 256kbit prio 0
tc qdisc add dev eth0 parent 1:110 handle 110: sfq perturb 10

# To filter FTP traffic 
tc class add dev eth0 parent 1:11 classid 1:111 htb rate 64kbit ceil 256kbit prio 1

    Here are the most important classes. They share bandwidth,
because I want the FTP server to borrow traffic if the ADSL is
otherwise unused. The FTP server gots 8Kbps and the rest of the
traffic 24kpbs.

    Finally, the filters:
tc filter add dev eth0 prio 1 protocol ip parent 1:0\
    u32 match ip dst 192.168.0.0/24 flowid 1:10

tc filter add dev eth0 prio 2 protocol ip parent 1:0\
    u32 match ip sport 0x3000 0x3000 flowid 1:111

tc filter add dev eth0 prio 2 protocol ip parent 1:0\
    u32 match ip sport 0x4000 0x4000 flowid 1:111

tc filter add dev eth0 prio 2 protocol ip parent 1:0\
    u32 match ip sport 0x20 0xff flowid 1:111

    I'm serving passive FTP only in ports from 0x3000 to 0x4fff, and
active FTP in port 20. The rest of LAN traffic (including FTP) is
sent to the hispeed class.

    As you can see, I give more priority to general ADSL traffic, and
I'm sure such traffic is NEVER 24kbps, always much less than that,
but if someone is using my FTP server at, let's say, 15kbps
(borrowing bandwidth and still with a backlog of 15-30 packets, I can
tell from the "tc -d -s" stats), if I try to download 300kB of email
using POP-3, the client slows to a crawl. If I browse many small
pages, the speed is slow. At the same time, browsing large pages or
downloading gcc-4.0.2 ;) gives a speed more or less similar to that I
would have without shaping and without the FTP server (well, a bit
less because the "burst effect" affects this transmissions too and
the slower pace in the ack packets makes FTP download a bit slower).

    I've played with burst and cburst values, and increasing burst in
class 1:110 (ADSL general traffic) and its parents to 16kb helps a
bit, as helps decreasing the burst in 1:111 (FTP traffic thru ADSL),
but I still get high latency, slow downloads, etc. If I stop
borrowing bandwidth things go a bit better, but I want to share
bandwidth.

    Am I doing anything wrong (probably a lot of things...)? Is slow
latency and slow "bursted protocols" a price to pay to have bandwidth
sharing and shaping? Is there any value I can tweak to make general
ADSL traffic more responsive? As you can see from the commands above,
I've assigned a higher priority to it to slow down latency, but...

    Thanks a lot in advance. I've read HTB documentation and, while
it is good and informative, it's not enough (for me) to know how to
solve this problem. I don't want to use any other qdisc because I
need a classful one and I don't fully understand CBQ (I understand
HTB MUCH better). Thanks again and pleased to meet you :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux