Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. #!/bin/sh
  2. ##Script Tested on ASUS AC-68U, FW380.64_2, using Adaptive QOS with Manual Bandwidth Settings
  3. ##Script Changes Unidentified Packet QOS destination from Default Traffic Container (Category7) into Other Traffic Container
  4. ##Script Changes Minimum Guarenteed Bandwidth per QOS category from 128Kbit each to user defined percentages upload/download.
  5.  
  6. cru a QOS_CHECK 0 0 * * * /jffs/scripts/firewall-start ## schedules a daily check to see if modifcation is till persistant
  7.  
  8. if [ "$(nvram get qos_enable)" = "1" ] && [ "$(nvram get qos_type)" = "1" ] ; then
  9. logger "Adaptive QOS: Modification Script Started"
  10. sleep 10
  11.  
  12. Cat0DownBandPercent=5 #Percent of download speed for QOS catagories, change as desired
  13. Cat1DownBandPercent=20
  14. Cat2DownBandPercent=15
  15. Cat3DownBandPercent=10
  16. Cat4DownBandPercent=10
  17. Cat5DownBandPercent=30
  18. Cat6DownBandPercent=5
  19. Cat7DownBandPercent=5
  20.  
  21. Cat0UpBandPercent=5 #Percent of upload speed for QOS catagories, change as desired
  22. Cat1UpBandPercent=20
  23. Cat2UpBandPercent=15
  24. Cat3UpBandPercent=30
  25. Cat4UpBandPercent=10
  26. Cat5UpBandPercent=10
  27. Cat6UpBandPercent=5
  28. Cat7UpBandPercent=5
  29.  
  30. ############################### Unidentified Packet Priority ##########################
  31. DestCat="$(tc filter show dev eth0 | grep "mark 0x40000000 0x4000ffff" -B 1 | tr ' ' '\n' | grep "flowid" -A1 | tail -n 1)"
  32. 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.
  33. #NewDestCat="1:13" #Uncomment and change to manually define QOS traffic container for unidentified traffic instead of routing to "Others" category container.
  34.  
  35. if [ "${DestCat}" = "1:17" ] ; then
  36. logger "Adaptive QOS: Changing default priority for Unidentified Traffic"
  37. tc filter del dev eth0 parent 1: handle 813::800 prio 1 protocol all u32
  38. tc filter replace dev eth0 protocol all prio 1 handle 813::800 u32 match mark 0x40000000 0x4000ffff flowid ${NewDestCat}
  39. tc filter del dev br0 parent 1: handle 813::800 prio 1 protocol all u32
  40. tc filter replace dev br0 protocol all prio 1 handle 813::800 u32 match mark 0x80000000 0x8000ffff flowid ${NewDestCat}
  41. else
  42. logger "Adaptive QOS: No change required for Unidentified Traffic priority"
  43. fi
  44.  
  45. ######################## Minimum Guarenteed Class Bandwidth ##########################
  46. DownRate1="$(tc class show dev br0 | grep -w "1:11" | tr ' ' '\n' | grep "rate" -A1 | tail -n 1)"
  47.  
  48. DownCeil="$(nvram get qos_ibw)"
  49. DownBurst="$(tc class show dev br0 | grep -w "1:10" | tr ' ' '\n' | grep -w "burst" -A1 | tail -n1)"
  50. DownCburst="$(tc class show dev br0 | grep -w "1:10" | tr ' ' '\n' | grep -w "cburst" -A1 | tail -n1)"
  51.  
  52. UpCeil="$(nvram get qos_obw)"
  53. UpBurst="$(tc class show dev eth0 | grep -w "1:10" | tr ' ' '\n' | grep -w "burst" -A1 | tail -n1)"
  54. UpCburst="$(tc class show dev eth0 | grep -w "1:10" | tr ' ' '\n' | grep -w "cburst" -A1 | tail -n1)"
  55.  
  56. NewDownRate0="$(expr ${DownCeil} \* ${Cat0DownBandPercent} / 100)"Kbit
  57. NewDownRate1="$(expr ${DownCeil} \* ${Cat1DownBandPercent} / 100)"Kbit
  58. NewDownRate2="$(expr ${DownCeil} \* ${Cat2DownBandPercent} / 100)"Kbit
  59. NewDownRate3="$(expr ${DownCeil} \* ${Cat3DownBandPercent} / 100)"Kbit
  60. NewDownRate4="$(expr ${DownCeil} \* ${Cat4DownBandPercent} / 100)"Kbit
  61. NewDownRate5="$(expr ${DownCeil} \* ${Cat5DownBandPercent} / 100)"Kbit
  62. NewDownRate6="$(expr ${DownCeil} \* ${Cat6DownBandPercent} / 100)"Kbit
  63. NewDownRate7="$(expr ${DownCeil} \* ${Cat7DownBandPercent} / 100)"Kbit
  64.  
  65. NewUpRate0="$(expr ${UpCeil} \* ${Cat0UpBandPercent} / 100)"Kbit
  66. NewUpRate1="$(expr ${UpCeil} \* ${Cat1UpBandPercent} / 100)"Kbit
  67. NewUpRate2="$(expr ${UpCeil} \* ${Cat2UpBandPercent} / 100)"Kbit
  68. NewUpRate3="$(expr ${UpCeil} \* ${Cat3UpBandPercent} / 100)"Kbit
  69. NewUpRate4="$(expr ${UpCeil} \* ${Cat4UpBandPercent} / 100)"Kbit
  70. NewUpRate5="$(expr ${UpCeil} \* ${Cat5UpBandPercent} / 100)"Kbit
  71. NewUpRate6="$(expr ${UpCeil} \* ${Cat6UpBandPercent} / 100)"Kbit
  72. NewUpRate7="$(expr ${UpCeil} \* ${Cat7UpBandPercent} / 100)"Kbit
  73.  
  74.  
  75.  
  76. if [ "${DownRate1}" != "${NewDownRate1}" ] ; then
  77. logger "Adaptive QOS: Changing default minimum guaranteed bandwidth for QOS categories"
  78. tc class change dev br0 parent 1:1 classid 1:10 htb prio 0 rate ${NewDownRate0} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  79. tc class change dev br0 parent 1:1 classid 1:11 htb prio 1 rate ${NewDownRate1} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  80. tc class change dev br0 parent 1:1 classid 1:12 htb prio 2 rate ${NewDownRate2} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  81. tc class change dev br0 parent 1:1 classid 1:13 htb prio 3 rate ${NewDownRate3} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  82. tc class change dev br0 parent 1:1 classid 1:14 htb prio 4 rate ${NewDownRate4} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  83. tc class change dev br0 parent 1:1 classid 1:15 htb prio 5 rate ${NewDownRate5} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  84. tc class change dev br0 parent 1:1 classid 1:16 htb prio 6 rate ${NewDownRate6} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  85. tc class change dev br0 parent 1:1 classid 1:17 htb prio 7 rate ${NewDownRate7} ceil ${DownCeil}Kbit burst ${DownBurst} cburst ${DownCburst}
  86. tc class change dev eth0 parent 1:1 classid 1:10 htb prio 0 rate ${NewUpRate0} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  87. tc class change dev eth0 parent 1:1 classid 1:11 htb prio 1 rate ${NewUpRate1} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  88. tc class change dev eth0 parent 1:1 classid 1:12 htb prio 2 rate ${NewUpRate2} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  89. tc class change dev eth0 parent 1:1 classid 1:13 htb prio 3 rate ${NewUpRate3} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  90. tc class change dev eth0 parent 1:1 classid 1:14 htb prio 4 rate ${NewUpRate4} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  91. tc class change dev eth0 parent 1:1 classid 1:15 htb prio 5 rate ${NewUpRate5} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  92. tc class change dev eth0 parent 1:1 classid 1:16 htb prio 6 rate ${NewUpRate6} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  93. tc class change dev eth0 parent 1:1 classid 1:17 htb prio 7 rate ${NewUpRate7} ceil ${UpCeil}Kbit burst ${UpBurst} cburst ${UpCburst}
  94. else
  95. logger "Adaptive QOS: No change required for QOS categories guaranteed bandwidth"
  96. fi
  97. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement