What's new

[Release] FreshJR Adaptive QOS (Improvements / Custom Rules / and Inner workings)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Status
Not open for further replies.
Hello. I have ATT fixed wireless internet and the speed can unfortunately fluctuate (sometimes significantly). They guarantee at least 1Mbps up and 10MBps down and for the most part it is above those limits. I am using a script and spdMerlin data to set the QoS bandwidth limits (with FreshJr mods) to try an account for those fluctuations. So, my question is, should QoS be disabled before running spdMerlin or will it not interfere with the speedtest? I don't want new limits that are influenced by the "old" or existing limits do I? Thanks.
 
Hello. I have ATT fixed wireless internet and the speed can unfortunately fluctuate (sometimes significantly). They guarantee at least 1Mbps up and 10MBps down and for the most part it is above those limits. I am using a script and spdMerlin data to set the QoS bandwidth limits (with FreshJr mods) to try an account for those fluctuations. So, my question is, should QoS be disabled before running spdMerlin or will it not interfere with the speedtest? I don't want new limits that are influenced by the "old" or existing limits do I? Thanks.
I really don't know if spdMerlin interfere with the speed test, probably yes, but I'm writing to say that as you, my internet speed fluctuates a lot, as unfortunately I'm using 4G for internet access.
So, if you don't mind, I'd love to have the script you wrote to define the qos based on speed test. That would be awesome!
 
I really don't know if spdMerlin interfere with the speed test, probably yes, but I'm writing to say that as you, my internet speed fluctuates a lot, as unfortunately I'm using 4G for internet access.
So, if you don't mind, I'd love to have the script you wrote to define the qos based on speed test. That would be awesome!
Sure, no problem. Let me clean it up a bit and I will share it. Please understand that I am far from being a good coder, but it is working as expected so far. It uses bash and bc as well as spdMerlin or course. I use cron to run the script approx. 3-4 times a day ... during each execution of the script I take the average of 3 (user definable) speMerlin values and then set qos_obw and qos_ibw to those average values.
 
Sure, no problem. Let me clean it up a bit and I will share it. Please understand that I am far from being a good coder, but it is working as expected so far. It uses bash and bc as well as spdMerlin or course. I use cron to run the script approx. 3-4 times a day ... during each execution of the script I take the average of 3 (user definable) speMerlin values and then set qos_obw and qos_ibw to those average values.
Perfect!
I'm not a coder either but I try to develop everything that suits my needs, so...
If it works it's good :) thank you!
 
Sure, no problem. Let me clean it up a bit and I will share it. Please understand that I am far from being a good coder, but it is working as expected so far. It uses bash and bc as well as spdMerlin or course. I use cron to run the script approx. 3-4 times a day ... during each execution of the script I take the average of 3 (user definable) speMerlin values and then set qos_obw and qos_ibw to those average values.
Maybe you can share to us all here :)
Really would appreciated.
 
Maybe you can share to us all here :)
Really would appreciated.
I hope this helps somebody ... works ok for me. Again, I am not very proficient at coding, just needed something that works for me.

Code:
#!/opt/bin/bash

######################################################################
# SET-BW-SPEEDS
# Set QoS upload/download speeds using Ookla speedtests and spdMerlin
# Requires bash, bc, and spdMerlin
######################################################################

#Make sure speeds (before scaling) are within these boundaries
# Mainly just to prevent bandwidth from being set too low
# (or too high)... not worried about upper limit but it is there
# for the sake of completeness
download_lower_limit=10  #Mbps
download_upper_limit=50  #Mbps
upload_lower_limit=1.0   #Mbps
upload_upper_limit=50    #Mbps

#Scale average values by this factor
#Adjust to optimize bufferbloat and quality grade at DSLreports.com
down_scale_factor=0.85
up_scale_factor=0.85

#Do we need to disable QoS to get new QoS bandwidth limits
#Maybe not since traffic is from router
disable_qos_to_test=0

#Average download and upload speeds over this many
# consecutive speedtest runs
num_spd_tests=3

#Pause between successive speedtest runs (if num_spd_tests > 1)
pause_between_test=0
#If so, pause for how long (will be used with sleep command)
pause_this_long=1m

#spdMerlin command
spdMer_command="/jffs/scripts/spdmerlin generate"
#spdMer_command="echo DEBUG: spdMerlin executes now"

#Location of upload stats
upload_stats="/jffs/addons/spdmerlin.d/csv/Uploaddaily_WAN.htm"

#Location of download stats
download_stats="/jffs/addons/spdmerlin.d/csv/Downloaddaily_WAN.htm"

#Do you wanna to know what is going on if you manually run this script
show_me=1

######################################################################

#Disable QOS to find upload/download speeds
if (( $disable_qos_to_test )); then
  (( $show_me )) && echo "Disabling QoS while performing speedtests ..."
  nvram set qos_enable=0
  nvram commit
  service restart_qos 1> /dev/null
  service restart_firewall 1> /dev/null
fi

#Calculate average download and upload speeds using spdMerlin
sum_down=0; sum_up=0; x=1
while [ $x -le $num_spd_tests ]
do
  (( $show_me )) && echo -e "\nRunning spdMerlin test #$x of $num_spd_tests ..."
  ${spdMer_command} &> /dev/null
  Mbps_down=$(tail -n1 $download_stats | awk -F ',' '{print $NF}')
  Mbps_up=$(tail -n1 $upload_stats | awk -F ',' '{print $NF}')

  sum_down=$(echo $sum_down+$Mbps_down | bc)
  sum_up=$(echo $sum_up+$Mbps_up | bc)

  if (( $show_me )); then
    echo "===== SpeedTest: $x ====="
    echo Download Speed: $Mbps_down Mbps
    echo Upload Speed: $Mbps_up Mbps
  fi

  x=$(( $x + 1 ))
  (( $pause_between_test )) && (( $x <= $num_spd_tests )) && echo "Sleeping for $pause_this_long ..." && sleep $pause_this_long
done

#Calculate the average values
Mbps_down=$(echo "scale=3; $sum_down/$num_spd_tests" | bc)
Mbps_up=$(echo "scale=3; $sum_up/$num_spd_tests" | bc)
if (( $show_me )) && (( $num_spd_tests > 1 )); then
  echo -e "\n===== Averages: ====="
  echo Download Speed: $Mbps_down Mbps
  echo Upload Speed: $Mbps_up Mbps
fi

#Make sure download and uploads speeds are within defined user-defined limits above
if (( `echo "$Mbps_down < $download_lower_limit" | bc` )); then
   logger " -----> Speedtest avg download speed ($Mbps_down Mbps) was less than lower limit ($download_lower_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg download speed ($Mbps_down Mbps) was less than lower limit ($download_lower_limit Mbps)"
   Mbps_down=$download_lower_limit
elif (( `echo "$Mbps_down > $download_upper_limit" | bc` )); then
   logger " -----> Speedtest avg download speed ($Mbps_down Mbps) was greater than upper limit ($download_upper_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg download speed ($Mbps_down Mbps) was greater than upper limit ($download_upper_limit Mbps)"
   Mbps_down=$download_upper_limit
fi
if (( `echo "$Mbps_up < $upload_lower_limit" | bc` )); then
   logger " -----> Speedtest avg upload speed ($Mbps_up Mbps) was less than lower limit ($upload_lower_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg upload speed ($Mbps_up Mbps) was less than lower limit ($upload_lower_limit Mbps)"
   Mbps_up=$upload_lower_limit
elif (( `echo "$Mbps_up > $upload_upper_limit" | bc` )); then
   logger " -----> Speedtest avg upload speed ($Mbps_up Mbps) was greater than upper limit ($upload_upper_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg upload speed ($Mbps_up Mbps) was greater than upper limit ($upload_upper_limit Mbps)"
   Mbps_up=$upload_upper_limit
fi

#Convert to Kbps
#Could simplify this but want to know scaled Mbps so that it can be reported
Mbps_down=$(echo $Mbps_down*$down_scale_factor | bc)
Mbps_up=$(echo $Mbps_up*$up_scale_factor | bc)
Kbps_down=$(echo $Mbps_down*1024 | bc)
Kbps_up=$(echo $Mbps_up*1024 | bc)

#Set Download Limit
logger " -----> Setting QoS Download Speed to $Mbps_down Mbps ..."
(( $show_me )) && echo -e "\nAfter scaling by $down_scale_factor, setting QoS Download Speed to $Mbps_down Mbps ..."
nvram set qos_ibw=$Kbps_down

#Set Upload Limit
logger " -----> Setting QoS Upload Speed to $Mbps_up Mbps ..."
(( $show_me )) && echo "After scaling by $up_scale_factor, setting QoS Upload Speed to $Mbps_up Mbps ..."
nvram set qos_obw=$Kbps_up

#Re-Enable QoS if it was disabled to perform speedtest
if (( $disable_qos_to_test )); then
  (( $show_me )) && echo "Re-enabling QoS now that speedtest are done ..."
  nvram set qos_enable=1
fi
nvram commit
service restart_qos 1> /dev/null
service restart_firewall 1> /dev/null
(( $show_me )) && echo "Done."
exit 0;
 
Last edited:
I hope this helps somebody ... works ok for me. Again, I am not very proficient at coding, just needed something that works for me.

