RouteOS小包优先,防下载影响游戏数据,宽带自动控流。
发布于2023-10-17 15:38 阅读1947次 #wanName用来指定上网口,dhcp模式直接填写端口全名,
如果是多拨可直接指定pppoe-out不用每个拨号都指定 speedMax为最大带宽,单位K。
upMax为上传最大带宽与下载同理 outEther为流量出口以便于监控并触发限速.
```
:local wanName "pppoe-out"
:local rateA "0-512000"
:local rateB "512000-2000000"
:local rateC "2000000-5000000"
:local rateD "5000000-0"
:local speedMax 200000
:local upMax 50000
:local outEther "ether1"
:local wanCount 0
:set wanCount [:len [/interface find name~$wanName]]
:for ii from=1 to=$wanCount do={
/ip firewall mangle add action=mark-connection chain=forward in-interface=($wanName.$ii) new-connection-mark=dconn-isp
/ip firewall mangle add action=mark-packet chain=forward connection-mark=dconn-isp in-interface=($wanName.$ii) new-packet-mark=dpkt-isp passthrough=yes
/ip firewall mangle add action=mark-packet chain=forward connection-bytes=$rateA in-interface=($wanName.$ii) new-packet-mark=dpkt-light-isp packet-mark=dpkt-isp passthrough=no
/ip firewall mangle add action=mark-packet chain=forward connection-bytes=$rateB in-interface=($wanName.$ii) new-packet-mark=dpkt-fair-isp packet-mark=dpkt-isp passthrough=no
/ip firewall mangle add action=mark-packet chain=forward connection-bytes=$rateC in-interface=($wanName.$ii) new-packet-mark=dpkt-weight-isp packet-mark=dpkt-isp passthrough=no
/ip firewall mangle add action=mark-packet chain=forward connection-bytes=$rateD in-interface=($wanName.$ii) new-packet-mark=dpkt-very-isp packet-mark=dpkt-isp passthrough=no
/ip firewall mangle add action=mark-connection chain=forward new-connection-mark=uconn-isp out-interface=($wanName.$ii)
/ip firewall mangle add action=mark-packet chain=forward connection-mark=uconn-isp new-packet-mark=upkt-isp out-interface=($wanName.$ii) passthrough=yes
}
/queue tree add max-limit=((($speedMax*95)/100)."K") name=Downsteam-ISP packet-mark=dpkt-isp parent=global queue=pcq-download-default
/queue tree add limit-at=((($speedMax*5)/100)."K") max-limit=((($speedMax*95)/100)."K") name=1.light-isp packet-mark=dpkt-light-isp parent=Downsteam-ISP priority=1 queue=pcq-download-default
/queue tree add limit-at=((($speedMax*4)/100)."K") max-limit=((($speedMax*95)/100)."K") name=2.fair-isp packet-mark=dpkt-fair-isp parent=Downsteam-ISP priority=2 queue=pcq-download-default
/queue tree add limit-at=((($speedMax*3)/100)."K") max-limit=((($speedMax*95)/100)."K") name=3.weight-isp packet-mark=dpkt-weight-isp parent=Downsteam-ISP priority=3 queue=pcq-download-default
/queue tree add limit-at=((($speedMax*2)/100)."K") max-limit=((($speedMax*95)/100)."K") name=4.very-isp packet-mark=dpkt-very-isp parent=Downsteam-ISP priority=4 queue=pcq-download-default
/queue tree add max-limit=((($upMax*95)/100)."K") name=Upsteam-ISP packet-mark=upkt-isp parent=global queue=pcq-upload-default
:set rateA ((($speedMax*95)/100)."K")
:set rateB ((($speedMax*80)/100)."K")
:set rateC ((($speedMax*70)/100)."K")
:set rateD ((($speedMax*60)/100)."K")
/tool traffic-monitor add name=down_start interface=$outEther traffic=received trigger=above threshold=((($speedMax*85)/100)."K") on-event="{\r\n/queue tree set [find name=\"Downsteam-ISP\"] max-limit=$rateA\r\n/queue tree set [find name=\"1.light-isp\"] max-limit=$rateA\r\n/queue tree set [find name=\"2.fair-isp\"] max-limit=$rateB\r\n/queue tree set [find name=\"3.weight-isp\"] max-limit=$rateC\r\n/queue tree set [find name=\"4.very-isp\"] max-limit=$rateD\r\n}"
:set rateA ((($speedMax*95)/100)."K")
:set rateB ((($speedMax*95)/100)."K")
:set rateC ((($speedMax*95)/100)."K")
:set rateD ((($speedMax*95)/100)."K")
/tool traffic-monitor add name=down_stop interface=$outEther traffic=received trigger=below threshold=((($speedMax*30)/100)."K") on-event="{\r\n/queue tree set [find name=\"Downsteam-ISP\"] max-limit=$rateA\r\n/queue tree set [find name=\"1.light-isp\"] max-limit=$rateA\r\n/queue tree set [find name=\"2.fair-isp\"] max-limit=$rateB\r\n/queue tree set [find name=\"3.weight-isp\"] max-limit=$rateC\r\n/queue tree set [find name=\"4.very-isp\"] max-limit=$rateD\r\n}"
:set rateA ((($upMax*70)/100)."K")
/tool traffic-monitor add name=up_start interface=$outEther traffic=transmitted trigger=above threshold=((($upMax*90)/100)."K") on-event="{\r\n/queue tree set [find name=\"Upsteam-ISP\"] max-limit=$rateA\r\n}"
:set rateA ((($upMax*95)/100)."K")
/tool traffic-monitor add name=up_stop interface=$outEther traffic=transmitted trigger=below threshold=((($upMax*30)/100)."K") on-event="{\r\n/queue tree set [find name=\"Upsteam-ISP\"] max-limit=$rateA\r\n}"
```
==========autoPCC为自动叠线参数修正,参考ROS多线叠加PCC参数自动修正========
```
#定时执行autoPCC 自动修正叠线参数与分流
:execute script="autoPCC"
#定时断开多线保留单线连接 并执行多线参数修正
{
/interface pppoe-client disable "pppoe-out2"
/interface pppoe-client disable "pppoe-out3"
:execute script="autoPCC"
}
#定时启用多线连接并执行autoPCC 自动修正叠线参数与分流
{
/interface pppoe-client enable "pppoe-out2"
/interface pppoe-client enable "pppoe-out3"
:delay 600:execute script="autoPCC"
}
#定时重启
/system rebot
```
1楼 1年前
经多次测试,同内网内使用迅雷下载站用17M/S的速度峰值下载,LOL不会出现掉包。个别区域可现实ADSL多拨实现宽带叠加。