Skip to content

Commit

Permalink
Change CAKE-autorate filenames to be all lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
richb-hanover committed Aug 22, 2022
1 parent 7ebf273 commit 40afeab
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 70 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ bandwidth settings by measuring traffic load and RTT times.
Read the [README](./README.md) file for more details.
This is the history of changes.

## 2022-08-21

- Version number 1.0.0
- Change file names to lower case, left the project name and repo CAKE-autorate
- create installer script
- Startup logging routines



## 2022-07-01

- Significant testing with a Starlink connection (thanks to @gba of OpenWrt)
Expand Down
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ and whilst the actual usable line rate is below the
compromise value, the connection is not throttled enough
(green) resulting in bufferbloat.

![image of Bandwidth Compromise](./Bandwidth-Compromise.png)
![image of Bandwidth Compromise](images/bandwidth-compromise.png)

## The Solution: Automatic Bandwidth Adjustment based on LOAD and RTT

The **CAKE-autorate.sh** script periodically measures the load and Round-Trip-Time (RTT) to adjust the upload and download values for the CAKE algorithm.
The **cake-autorate.sh** script periodically measures the load and Round-Trip-Time (RTT)
to adjust the upload and download values for the CAKE algorithm.

## Theory of Operation

`CAKE-autorate.sh` monitors load (rx and tx) and ping respones from one or more reflectors, and adjusts the download and upload bandwidth for CAKE. Rate control is intentionally kept as simple as possible and follows the following approach:
`cake-autorate.sh` monitors load (rx and tx) and ping respones from one or more reflectors,
and adjusts the download and upload bandwidth for CAKE.
Rate control is intentionally kept as simple as possible and follows the following approach:

- with low load, decay rate back to set baseline (and subject to refractory period)
- with high load, increase rate subject to set maximum
- on bufferbloat, decrease rate subject to set min (and subject to refractory period)

![image of CAKE-autorat rate control](./CAKE-autorate-rate-control.png)
![image of cake-autorate rate control](images/cake-bandwidth-autorate-rate-control.png)

**Setting the minimum bandwidth:**
Set the minimum value to the worst possible observed bufferbloat free bandwidth. Ideally this CAKE bandwidth should never result in bufferbloat even under the worst conditions. This is a hard minimum - the script will never reduce the bandwidth below this level.
Expand All @@ -60,7 +63,7 @@ The maximum bandwidth should be set to the lower of the maximum bandwidth that t

To elaborate on setting the minimum and maximum, a variable bandwidth connection may be most ideally divided up into a known fixed, stable component, on top of which is provided an unknown variable component:

![image of CAKE bandwidth adaptation](./CAKE-Bandwidth-Adaptation.png)
![image of cake bandwidth adaptation](images/cake-bandwidth-adaptation.png)

The minimum bandwidth is then set to (or slightly below) the fixed component, and the maximum bandwidth may be set to (or slightly above) the maximum observed bandwidth. Or, if a lower maximum bandwidth is required by the user, the maximum bandwidth is set to that lower bandwidth as explained above.

Expand All @@ -85,15 +88,15 @@ as described in the
copying and pasting each of the commands below:

```bash
wget -O /tmp/CAKE-autorate-setup.sh https://raw.githubusercontent.com/lynxthecat/CAKE-autorate/main/CAKE-autorate-setup.sh
sh /tmp/CAKE-autorate-setup.sh
wget -O /tmp/cake-autorate-setup.sh https://raw.githubusercontent.com/lynxthecat/CAKE-autorate/main/cake-autorate-setup.sh
sh /tmp/cake-autorate-setup.sh
```

- The installer script will detect a previous configuration file,
and ask whether to preserve it. If you do not keep it...
- Edit the `CAKE-autorate-config.sh` script (in the `/root/CAKE-autorate` directory) using
- Edit the `cake-autorate-config.sh` script (in the `/root/cake-autorate` directory) using
vi or nano to set the configuration parameters below
(see comments inside `CAKE-autorate-config.sh` for details).
(see comments inside `cake-autorate-config.sh` for details).

