Important
- This adaptation is using AdGuardHome to get DNS latency in real-time. You may want to visit the DNSCrypt-CAKE repository if you want to compare both tools.
- If there is a new update from the AdGuardHome repository, you only need to replace the
qlog.go
file from the new version using the one with CAKE support and it will work just fine. - If there is a new update with an updated
qlog.go
from the official repository, we will try to updateqlog.go
(with CAKE support) accordingly. - This adaptation was inspired by the cake-autorate project, but was not intended to replace that at all, since it is using a completely different approach. You are free to use whatever works best for you.
Note
The goal of this project is to provide another alternative that "just works" for not-so-technical users. Thus, users only need to set these values correctly: uplinkInterface
, miscInterfaceArr
, maxDL
, and maxUL
.
- About
- What to expect
- Congestion Control Consideration
- How it works
- How to compile the code
- See agh-cake in action
- Credits
CAKE (Common Applications Kept Enhanced) is a comprehensive smart queue management that is available as a queue discipline (qdisc) for the Linux kernel. It is one of the best qdiscs designed to solve bufferbloat problems at the network edge.
According to the CAKE's ROUND TRIP TIME PARAMETERS man7 page, if there is a way to adjust the RTT dynamically in real-time, it should theoretically make CAKE able to give the best possible AQM results between latency and throughput.
agh-cake
is an attempt to adjust CAKE's rtt
parameter in real-time based on real latency per DNS request using a slightly modified version of AdGuardHome. In addition to that, it will also adjust bandwidth
intelligently while constantly monitoring your real RTT.
This is an adaptation of dnscrypt-cake, inspired by the cake-autorate project, implemented in Go, but it's adjusting CAKE's rtt
and bandwidth
based on your every DNS request and what website you are visiting, not by only ping-ing to 1.1.1.1
, 8.8.8.8
and/or any other DNS servers.
This implementation is suitable for servers and networks where most of the users are actively sending DNS requests.
There are several things you can expect from using this implementation:
- You only need to worry about setting up
uplinkInterface
,miscInterfaceArr
,maxDL
, andmaxUL
correctly. - It will manage
bandwidth
intelligently (do a speedtest using Speedtest CLI or similar tools to see it in action). - It will manage
rtt
ranging from 10ms - 3600s. Unless your network is really that fast, you will see mostly 100ms RTT or higher andagh-cake
will adjust CAKE'srtt
accordingly. - It will manage
split-gso
automatically. - It is able to scale CAKE's
bandwidth
from 1 Mbit/s to 1 Gbit/s (or even more) in seconds.
Note
Just set maxDL
and maxUL
based on whatever speed advertised by your ISP. No need to limit them to 90% or something like that. The code logic will try to handle that automatically.
You may want to consider what TCP CC algorithm to use that works best for your workloads.
Different CC handles congestion differently, and that will affect how fast agh-cake
is able to restore the configured bandwidth when a latency increase is detected.
Below are the CC algorithms that we have tested and worked well with agh-cake
in a server environment:
reno
— The Reno TCP CCcubic
— The CUBIC TCP CCscalable
— The Scalable TCP CCdctcp
— The DCTCP TCP CChtcp
— The H-TCP TCP CChighspeed
— The High Speed TCP CCyeah
— The YeAH TCP CCbbr
— The BBR TCP CC (v1 and v3)
Important
dctcp
must not be deployed over the public Internet without additional measures.- Using
bbr
might cause issues such as frequent captchas on some websites or any other issues. This article by APNIC can give you some references on when you may want to use it.
- When a latency increase is detected,
agh-cake
will try to check if the DNS latency is in the range of 10ms - 3600s or not. If yes, then use that as CAKE'srtt
, if not then usertt 10ms
if it's less than 10ms, andrtt 3600s
if it's more than 3600s. agh-cake
will then adjust CAKE'sbandwidth
using all data in thedataTotal
slice/array.- The
cake()
function will try to handlebandwidth
,rtt
, andsplit-gso
in milliseconds.
Note
The cake()
function will configure CAKE and re-calculate rtt
and bandwidth
, then save the latest data into several slices/arrays. The arrays can hold up to 100000 data, and the cake()
function will loop infinitely.
-
Download and install The Go Programming Language.
-
Copy the files from
./agh-cake/cake-support
to./agh-cake/AdGuardHome/internal/querylog
. -
Edit the
qlog.go
file and adjust these values:uplinkInterface
andmiscInterfaceArr
to your network interface names.maxDL
andmaxUL
to your maximum network bandwidth (in kilobit/s format) advertised by your ISP.CertFilePath
andKeyFilePath
to where your SSL certificate is located.
-
Then, see the How to build from source section to compile the code.
Important
- You have to run the binary with
sudo
since it needs to change the linux qdisc, so it needs enough permissions to do that. - It's not recommended to change
cakeUplink
andcakeDownlink
parameters in theqlog.go
file as they are intended to only handlebandwidth
andrtt
. If you need to change CAKE's parameters, change them directly from the terminal. - Use
httpserverGin.ListenAndServe()
instead ofhttpserverGin.ListenAndServeTLS(CertFilePath, KeyFilePath)
in theqlog.go
file if you don't want to use SSL certificate (i.e. you're usinglocalhost
instead of0.0.0.0
).
We are testing agh-cake
in our server here:
https://net.0ms.dev:7777/netstat
See agh-cake
metrics here:
https://net.0ms.dev:22222/cake
A quick speed/bufferbloat test using Cloudflare Speed Test:
A quick speed/bufferbloat test using Waveform Speed Test:
Although we are writing this guide to let people know about our implementation, it was made possible by using other things provided by the developers and/or companies mentioned in this guide.
All credits and copyrights go to the respective owners.