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.
- cru a QOS_CHECK 0 0 * * * /jffs/scripts/firewall-start ## schedules a daily check to see if modifcation is till persistant
- if [ "$(nvram get qos_enable)" = "1" ] && [ "$(nvram get qos_type)" = "1" ] ; then
- logger "Adaptive QOS: Modification Script Started"
- sleep 10
- 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 ##########################
- DestCat="$(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 catagory of the "Others" Traffic Container. Result used to route unclassifed traffic into catagory of "Others" container.
- #NewDestCat="1:13" #Uncomment and change to manually define QOS traffic container for unidentified traffic instead of routing to "Others" category container.
- if [ "${DestCat}" = "1:17" ] ; then
- logger "Adaptive QOS: Changing default priority for Unidentified Traffic"
- 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}
- 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}
- else
- logger "Adaptive QOS: No change required for Unidentified Traffic priority"
- fi
- ######################## Minimum Guarenteed Class Bandwidth ##########################
- DownRate1="$(tc class show dev br0 | grep -w "1:11" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
- DownCeil="$(nvram get qos_ibw)"
- 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)"
- UpCeil="$(nvram get qos_obw)"
- 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)"
- 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
- 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
- if [ "${DownRate1}" != "${NewDownRate1}" ] ; then
- logger "Adaptive QOS: Changing default minimum guaranteed bandwidth for QOS categories"
- tc class change dev br0 parent 1:1 classid 1:10 htb prio 0 rate ${NewDownRate0} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:11 htb prio 1 rate ${NewDownRate1} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:12 htb prio 2 rate ${NewDownRate2} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:13 htb prio 3 rate ${NewDownRate3} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:14 htb prio 4 rate ${NewDownRate4} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:15 htb prio 5 rate ${NewDownRate5} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:16 htb prio 6 rate ${NewDownRate6} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev br0 parent 1:1 classid 1:17 htb prio 7 rate ${NewDownRate7} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
- tc class change dev eth0 parent 1:1 classid 1:10 htb prio 0 rate ${NewUpRate0} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:11 htb prio 1 rate ${NewUpRate1} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:12 htb prio 2 rate ${NewUpRate2} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:13 htb prio 3 rate ${NewUpRate3} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:14 htb prio 4 rate ${NewUpRate4} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:15 htb prio 5 rate ${NewUpRate5} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:16 htb prio 6 rate ${NewUpRate6} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- tc class change dev eth0 parent 1:1 classid 1:17 htb prio 7 rate ${NewUpRate7} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
- else
- logger "Adaptive QOS: No change required for QOS categories guaranteed bandwidth"
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement