cake-autorate is a script that minimizes latency by adjusting CAKE bandwidth settings based on traffic load and round-trip time measurements. See the main README page for more details of the algorithm.
cake-autorate provides an installation script that installs all the required tools. To use it:
-
Install SQM (
luci-app-sqm
) and enable and configurecake
Queue Discipline on the interface(s) as described in the OpenWrt SQM documentation -
Alternatively, and especially if you may have more complex networking needs:
- DSCPs - consider cake-simple-qos;
- WireGuard with PBR - consider cake-dual-ifb.
-
Use the installer script by copying and pasting each of the commands below. The commands retrieve the current version from this repo:
wget -O /tmp/cake-autorate_setup.sh https://raw.githubusercontent.com/lynxthecat/cake-autorate/master/setup.sh sh /tmp/cake-autorate_setup.sh
-
The installer script will detect a previous configuration file, and ask whether to preserve it.
-
For a fresh install, you will need to undertake the following steps.
-
Edit the config.primary.sh script (in the /root/cake-autorate directory) using vi or nano to set the configuration parameters below (see comments in config.primary.sh for details).
-
Change
dl_if
andul_if
to match the names of the upload and download interfaces to which CAKE is applied. These can be obtained, for example, by consulting the configured SQM settings in LuCI or by examining the output oftc qdisc ls
.| Variable | Setting | | -------: | :----------------------------------------------- | |
dl_if
| Interface that downloads data (often ifb4-wan) | |ul_if
| Interface that uploads (often wan) | -
Set bandwidth variables as described in config.primary.sh.
| Type | Download | Upload | | ---: | :------------------------- | :------------------------- | | Min. |
min_dl_shaper_rate_kbps
|min_ul_shaper_rate_kbps
| | Base |base_dl_shaper_rate_kbps
|base_ul_shaper_rate_kbps
| | Max. |max_dl_shaper_rate_kbps
|max_ul_shaper_rate_kbps
| -
Choose whether cake-autorate should adjust the shaper rates (disable for monitoring only):
| Variable | Setting | | ----------------------: | :----------------------------------------- | |
adjust_dl_shaper_rate
| enable (1) or disable (0) download shaping | |adjust_ul_shaper_rate
| enable (1) or disable (0) upload shaping |
-
-
The other configuration file - defaults.sh - has sensible default settings. After cake-autorate has been installed and is running, you may wish to change some of these.
-
For example, to set a different
dl_delay_thr_ms
, then add a line to the config like:dl_delay_thr_ms=100
-
The following variables control logging:
| Variable | Setting | | -----------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
output_processing_stats
| If non-zero, log the results of every iteration through the process | |output_load_stats
| If non-zero, log the log the measured achieved rates of upload and download | |output_reflector_stats
| If non-zero, log the statistics generated in respect of reflector health monitoring | |output_summary_stats
| If non-zero, log a summary with the key statistics | |output_cake_changes
| If non-zero, log when changes are made to CAKE settings viatc
- this shows when cake-autorate is adjusting the shaper | |debug
| If non-zero, debug lines will be output | |log_DEBUG_messages_to_syslog
| If non-zero, log lines will also get sent to the system log | |log_to_file
| If non-zero, log lines will be sent to /tmp/cake-autorate.log regardless of whether printing to console and after every write the log file will be rotated f eitherlog_file_max_time_mins
have elapsed orlog_file_max_size_KB
has been exceeded | |log_file_max_time_mins
| Number of minutes to elapse between log file rotaton | |log_file_max_size_KB
| Number of KB (i.e. bytes/1024) worth of log lines between log file rotations |
-
To start the cake-autorate.sh
script and watch the logged output as
it adjusts the CAKE parameters, run these commands:
cd /root/cake-autorate # to the cake-autorate directory
./cake-autorate.sh
- Monitor the script output to see how it adjusts the download and upload rates as you use the connection.
- Press ^C to halt the process.
You can install cake-autorate as a service that starts up the autorate process whenever the router reboots. To do this:
-
Run these commands to enable and start the service file:
# the setup.sh script already installed the service file service cake-autorate enable service cake-autorate start
If you edit any of the configuration files, you will need to restart
the service with service cake-autorate restart
When running as a service, the cake-autorate.sh
script outputs to
/var/log/cake-autorate.primary.log (observing the instance
identifier cake-autorate_config.identifier.sh set in the config file
name).
WARNING: Take care to ensure sufficient free (Flash) memory exists in router to handle selected logging parameters.
OpenWrt devices can save files across upgrades. Read the Backup and Restore page on the OpenWrt wiki for details.
To ensure the cake-autorate script and configuration files are preserved, enter the files below to the OpenWrt router's Configuration tab
/root/cake-autorate
/etc/init.d/cake-autorate
- cake-autorate has been designed to run multiple instances simultaneously.
- cake-autorate will run one instance per config file present in the /root/cake-autorate/ directory in the form:
config.interface.sh
where 'interface' is replaced with e.g. 'primary', 'secondary', etc.
- OpenWrt forum member @gba has kindly shared his Starlink config. This ought to provide some helpful pointers for adding appropriate overrides for Starlink users.
- See discussion on OpenWrt thread from around this post.
cake-autorate reads the $pinger_binary
variable in the config file
to select the ping binary. Choices include:
- fping (DEFAULT) round robin pinging to multiple reflectors with tightly controlled timings
- tsping round robin ICMP type 13 pinging to multiple reflectors with tightly controlled timings
- iputils-ping more advanced pinging than the default busybox ping with sub 1s ping frequency
About tsping @Lochnair has coded up an elegant ping utility in C that sends out ICMP type 13 requests in a round robin manner, thereby facilitating determination of one way delays (OWDs), i.e. not just round trip time (RTT), but the constituent download and upload delays, relative to multiple reflectors. Presently this must be compiled manually (although we can expect an official OpenWrt package soon).
Instructions for building a tsping
OpenWrt package are available
from github.