Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: How To: Ubiquiti EdgeRouter (Vyatta OS) auto update QoS speed limits from AAISP  (Read 1364 times)

Ixel

  • Kitizen
  • ****
  • Posts: 1282

Hi all,
Not sure how many might find this useful but I thought I'd post it anyway, perhaps some people are curious.

I own a Ubiquiti EdgeRouter Pro 8 and it's connected to my DrayTek (bridged modem) which is on an FTTC service from AAISP. I knew writing a small bash script would be pretty easy to dynamically change the QoS speed settings based on what AAISP see. It appears to work on a PPP connect but as I always currently sync at 80/20 (just) I don't know 100%. I know however that it's updating when there's a successful PPP connect.

Code: [Select]
#!/bin/bash

runcmd=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper

curl -sH "Content-Type: application/json" -X POST -d '{"control_login":"CHANGE_THIS","control_password":"CHANGE_THIS","service":"CHANGE_THIS"}' https://chaos2.aa.net.uk/broadband/info > /tmp/aaisp.txt
rx_rate=$(cat /tmp/aaisp.txt | jq '.info[0].tx_rate_adjusted')
tx_rate=$(cat /tmp/aaisp.txt | jq '.info[0].rx_rate')

rx_rate=$(echo $rx_rate | sed 's/"//g')
tx_rate=$(echo $tx_rate | sed 's/"//g')

rx_rate_adjusted=$(echo $rx_rate | awk '{print int($0*0.95)}')
tx_rate_adjusted=$(echo $tx_rate | awk '{print int($0*0.95)}')

echo "Transfer rate updated... RX: ${rx_rate_adjusted}bit - TX: ${tx_rate_adjusted}bit"

if [ "$rx_rate_adjusted" -gt "1" ]; then
    $runcmd begin
    $runcmd delete traffic-control smart-queue Internet download rate
    $runcmd set traffic-control smart-queue Internet download rate $(echo $rx_rate_adjusted)bit
    $runcmd delete traffic-control smart-queue Internet upload rate
    $runcmd set traffic-control smart-queue Internet upload rate $(echo $tx_rate_adjusted)bit
    $runcmd commit
    $runcmd save
    $runcmd end
fi

Put the above code in a file like /config/scripts/ppp/ip-up.d/aaisp.sh and save. Chmod that file to 777. The directories ppp and ip-up.d probably don't exist so mkdir those too and chmod 777. Hopefully most people here who are curious or interested understand the above, if not I'll edit the post to be in more detail.

Enjoy.

P.S. You can adjust the 0.95 (95%) to what value you prefer, e.g. on " | awk '{print int($0*0.95)}')". In my case I'm using 95%.
Logged