- Change `ul_if` and `dl_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 of `tc qdisc ls`.

Expand All @@ -102,7 +105,7 @@ vi or nano to set the configuration parameters below
| `ul_if` | Interface that uploads (often `wan`) | `min_ul_shaper_rate_kbps` |
| `dl_if` | Interface that uploads data (check `tc qdisc ls`) |

- Set bandwidth variables as described in `CAKE-autorate-config.sh`.
- Set bandwidth variables as described in `cake-autorate-config.sh`.

| Type | Download | Upload |
|----: | :-------- | :------ |
Expand All @@ -118,13 +121,13 @@ vi or nano to set the configuration parameters below

## Manual testing

To run the `CAKE-autorate.sh` script:
To run the `cake-autorate.sh` script:

* In `CAKE-autorate-config.sh`, set **output\_processing\_stats** to '1'
* In `cake-autorate-config.sh`, set **output\_processing\_stats** to '1'

```bash
cd /root/CAKE-autorate # to the CAKE-autorate directory
bash ./CAKE-autorate.sh
cd /root/cake-autorate # to the cake-autorate directory
bash ./cake-autorate.sh
```

- Monitor the script output to see how it adjusts the download
Expand All @@ -140,16 +143,16 @@ To do this:
- Run these commands to enable and start the service file:

```bash
# the CAKE-autorate-setup.sh script already installed the service file
# the cake-autorate-setup.sh script already installed the service file
service cake-autorate enable
service cake-autorate start
```

When running as a service, the `CAKE-autorate.sh` script outputs to `/tmp/CAKE-autorate.log`.
When running as a service, the `cake-autorate.sh` script outputs to `/tmp/cake-autorate.log`.

WARNING: It is a good idea to disable logging output when
running as a service given the high rate of logging.
Do this by setting **output\_processing\_stats** to '0' in `CAKE-autorate-config.sh`
Do this by setting **output\_processing\_stats** to '0' in `cake-autorate-config.sh`

## Preserving CAKE-autorate files for backup or upgrades

Expand All @@ -160,7 +163,7 @@ describes how files can be saved across upgrades.
so they will be saved in backups and preserved across snapshot upgrades.

```
/root/CAKE-autorate
/root/cake-autorate
/etc/init.d/cake-autorate
```

Expand Down
2 changes: 1 addition & 1 deletion cake-autorate
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ USE_PROCD=1

start_service() {
procd_open_instance
procd_set_param command /root/CAKE-autorate/CAKE-autorate.sh
procd_set_param command /root/cake-autorate/cake-autorate.sh
# uncomment if you want procd to restart your script if it terminated for whatever reason
#procd_set_param respawn
procd_close_instance
Expand Down
4 changes: 2 additions & 2 deletions CAKE-autorate-config.sh → cake-autorate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# CAKE-autorate automatically adjusts bandwidth for CAKE in dependence on detected load and RTT

# CAKE-config.sh is a script that sets up defaults for CAKE-autorate
# cake-autorate-config.sh is a script that sets up defaults for CAKE-autorate

# Author: @Lynx (OpenWrt forum)
# Inspiration taken from: @moeller0 (OpenWrt forum)

CAKE_autorate_version="1.0.0"
cake_autorate_version="1.0.0"

# *** OUTPUT OPTIONS ***

Expand Down
34 changes: 17 additions & 17 deletions CAKE-autorate-setup.sh → cake-autorate-setup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /bin/ash
# Basic installation script for CAKE-autorate.sh
#! /bin/sh
# Basic installation script for cake-autorate.sh
# See https://github.com/lynxthecat/sqm-autorate for details
# https://www.shellcheck.net/ is your friend

SRC_DIR="https://raw.githubusercontent.com/lynxthecat/CAKE-autorate/main/"
#SRC_DIR="https://raw.githubusercontent.com/richb-hanover/CAKE-autorate/setup-script/"
# SRC_DIR="https://raw.githubusercontent.com/lynxthecat/CAKE-autorate/main/"
SRC_DIR="https://raw.githubusercontent.com/richb-hanover/cake-autorate/setup-script/"
DOC_URL="https://github.com/lynxthecat/CAKE-autorate#installation-on-openwrt"

# Retrieve required packages
Expand All @@ -15,33 +15,33 @@ DOC_URL="https://github.com/lynxthecat/CAKE-autorate#installation-on-openwrt"
# cd to the /root directory
cd /root/ || exit

# create the CAKE-autorate directory if it's not present
[[ -d CAKE-autorate ]] || mkdir CAKE-autorate
# create the cake-autorate directory if it's not present
[[ -d cake-autorate ]] || mkdir cake-autorate

printf "Installing CAKE-autorate in /root/CAKE-autorate...\n"
printf "Installing CAKE-autorate in /root/cake-autorate...\n"

# cd into it
cd CAKE-autorate/ || exit
cd cake-autorate/ || exit

# rm the main script and fetch a fresh copy
[[ -f CAKE-autorate.sh ]] && rm CAKE-autorate.sh
wget -q "$SRC_DIR"CAKE-autorate.sh
[[ -f cake-autorate.sh ]] && rm cake-autorate.sh
wget -q "$SRC_DIR"cake-autorate.sh

# Check if the configuration script exists, and ask whether to keep it

editmsg=$(printf "\nNow edit the CAKE-autorate-config.sh file as described in:\n $DOC_URL")
editmsg=$(printf "\nNow edit the cake-autorate-config.sh file as described in:\n $DOC_URL")

if [ -f CAKE-autorate-config.sh ]; then
if [ -f cake-autorate-config.sh ]; then
printf "Previous configuration present - keep it? [Y/n] "
read keepIt
if [ "$keepIt" == "N" ] || [ "$keepIt" == "n" ]; then
rm ./CAKE-autorate-config.sh
wget -q "$SRC_DIR"CAKE-autorate-config.sh
rm ./cake-autorate-config.sh
wget -q "$SRC_DIR"cake-autorate-config.sh
else
editmsg="Using prior configuration"
fi
else
wget -q "$SRC_DIR"CAKE-autorate-config.sh
wget -q "$SRC_DIR"cake-autorate-config.sh
fi
# make both .sh files executable
chmod +x *.sh
Expand All @@ -57,9 +57,9 @@ wget -q "$SRC_DIR"cake-autorate
chmod +x cake-autorate

printf "\n"
printf "`grep CAKE_autorate /root/CAKE-autorate/CAKE-autorate-config.sh` successfully installed but not yet running\n"
printf "`grep cake_autorate_version /root/cake-autorate/cake-autorate-config.sh` successfully installed but not yet running\n"
printf "\n"
printf "Start the software manually with:\n"
printf " cd /root/CAKE-autorate; bash ./CAKE-autorate.sh\n"
printf " cd /root/cake-autorate; bash ./cake-autorate.sh\n"
printf "Run as a service with:\n"
printf " service cake-autorate enable;service cake-autorate start\n"
Loading

0 comments on commit 40afeab

Please sign in to comment.