Advertisement
Guest User

Untitled

a guest
Sep 25th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # CAKE-autorate automatically adjusts bandwidth for CAKE in dependence on detected load and RTT
  4.  
  5. # cake-autorate-config.sh is a script that sets up defaults for CAKE-autorate
  6.  
  7. # Author: @Lynx (OpenWrt forum)
  8. # Inspiration taken from: @moeller0 (OpenWrt forum)
  9.  
  10. cake_autorate_version="1.0.0"
  11.  
  12. # *** OUTPUT OPTIONS ***
  13.  
  14. output_processing_stats=0 # enable (1) or disable (0) output monitoring lines showing processing stats
  15. output_cake_changes=0 # enable (1) or disable (0) output monitoring lines showing cake bandwidth changes
  16. debug=0 # enable (1) or disable (0) out of debug lines
  17.  
  18. # *** STANDARD CONFIGURATION OPTIONS ***
  19.  
  20. dl_if=eth0 # download interface
  21. ul_if=eth1 # upload interface
  22.  
  23. reflector_ping_interval_s=0.2 # (seconds, e.g. 0.2s or 2s)
  24.  
  25. # list of reflectors to use and number of pingers to initiate
  26. # pingers will be initiated with reflectors in the order specified in the list
  27. # additional reflectors will be used to replace any reflectors that go stale
  28. # so e.g. if 6 reflectors are specified and the number of pingers is set to 4, the first 4 reflectors will be used initially
  29. # and the remaining 2 reflectors in the list will be used in the event any of the first 4 go bad
  30. # a bad reflector will go to the back of the queue on reflector rotation
  31. reflectors=("1.1.1.1" "1.0.0.1" "8.8.8.8" "8.8.4.4" "101.101.101.101" "101.102.103.104")
  32. no_pingers=6
  33.  
  34. # delay threshold in ms is the extent of RTT increase to classify as a delay
  35. # this is automatically adjusted based on maximum on the wire packet size
  36. # (adjustment significant at sub 12Mbit/s rates, else negligible)
  37. delay_thr_ms=40 # (milliseconds)
  38.  
  39. min_dl_shaper_rate_kbps=140000 # minimum bandwidth for download (Kbit/s)
  40. base_dl_shaper_rate_kbps=180000 # steady state bandwidth for download (Kbit/s)
  41. max_dl_shaper_rate_kbps=210000 # maximum bandwidth for download (Kbit/s)
  42.  
  43. min_ul_shaper_rate_kbps=35000 # minimum bandwidth for upload (Kbit/s)
  44. base_ul_shaper_rate_kbps=45000 # steady state bandwidth for upload (KBit/s)
  45. max_ul_shaper_rate_kbps=52500 # maximum bandwidth for upload (Kbit/s)
  46.  
  47. # sleep functionality saves unecessary pings and CPU cycles by
  48. # pausing all active pingers when connection is not in active use
  49. enable_sleep_function=1 # enable (1) or disable (0) sleep functonality
  50. connection_active_thr_kbps=500 # threshold in Kbit/s below which dl/ul is considered idle
  51. sustained_idle_sleep_thr_s=60 # time threshold to put pingers to sleep on sustained dl/ul achieved rate < idle_thr (seconds)
  52.  
  53. startup_wait_s=0 # number of seconds to wait on startup (e.g. to wait for things to settle on router reboot)
  54.  
  55. # *** ADVANCED CONFIGURATION OPTIONS ***
  56.  
  57. # interval in ms for monitoring achieved rx/tx rates
  58. # this is automatically adjusted based on maximum on the wire packet size
  59. # (adjustment significant at sub 12Mbit/s rates, else negligible)
  60. monitor_achieved_rates_interval_ms=200 # (milliseconds)
  61.  
  62. # bufferbloat is detected when (bufferbloat_detection_thr) samples
  63. # out of the last (bufferbloat detection window) samples are delayed
  64. bufferbloat_detection_window=5 # number of samples to retain in detection window
  65. bufferbloat_detection_thr=3 # number of delayed samples for bufferbloat detection
  66.  
  67. # RTT baseline against which to measure delays
  68. # the idea is that the baseline is allowed to increase slowly to allow for path changes
  69. # and slowly enough such that bufferbloat will be corrected well before the baseline increases,
  70. # but it will decrease very rapidly to ensure delays are measured against the shortest path
  71. alpha_baseline_increase=0.001 # how rapidly baseline RTT is allowed to increase
  72. alpha_baseline_decrease=0.9 # how rapidly baseline RTT is allowed to decrease
  73.  
  74. # rate adjustment parameters
  75. # bufferbloat adjustment works with the lower of the adjusted achieved rate and adjusted shaper rate
  76. # to exploit that transfer rates during bufferbloat provide an indication of line capacity
  77. # otherwise shaper rate is adjusted up on load high, and down on load idle or low
  78. # and held the same on load medium
  79. achieved_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce achieved rate upon detection of bufferbloat
  80. shaper_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce shaper rate upon detection of bufferbloat
  81. shaper_rate_adjust_up_load_high=1.01 # how rapidly to increase shaper rate upon high load detected
  82. shaper_rate_adjust_down_load_low=0.9 # how rapidly to return down to base shaper rate upon idle or low load detected
  83. shaper_rate_adjust_up_load_low=1.01 # how rapidly to return up to base shaper rate upon idle or low load detected
  84.  
  85. # the load is categoried as low if < medium_load_thr, medium if > medium_load_thr and high if > high_load_thr relative to the current shaper rate
  86. medium_load_thr=0.75 # % of currently set bandwidth for detecting medium load
  87. high_load_thr=0.75 # % of currently set bandwidth for detecting high load
  88.  
  89. # refractory periods between successive bufferbloat/decay rate changes
  90. # the bufferbloat refractory period should be greater than the
  91. # average time it would take to replace the bufferbloat
  92. # detection window with new samples upon a bufferbloat event
  93. bufferbloat_refractory_period_ms=300 # (milliseconds)
  94. decay_refractory_period_ms=1000 # (milliseconds)
  95.  
  96. # interval for checking reflector health
  97. reflector_health_check_interval_s=1 # (seconds)
  98. # deadline for reflector response not to be classified as an offence against reflector
  99. reflector_response_deadline_s=1 # (seconds)
  100.  
  101. # reflector misbehaving is detected when $reflector_misbehaving_detection_thr samples
  102. # out of the last (reflector misbehaving detection window) samples are offences
  103. # thus with a 1s interval, window 60 and detection_thr 3, this is tantamount to
  104. # 3 offences within the last 60s
  105. reflector_misbehaving_detection_window=60
  106. reflector_misbehaving_detection_thr=3
  107.  
  108. global_ping_response_timeout_s=10 # timeout to set shaper rates to min on no ping response whatsoever (seconds)
  109.  
  110. if_up_check_interval_s=10 # time to wait before re-checking if rx/tx bytes files exist (e.g. from boot state)
  111.  
  112.  
  113. # Starlink satellite switch (sss) compensation options
  114. sss_compensation=0 # enable (1) or disable (0) Starlink handling
  115. # satellite switch compensation start times in seconds of each minute
  116. sss_times_s=("12.0" "27.0" "42.0" "57.0")
  117. sss_compensation_pre_duration_ms=300
  118. sss_compensation_post_duration_ms=200
  119.  
  120. # verify these are correct using 'cat /sys/class/...'
  121. case "${dl_if}" in
  122. \veth*)
  123. rx_bytes_path="/sys/class/net/${dl_if}/statistics/tx_bytes"
  124. ;;
  125. \ifb*)
  126. rx_bytes_path="/sys/class/net/${dl_if}/statistics/tx_bytes"
  127. ;;
  128. *)
  129. rx_bytes_path="/sys/class/net/${dl_if}/statistics/rx_bytes"
  130. ;;
  131. esac
  132.  
  133. case "${ul_if}" in
  134. \veth*)
  135. tx_bytes_path="/sys/class/net/${ul_if}/statistics/rx_bytes"
  136. ;;
  137. \ifb*)
  138. tx_bytes_path="/sys/class/net/${ul_if}/statistics/rx_bytes"
  139. ;;
  140. *)
  141. tx_bytes_path="/sys/class/net/${ul_if}/statistics/tx_bytes"
  142. ;;
  143. esac
  144.  
  145. if (( $debug )) ; then
  146. echo "DEBUG rx_bytes_path: $rx_bytes_path"
  147. echo "DEBUG tx_bytes_path: $tx_bytes_path"
  148. fi
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement