Inbound traffic shaping on unpredictable ADSL - the qosmon approach


  • Hello everybody,
    I've been using pfSense for some time now, and it's wonderful. I've never been able to solve a problem, anyway: QoS on unpredictable links. I've a 2Mbps/640Kbps ADSL but the cable is long and it can go up to 2.3 or down to 1.5, depending on the time of the day.
    For years, I've been unable to have a reliable inbound QoS here (and in many situations like this), unless I capped my ADSL at something like 1.4 Mbps, losing an important part of it.

    Some months ago, I installed Gargoyle router http://www.gargoyle-router.com/ on my home router. It has a feature called "Adaptive Bandwidth Control" (managed by the qosmon utility) which basically acts this way:
    The QoS is managed by a normal "HFSC" queue, managed via TC on Linux. You have to set the maximun possible downlink bandwidth (in the best conditions), which is a hard upper limit. So I could put 2.3 Mbit/sec. The the qosmon:

    • Keeps an eye on the bandwidth, continuously.

    • If it detects you're not too far from the limit you set and you're using more than one queue, it starts pinging a host (the uplink, generally speaking, but can be set)

    • If the ping time gets over a set limit (for me it's more or less 80msec), it just throttles down the upper limit of your root QoS queue, until the ping time gets back to a safe level

    • If the ping time is lower, it raises the root queue speed, little by little

    • If there's just one active queue and/or everything is far from approaching the upper limit, it just releases any limit and just sets back the original upper downlink limit

    It works. If I have just one queue active, it gets the full speed without any pinging test (we don't mind if there are congestions). But as soon as I start a VOIP call (for example), the qosmon detects it, starts to ping the uplink and throttles down the bandwidth to assure a good latency. And continues to monitor it. The result is excellent: no problems at all, even if all the queues are requesting bandwidth.

    Actually, the real advantage of qosmon is this adaptive bandwidth control.
    It would be cool to see it in pfSense. Having a look at the code (http://www.gargoyle-router.com/gargoyle/projects/gargoyle/repository/revisions/f9f06d8602f613ab0f5ff3a20f400d2c9f937c76/entry/package/qos-gargoyle/src/qosmon.c), it seems quite easy: except the plotting parts (we don't need them, we already have a good GUI on pfSense), we just need the pinging and throttling parts. While I think that the pinging one is already working, the throttling one can be trickier as talks directly to the kernel. So we just should make it tell the kernel to lower the root queue speed, in one way or another.

    If I had enough pf internal knowledge, I could try to adapt it but, sadly enough, I haven't. And I don't think it would be a good idea to modify, every second, the pf.conf and ask pf to reload it.
    So I'm asking you experts if you like the idea and if you think it could be done here. With something like this, I don't think that pfSense could have any competitor.


  • I second this.  It would be so useful, especially for home users with crappy ISPs, as well as others who use satellite links, DSL/cable with too many users on one pipe (most major cities), etc.
    I've always wondered if something like this could be included in pfSense, and I'd thought of using ping times to get an idea of link saturation.  Seems this actually put the idea to use!  Very nice.


  • Put a feature request for it in redmine.pfsense.org.
    Just that in pfSense its not so easy to monitor through ping since the icmp packets themselves are subject to throttling as well!

    While it can be given a thought in general just record it in redmine to have it always there when i find time to play with this option.


  • @ermal:

    Put a feature request for it in redmine.pfsense.org.

    Sure, I'll be doing it ASAP.

    Just that in pfSense its not so easy to monitor through ping since the icmp packets themselves are subject to throttling as well!

    Yes, but they can still give an idea of the situation. Actually, it's more or less the same in Gargoyle, but the result is excellent.

    While it can be given a thought in general just record it in redmine to have it always there when i find time to play with this option.

    Ok! I'll be doing it. Thank you for your kind attention!