Getting QoS right is essential for bandwidth-constrained links. Simple FIFO queues, which are what most basic routers implement by default, quickly fall apart when one host "misbehaves" and generates heavy traffic, clogging the uplink. Per-connection queueing (PCQ) or various fair-queueing (FQ) algorithms can help when you have a guaranteed or even somewhat stable uplink bandwidth, as is the case with dedicated fiber and most fiber PON or DSL links.
Enter LTE and radio links. Implementing queueing on these links is especially difficult, as they have very wide and even sub-second bandwidth variations. PCQ and FQ algorithms are not suited to this case, as they need to know the bandwidth "ceiling" under which to operate. The CAKE queueing algorithm, however, is much better equipped to handle such a scenario, as it can "auto-rate" the uplink bandwidth. It does so by watching the timing of incoming TCP ACKs. If they start arriving with delays, it infers that the uplink is congested (because the data packets that triggered those ACKs got delayed) and reduces the shaper rate. If the ACKs arrive smoothly, it cautiously increases the rate.
Configuring a basic CAKE queue on MikroTik Routers (ROS 7) involves defining two queue types (one for TX and one for RX) and a simple queue targeting the WAN interface:
/queue type
add cake-diffserv=besteffort cake-flowmode=dual-srchost cake-nat=yes cake-rtt=80ms kind=cake name=qtype_cake_tx
add cake-diffserv=besteffort cake-flowmode=dual-srchost cake-nat=yes cake-rtt=80ms kind=cake name=qtype_cake_rx
/queue simple
add max-limit=100M/100M name=queue_internet queue=qtype_cake_rx/qtype_cake_tx target=lte1
Here are a few things to note and potentially adjust.
In the /queue type section:
* cake-nat must be set to yes if you're performing NAT on the interface, as it will ensure CAKE is able to isolate individual flows.
* cake-rtt must be set to a realistic round-trip time to a typical internet destination. In my case, the RTT when I ping www.google.com or time.windows.com is about 50 to 80ms. I will set it to 80ms because I'd rather have a bit more bandwidth than tighter jitter. If tighter jitter were to be preferred, I'd set it closer to 50ms.
In the /queue simple section:
You can specify a bandwidth "ceiling", as I did setting 100 Mbps both for TX and RX, or leave it unlimited.
In my very brief testing with Speedtest.net and such I have found this setup effective not only in resolving the jitter problem under heavy traffic, but also in improving overall bandwidth, perhaps because of the reduction in "wasted" packets such as TCP retransmissions.
Bear in mind that CAKE is computationally expensive, and while newer ARM based routers will handle it no problem, my MIPSBE based BaseBox 5 runs a little bit closer to full CPU usage than I would like.


