xuxi3201 发表于 2025-3-17 11:07:04

根据流畅度ros做sstp自动禁用12

本帖最后由 xuxi3201 于 2025-3-17 11:37 编辑

根据流畅度ros做sstp自动禁用

共三步
第一 查询每秒的流量
连续8秒
这个脚本重复6次


# ss076eight1
# s076max
{
:global ss076maxr0
:global ss076maxt0
#
:global ss076maxr1 0
:global ss076maxt1 0
:global ss076eightr1 0
:global ss076eightt1 0
:local iii "ss086176"
#
:for jjj from=1 to=8 do={
/interface monitor-traffic $iii once do={
:set ss076maxr0 ($"rx-bits-per-second" / 1024)
:set ss076maxt0 ($"tx-bits-per-second" / 1024)
}
:if ($ss076maxr0 > $ss076maxr1) do={ :set ss076maxr1 $ss076maxr0 }
:if ($ss076maxt0 > $ss076maxt1) do={ :set ss076maxt1 $ss076maxt0 }
:set ss076eightr1 ($ss076eightr1 + $ss076maxr0)
:set ss076eightt1 ($ss076eightt1 + $ss076maxt0)
:delay 1
}
}
#




第二
对第一个脚本的6个结果做分析
如果小于5000并且持续有流量 就判断为:网络不流畅
就满足条件禁用sstp
# ss076eightcounter
{
# counter
:global ss076maxr1
:global ss076maxr2
:global ss076maxr3
:global ss076maxr4
:global ss076maxr5
:global ss076maxr6
:global ss6slow 0
:global ss6counter 0
:global ss6switch 0
:local ss6limitmax 5000
:local ss6limitmin 200
#
:if ($ss076maxr1 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr1 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
:if ($ss076maxr2 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr2 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
:if ($ss076maxr3 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr3 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
:if ($ss076maxr4 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr4 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
:if ($ss076maxr5 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr5 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
:if ($ss076maxr6 > $ss6limitmin ) do={
:set ss6counter ($ss6counter + 1)
:if ($ss076maxr6 < $ss6limitmax ) do={ :set ss6slow ($ss6slow + 1) }
}
#
/ip/route
:if ( active ] ) do={
:if (($ss6slow = 6) && ($ss6counter > 3)) do={
:set ss6switch 1
:log info ("   ss6slow $ss6slow   ss6counter $ss6counter   ss6switch $ss6switch ")
} else={ :set ss6switch 0}
}

}
#



第三步
从另外一个角度确认网络不流畅


第四步
如果sstp为不使用
就执行
从另外一个角度确认网络不流畅
如果是流畅就恢复sstp


页: [1]
查看完整版本: 根据流畅度ros做sstp自动禁用12