Multiple QoS profiles OR restart QoS from a shell?

Hello,

My internet provider recently gave customers the ability to double our connection speed (bandwidth) for a few days a month. I wish they had just given us a discount!

I use QoS and find it very helpful for my uplink connection. I have tuned it for my default connection speed so to take advantage of these speed increases I need a totally different profile.

Does anyone else have a requirement like this? I am aware of another internet provider here which allows you to change your bandwidth profile each day and then charges you according to what you choose.

As a work-around is it possible to restart QoS from a shell?

I could write a shell script which stopped QoS, backed up the configuration files, copied over a different profile of configuration files and re-started QoS.

Thank you!

It’s probably possible to script IPFire for two Quality of Service profiles. However, the built-in QoS isn’t designed for multi-profile use. To achieve this, you would need to delve into the code and create your script based on your findings.

I understand this could be a rather tedious and non-optimal solution, but as an alternative, you might consider having two different boot disks for IPFire, each with a different version of QoS. This way, the QoS in use would be determined by the disk you choose to boot from…

1 Like

Thanks for the suggesting, but that seems a rather drastic and complex solution. It’s also manual to switch between OSes in GRUB.

I’m looking to set up a script I can run remotely (via ssh, single command) and achieve what I mentioned above.

I realised later that the QoS page is calling a perl script which calls a qosctrl utility. It looks like it shouldn’t be that hard. If I get the time I’ll post back here what end up doing.

1 Like

A major reason for me using IPFire is that I can change many things if I need to!

I created the simple script below which switches (or “toggles”) between two copies of the QoS settings. Those two copies need to be made in directories named /var/ipfire/qos/slow-profile and /var/ipfire/qos/fast-profile first. You also need to set the value of the DOWN_SPEED_SLOW variable to the highest speed your slow connection could possibly use (my normal or “slow” connection is currently 50 mpbs so It’s set to that, while my “fast” connection is 100 mbps).

I could call this script from another system over SSH but in this situation I’ve set up a cron job to run it once on the day I have a speed profile change and once on the day after. (My ISPs speed change thingy runs for 24 hours)

#!/bin/bash
########################################################################
# Begin
#
# Description : QoS profile swap
#
# Authors     : DNL
#
# Version     : 0.1
#
# Notes       : Toggles between two QoS Profiles.
#               Both profiles must exist in subdirs at /var/ipfire/qos/
#               and be named "slow-profile" and "fast-profile"
#
#               https://wiki.ipfire.org/configuration/services/qos
#
########################################################################

set -o pipefail

# The highest value the Downlink speed could be set for the "slow" profile (kib/sec)
DOWN_SPEED_SLOW=50000

DOWN_SPEED=$( grep ^INC_SPD /var/ipfire/qos/settings | cut -d'=' -f2 )

/usr/local/bin/qosctrl stop >/dev/null

if [[ ${DOWN_SPEED} -le ${DOWN_SPEED_SLOW} ]]
then
        NEW_PROFILE="fast"
else
        NEW_PROFILE="slow"
fi

cp -f /var/ipfire/qos/${NEW_PROFILE}-profile/* /var/ipfire/qos

# Use the logic from IPFire to generate qos script and start QoS silently
/usr/local/bin/qosctrl generate
/usr/local/bin/qosctrl start >/dev/null
logger -p local0.info -t switchqos.sh[$$] "Switched QoS to ${NEW_PROFILE} profile"

2 Likes

Congratulations! Fantastic work. Expecially because you managed to figure out how the QoS is implemented in IPFire.

My only question? Does this only change the max speed setting. And not effect any custom settings.

The script copies all the settings so anything can be modified. I’ve not very creatively called all settings a “profile”.

In my case the only things I changed were:

  1. Downlink speed
  2. Uplink speed
  3. Maximum bandwith for each class (in my case that’s 13 classes)
  4. Guaranteed bandwith for each class (13 classes)

…but if you wanted to have one profile with different QoS classes and rules during the day and another at night, then there’s nothing to stop you*. It’s up to how you configure the settings in the first place.

* EDIT noting that the way I’ve written this for now it only toggles between two profiles based on their maximum downlink speed. If you wanted to change between two profiles with the same maximum speed then you’d have to come up with another way to determine which “profile” is in use at the time in order to switch between them.

3 Likes