I have a router/gateway under Linux, I want to add some QoS to reserve bandwidth for a specific flow. This can be done with iptables/netfilter and tc, but all examples start from the fact that you know in advance the total bandwidth available.
Problem is, my WAN is a moving 3G connection, with variable performances. On day 1, I can have 5 Mbps, and rainy day 2 is down to 2 Mbps. How can I guarantee that my flow 1 will always have 100Kbps available with low latency?
I thought of a complex solution, with a daily or hourly script to check bandwidth and dynamically create and apply QoS scripts, but it's not a good solution to me.
You should be able to reach your goal with hfsc scheduler. You will have the ability to reserve a part of the bandwidth and give low latency guaranty with "real time", the other classes will proportionnally fill the rest of the bandwidth with "linkshare".
It is important here to use real time and not linkshare, because real time, in order to be sure to be able to send a packet at the very last miliseconds, is able to stop the other class to send a packet.
In order to accomplish what you want, you need to set a way to high upperlimit on the root class (10MB maybe), but no ul on leaf ones. Because of the way hfsc linkshare is sharing the bandwidth between all the "ls" class, they will share the available bandwidth, over the m2 value if there is more.
For example, you could use this kind of setup :
Values could need to be changed according to your need, especially in class 100, although I tried to write these numbers to fit to your 3G.
You should read more on man tc-hfsc, this post, and this article to learn more about hfsc and how it works.