Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ##Script Tested on ASUS AC-68U, FW380.64_2, using Adaptive QOS with Manual Bandwidth Settings
- ##Script Changes Unidentified Packet QOS destination from Default Traffic Container (Category7) into Other Traffic Container
- ##Script Changes Minimum Guarenteed Bandwidth per QOS category from 128Kbit each to user defined percentages upload/download.
- echo "Adaptive QOS: Modification Script Started"
- Cat0DownBandPercent=5 #Percent of download speed for QOS catagories, change as desired
- Cat1DownBandPercent=20
- Cat2DownBandPercent=15
- Cat3DownBandPercent=10
- Cat4DownBandPercent=10
- Cat5DownBandPercent=30
- Cat6DownBandPercent=5
- Cat7DownBandPercent=5
- Cat0UpBandPercent=5 #Percent of upload speed for QOS catagories, change as desired
- Cat1UpBandPercent=20
- Cat2UpBandPercent=15
- Cat3UpBandPercent=30
- Cat4UpBandPercent=10
- Cat5UpBandPercent=10
- Cat6UpBandPercent=5
- Cat7UpBandPercent=5
- ############################### Unidentified Packet Priority ##########################
- DownloadPrio="$(tc filter show dev br0 | grep "mark 0x80000000 0x8000ffff" -B 1 | tr ' ' '\n' | grep "flowid" -A1 | tail -n 1)"
- UploadPrio="$(tc filter show dev eth0 | grep "mark 0x40000000 0x4000ffff" -B 1 | tr ' ' '\n' | grep "flowid" -A1 | tail -n 1)"
- NewDestCat="$(tc filter show dev eth0 | grep "mark 0x400a" -B1 | tr ' ' '\n' | grep "flowid" -A1 | tail -n1)" #Identifies current priority of the "Others" Traffic Container. Result used to route unclassifed traffic into same container.
- #NewDestCat="1:13" #Uncomment and change to manually define QOS traffic container for unidentified traffic instead of routing to currently set "Others" category
- ChangePrioReq=0
- if [ "${DownloadPrio}" = "1:17" ] ; then
- ChangePrioReq=1
- tc filter del dev br0 parent 1: handle 813::800 prio 1 protocol all u32
- tc filter replace dev br0 protocol all prio 1 handle 813::800 u32 match mark 0x80000000 0x8000ffff flowid ${NewDestCat}
- fi
- if [ "${UploadPrio}" = "1:17" ] ; then
- ChangePrioReq=1
- tc filter del dev eth0 parent 1: handle 813::800 prio 1 protocol all u32
- tc filter replace dev eth0 protocol all prio 1 handle 813::800 u32 match mark 0x40000000 0x4000ffff flowid ${NewDestCat}
- fi
- if [ "${ChangePrioReq}" = "1" ] ; then
- echo "Adaptive QOS: Changing default priority for Unidentified Traffic"
- else
- echo "Adaptive QOS: No priority change required for Unidentified Traffic"
- fi
- ######################## Minimum Guarenteed Class Bandwitdh ##########################
- DownCeil="$(tc class show dev br0 | grep -w "1:1 root" | tr ' ' '\n' | grep "ceil" -A1 | tail -n1 | tr -d 'Kbit')"
- DownBurst="$(tc class show dev br0 | grep -w "1:10" | tr ' ' '\n' | grep -w "burst" -A1 | tail -n1)"
- DownCburst="$(tc class show dev br0 | grep -w "1:10" | tr ' ' '\n' | grep -w "cburst" -A1 | tail -n1)"
- DownRate0="$(tc class show dev br0 | grep -w "1:10" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate1="$(tc class show dev br0 | grep -w "1:11" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate2="$(tc class show dev br0 | grep -w "1:12" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate3="$(tc class show dev br0 | grep -w "1:13" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate4="$(tc class show dev br0 | grep -w "1:14" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate5="$(tc class show dev br0 | grep -w "1:15" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate6="$(tc class show dev br0 | grep -w "1:16" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownRate7="$(tc class show dev br0 | grep -w "1:17" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- NewDownRate0="$(expr ${DownCeil} \* ${Cat0DownBandPercent} / 100)"Kbit
- NewDownRate1="$(expr ${DownCeil} \* ${Cat1DownBandPercent} / 100)"Kbit
- NewDownRate2="$(expr ${DownCeil} \* ${Cat2DownBandPercent} / 100)"Kbit
- NewDownRate3="$(expr ${DownCeil} \* ${Cat3DownBandPercent} / 100)"Kbit
- NewDownRate4="$(expr ${DownCeil} \* ${Cat4DownBandPercent} / 100)"Kbit
- NewDownRate5="$(expr ${DownCeil} \* ${Cat5DownBandPercent} / 100)"Kbit
- NewDownRate6="$(expr ${DownCeil} \* ${Cat6DownBandPercent} / 100)"Kbit
- NewDownRate7="$(expr ${DownCeil} \* ${Cat7DownBandPercent} / 100)"Kbit
- UpCeil="$(tc class show dev eth0 | grep -w "1:1 root" | tr ' ' '\n' | grep "ceil" -A1 | tail -n1 | tr -d 'Kbit')"
- UpBurst="$(tc class show dev eth0 | grep -w "1:10" | tr ' ' '\n' | grep -w "burst" -A1 | tail -n1)"
- UpCburst="$(tc class show dev eth0 | grep -w "1:10" | tr ' ' '\n' | grep -w "cburst" -A1 | tail -n1)"
- UpRate0="$(tc class show dev eth0 | grep -w "1:10" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate1="$(tc class show dev eth0 | grep -w "1:11" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate2="$(tc class show dev eth0 | grep -w "1:12" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate3="$(tc class show dev eth0 | grep -w "1:13" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate4="$(tc class show dev eth0 | grep -w "1:14" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate5="$(tc class show dev eth0 | grep -w "1:15" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate6="$(tc class show dev eth0 | grep -w "1:16" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- UpRate7="$(tc class show dev eth0 | grep -w "1:17" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- NewUpRate0="$(expr ${UpCeil} \* ${Cat0UpBandPercent} / 100)"Kbit
- NewUpRate1="$(expr ${UpCeil} \* ${Cat1UpBandPercent} / 100)"Kbit
- NewUpRate2="$(expr ${UpCeil} \* ${Cat2UpBandPercent} / 100)"Kbit
- NewUpRate3="$(expr ${UpCeil} \* ${Cat3UpBandPercent} / 100)"Kbit
- NewUpRate4="$(expr ${UpCeil} \* ${Cat4UpBandPercent} / 100)"Kbit
- NewUpRate5="$(expr ${UpCeil} \* ${Cat5UpBandPercent} / 100)"Kbit
- NewUpRate6="$(expr ${UpCeil} \* ${Cat6UpBandPercent} / 100)"Kbit
- NewUpRate7="$(expr ${UpCeil} \* ${Cat7UpBandPercent} / 100)"Kbit
- ChangeRateReq=0
- if [ "${DownRate0}" != "${NewDownRate0}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:10 htb prio 0 rate ${NewDownRate0} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate1}" != "${NewDownRate1}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:11 htb prio 1 rate ${NewDownRate1} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate2}" != "${NewDownRate2}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:12 htb prio 2 rate ${NewDownRate2} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate3}" != "${NewDownRate3}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:13 htb prio 3 rate ${NewDownRate3} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate4}" != "${NewDownRate4}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:14 htb prio 4 rate ${NewDownRate4} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate5}" != "${NewDownRate5}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:15 htb prio 5 rate ${NewDownRate5} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate6}" != "${NewDownRate6}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:16 htb prio 6 rate ${NewDownRate6} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${DownRate7}" != "${NewDownRate7}" ] ; then
- tc class change dev br0 parent 1:1 classid 1:17 htb prio 7 rate ${NewDownRate7} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate0}" != "${NewUpRate0}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:10 htb prio 0 rate ${NewUpRate0} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate1}" != "${NewUpRate1}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:11 htb prio 1 rate ${NewUpRate1} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate2}" != "${NewUpRate2}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:12 htb prio 2 rate ${NewUpRate2} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate3}" != "${NewUpRate3}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:13 htb prio 3 rate ${NewUpRate3} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate4}" != "${NewUpRate4}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:14 htb prio 4 rate ${NewUpRate4} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate5}" != "${NewUpRate5}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:15 htb prio 5 rate ${NewUpRate5} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate6}" != "${NewUpRate6}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:16 htb prio 6 rate ${NewUpRate6} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${UpRate7}" != "${NewUpRate7}" ] ; then
- tc class change dev eth0 parent 1:1 classid 1:17 htb prio 7 rate ${NewUpRate7} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- ChangeRateReq=1
- fi
- if [ "${ChangeRateReq}" = "1" ] ; then
- echo "Adaptive QOS: Changing default minimum guaranteed bandwidth for QOS categories"
- else
- echo "Adaptive QOS: No guaranteed bandwidth change required for QOS categories"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement