Inbound traffic shaping on unpredictable ADSL - the qosmon approach
|Affected version:||Affected Architecture:|
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.