Code:
#!/opt/bin/bash

######################################################################
# SET-BW-SPEEDS
# Set QoS upload/download speeds using Ookla speedtests and spdMerlin
# Requires bash, bc, and spdMerlin
######################################################################

#Make sure speeds (before scaling) are within these boundaries
# Mainly just to prevent bandwidth from being set too low
# (or too high)... not worried about upper limit but it is there
# for the sake of completeness
download_lower_limit=10  #Mbps
download_upper_limit=50  #Mbps
upload_lower_limit=1.0   #Mbps
upload_upper_limit=50    #Mbps

#Scale average values by this factor
#Adjust to optimize bufferbloat and quality grade at DSLreports.com
down_scale_factor=0.85
up_scale_factor=0.85

#Do we need to disable QoS to get new QoS bandwidth limits
#Maybe not since traffic is from router
disable_qos_to_test=0

#Average download and upload speeds over this many
# consecutive speedtest runs
num_spd_tests=3

#Pause between successive speedtest runs (if num_spd_tests > 1)
pause_between_test=0
#If so, pause for how long (will be used with sleep command)
pause_this_long=1m

#spdMerlin command
spdMer_command="/jffs/scripts/spdmerlin generate"
#spdMer_command="echo DEBUG: spdMerlin executes now"

#Location of upload stats
upload_stats="/jffs/addons/spdmerlin.d/csv/Uploaddaily_WAN.htm"

#Location of download stats
download_stats="/jffs/addons/spdmerlin.d/csv/Downloaddaily_WAN.htm"

#Do you wanna to know what is going on if you manually run this script
show_me=1

######################################################################

#Disable QOS to find upload/download speeds
if (( $disable_qos_to_test )); then
  (( $show_me )) && echo "Disabling QoS while performing speedtests ..."
  nvram set qos_enable=0
  nvram commit
  service restart_qos 1> /dev/null
  service restart_firewall 1> /dev/null
fi

#Calculate average download and upload speeds using spdMerlin
sum_down=0; sum_up=0; x=1
while [ $x -le $num_spd_tests ]
do
  (( $show_me )) && echo -e "\nRunning spdMerlin test #$x of $num_spd_tests ..."
  ${spdMer_command} &> /dev/null
  Mbps_down=$(tail -n1 $download_stats | awk -F ',' '{print $NF}')
  Mbps_up=$(tail -n1 $upload_stats | awk -F ',' '{print $NF}')

  sum_down=$(echo $sum_down+$Mbps_down | bc)
  sum_up=$(echo $sum_up+$Mbps_up | bc)

  if (( $show_me )); then
    echo "===== SpeedTest: $x ====="
    echo Download Speed: $Mbps_down Mbps
    echo Upload Speed: $Mbps_up Mbps
  fi

  x=$(( $x + 1 ))
  (( $pause_between_test )) && (( $x <= $num_spd_tests )) && echo "Sleeping for $pause_this_long ..." && sleep $pause_this_long
done

#Calculate the average values
Mbps_down=$(echo "scale=3; $sum_down/$num_spd_tests" | bc)
Mbps_up=$(echo "scale=3; $sum_up/$num_spd_tests" | bc)
if (( $show_me )) && (( $num_spd_tests > 1 )); then
  echo -e "\n===== Averages: ====="
  echo Download Speed: $Mbps_down Mbps
  echo Upload Speed: $Mbps_up Mbps
fi

#Make sure download and uploads speeds are within defined user-defined limits above
if (( `echo "$Mbps_down < $download_lower_limit" | bc` )); then
   logger " -----> Speedtest avg download speed ($Mbps_down Mbps) was less than lower limit ($download_lower_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg download speed ($Mbps_down Mbps) was less than lower limit ($download_lower_limit Mbps)"
   Mbps_down=$download_lower_limit
elif (( `echo "$Mbps_down > $download_upper_limit" | bc` )); then
   logger " -----> Speedtest avg download speed ($Mbps_down Mbps) was greater than upper limit ($download_upper_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg download speed ($Mbps_down Mbps) was greater than upper limit ($download_upper_limit Mbps)"
   Mbps_down=$download_upper_limit
fi
if (( `echo "$Mbps_up < $upload_lower_limit" | bc` )); then
   logger " -----> Speedtest avg upload speed ($Mbps_up Mbps) was less than lower limit ($upload_lower_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg upload speed ($Mbps_up Mbps) was less than lower limit ($upload_lower_limit Mbps)"
   Mbps_up=$upload_lower_limit
elif (( `echo "$Mbps_up > $upload_upper_limit" | bc` )); then
   logger " -----> Speedtest avg upload speed ($Mbps_up Mbps) was greater than upper limit ($upload_upper_limit Mbps)"
   (( $show_me )) && echo "Speedtest avg upload speed ($Mbps_up Mbps) was greater than upper limit ($upload_upper_limit Mbps)"
   Mbps_up=$upload_upper_limit
fi

#Convert to Kbps
#Could simplify this but want to know scaled Mbps so that it can be reported
Mbps_down=$(echo $Mbps_down*$down_scale_factor | bc)
Mbps_up=$(echo $Mbps_up*$up_scale_factor | bc)
Kbps_down=$(echo $Mbps_down*1024 | bc)
Kbps_up=$(echo $Mbps_up*1024 | bc)

#Set Download Limit
logger " -----> Setting QoS Download Speed to $Mbps_down Mbps ..."
(( $show_me )) && echo -e "\nAfter scaling by $down_scale_factor, setting QoS Download Speed to $Mbps_down Mbps ..."
nvram set qos_ibw=$Kbps_down

#Set Upload Limit
logger " -----> Setting QoS Upload Speed to $Mbps_up Mbps ..."
(( $show_me )) && echo "After scaling by $up_scale_factor, setting QoS Upload Speed to $Mbps_up Mbps ..."
nvram set qos_obw=$Kbps_up

#Re-Enable QoS if it was disabled to perform speedtest
if (( $disable_qos_to_test )); then
  (( $show_me )) && echo "Re-enabling QoS now that speedtest are done ..."
  nvram set qos_enable=1
fi
nvram commit
service restart_qos 1> /dev/null
service restart_firewall 1> /dev/null
(( $show_me )) && echo "Done."
exit 0;
I'll give it a try! Sounds cool!

I just want to edit something - how can I call spdMerlin option 2 (use preferred server)? Because I need to force a specifically server where I know I can get my real speeds
 
I'll give it a try! Sounds cool!

I just want to edit something - how can I call spdMerlin option 2 (use preferred server)? Because I need to force a specifically server where I know I can get my real speeds
Not sure, but maybe edit /jffs/addons/spdmerlin.d/config with your PREFERREDSERVER and make sure USEPREFERRED=true
 
Using same preferred server:
Running script with QoS enabled:
===== Averages: =====
Download Speed: 17.393 Mbps
Upload Speed: .650 Mbps

Running script with QoS disabled:
===== Averages: =====
Download Speed: 18.530 Mbps
Upload Speed: 3.746 Mbps

So, for me at least, having QoS enabled does appear to affect the Speedtest results.
 
Using same preferred server:
Running script with QoS enabled:
===== Averages: =====
Download Speed: 17.393 Mbps
Upload Speed: .650 Mbps

Running script with QoS disabled:
===== Averages: =====
Download Speed: 18.530 Mbps
Upload Speed: 3.746 Mbps

So, for me at least, having QoS enabled does appear to affect the Speedtest results.
I made some tests and I think it affects ....
Although my download speed is very unpredictable (sometimes 20mbps, sometimes 5mbps, sometimes the full 40mbps or even more), my upload speed is constant, capped to the maximum of contract - 10 Mbps.
And with qos on, in speedtest I usually get 5-6mbps. With qos off, I usually get the 10mbps
 
@squidbilly
Something odd when trying to run! Screenshot attached.
 

Attachments

  • Screenshot_20200326-101745046 (1).jpg
    Screenshot_20200326-101745046 (1).jpg
    48.7 KB · Views: 167
Something odd going on with the script.
The script has been working ok for ages.

With DSLreports i can tweak it to get A+ A and A+ but recently its been simply A A A.
Now with online games this has made a difference...a very noticeable one too.
After tweaking the DL and UL no joy.

But switching to bandwidth limiter BINGO.
Back to A+ A A+ plus the latency to the nearest server is 20ms lower than under the script.

Gameplay is also noticeably better.
 
Something odd going on with the script.
The script has been working ok for ages.

With DSLreports i can tweak it to get A+ A and A+ but recently its been simply A A A.
Now with online games this has made a difference...a very noticeable one too.
After tweaking the DL and UL no joy.

But switching to bandwidth limiter BINGO.
Back to A+ A A+ plus the latency to the nearest server is 20ms lower than under the script.

Gameplay is also noticeably better.
What are your internet speeds and can you post pics of your setup using bandwidth limiter? Thanks
 
What are your internet speeds and can you post pics of your setup using bandwidth limiter? Thanks

Im on 100MBs symetrical....
I give minimal BW to mobiles...a little more to the ipad and use the same BW for PS4 and laptop....45DL 40UL.

This gives me A+ A A+.
 
Status
Not open for further replies.

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top