/ ppp secret add name="user1" service=pptp password="null" profile=default-encryption local address=192.168.70.1 remote-address=192.168.70.10 disabled=no
/ ppp secret add name="user2" service=pptp password="null" profile=default-encryption local-address=192.168.70.1 remote-address=192.168.70.11 disabled=no
/ ppp secret add name="user3" service=pptp password="null" profile=default-encryption local-address=192.168.70.1 remote-address=192.168.70.12 disabled=no
/ interface pptp-server add name="user1" user="user1" disabled=no
/ interface pptp-server add name="user2" user="user2" disabled=no
/ interface pptp-server add name="user3" user="user3" disabled=no
/ ip firewall mangle add chain=forward src-address=192.168.70.10 dst-address=0.0.0.0/0 action=mark-packet new-packet-mark=user1_up passthrough=no disabled=no
/ ip firewall mangle add chain=forward src-address=192.168.70.11 dst-address=0.0.0.0/0 action=mark-packet new-packet-mark=user2_up passthrough=no disabled=no
/ ip firewall mangle add chain=forward src-address=192.168.70.12 dst-address=0.0.0.0/0 action=mark-packet new-packet-mark=user3_up passthrough=no disabled=no
/ ip firewall mangle add chain=forward src-address=0.0.0.0/0 dst-address=192.168.70.10 action=mark-packet new-packet-mark=user1_down passthrough=no disabled=no
/ ip firewall mangle add chain=forward src-address=0.0.0.0/0 dst-address=192.168.70.11 action=mark-packet new-packet-mark=user2_down passthrough=no disabled=no
/ ip firewall mangle add chain=forward src-address=0.0.0.0/0 dst-address=192.168.70.12 action=mark-packet new-packet-mark=user3_down passthrough=no disabled=no
/ queue tree add name="Download" parent=global-out limit-at=0 queue=hotspot-default priority=8 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
/ queue tree add name="user1_down" parent=Download packet-mark=user1_down disabled=no
/ queue tree add name="user2_down" parent=Download packet-mark=user2_down disabled=no
/ queue tree add name="user3_down" parent=Download packet-mark=user3_down disabled=no
/ queue tree add name="Upload" parent=global-out limit-at=0 queue=hotspot-default priority=8 max-limit=0 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no
/ queue tree add name="user1_up" parent=Upload packet-mark=user1_up disabled=no
/ queue tree add name="user2_up" parent=Upload packet-mark=user2_up disabled=no
/ queue tree add name="user3_up" parent=Upload packet-mark=user3_up disabled=no
MaxRateDownload - ()
MaxRateUpload - ()
ActiveThresholddown - ()
ActiveThresholdup - ()
ParentDownload - ()
ParentUpload - ()
:local MaxRateDownload ("2000000");
:local MaxRateUpload ("2000000");
:local ActiveThresholddown ("5000");
:local ActiveThresholdup ("5000");
######################
:local MaxRateDownload ("2000000");
:local MaxRateUpload ("2000000");
:local ActiveThresholddown ("5000");
:local ActiveThresholdup ("5000");
:local ParentDownload ("Download");
:local ParentUpload ("Upload");
######################
######################
:local z;
:local i;
:local ii;
:local userX;
:global onlineclientsdown (0);
:global onlineclientsup (0);
:global connected (0);
######################
######################
:foreach i in=[/ppp active find] do={ :set userX [/ppp active get $i name];
:global connected ($connected+1);
/interface monitor-traffic [/interface find name=$userX] once do {:if ($received-bits-per-second>=$ActiveThresholddown) do { :set onlineclientsdown ($onlineclientsdown+1);}} };
:foreach ii in=[/ppp active find] do={ :set userX [/ppp active get $ii name];
/interface monitor-traffic [/interface find name=$userX] once do {:if ($sent-bits-per-second>=$ActiveThresholdup) do { :set onlineclientsup ($onlineclientsup+1);}} };
:if ($onlineclientsdown = 0) do {:set onlineclientsdown (1)};
:if ($onlineclientsup= 0) do {:set onlineclientsup (1)};
:local ratelimitdown ($MaxRateDownload/$onlineclientsdown)
:local ratelimitup ($MaxRateUpload/$onlineclientsup)
:foreach z in=[/ppp active find] do={ :set userX [/ppp active get $z name];
/queue tree set [/queue tree find name=($userX . "_down")] parent=$ParentDownload packet-mark=($userX . "_down") queue=hotspot-default priority=8 max-limit=$ratelimitdown
/queue tree set [/queue tree find name=($userX . "_up")] parent=$ParentUpload packet-mark=($userX . "_up") queue=hotspot-default priority=8 max-limit=$ratelimitup};
######################
######################
:local kbsmaxdown ($MaxRateDownload/1000);
:local kbsmaxup ($MaxRateUpload /1000);
:local kbsthr ($ActiveThresholddown/1000);
:local kbsdown ($ratelimitdown/1000);
:local kbsup ($ratelimitup/1000);
:log warning ("Shaper:");
:log info ("MaxRate Download : " . $MaxRateDownload . " bps /" . $kbsmaxdown . " kbs / Upload : " . $MaxRateUpload . " bps /" . $kbsmaxup . " kbs");
:log info ("Threshold: Download : " . $ActiveThresholddown . " bps /" . $kbsthr . " kbs / Upload : " . $ActiveThresholdup . " bps /" . $kbsthr . " kbs");
:log info ("Connected Users : " . $connected);
:log info ("Active Users : Download : " . $onlineclientsdown . " / Upload : " . $onlineclientsup);
:log info ("User Speed Download : " . $ratelimitdown . " bps /" . $kbsdown . " kbs / Upload : " . $ratelimitup . " bps /" . $kbsup . " kbs");
######################
# (C) Inlarion icq 429-587 Copyright!
######################
:local MaxRateDownload ("2000000");
:local MaxRateUpload ("2000000");
:local ActiveThresholddown ("5000");
:local ActiveThresholdup ("5000");
:local ParentDownload ("Download");
:local ParentUpload ("Upload");
######################
######################
:local z;
:local i;
:local ii;
:local userX;
:global onlineclientsdown (0);
:global onlineclientsup (0);
:global connected (0);
######################
######################
:foreach i in=[/ppp active find] do={ :set userX [/ppp active get $i name];
:global connected ($connected+1);
/interface monitor-traffic [/interface find name=$userX] once do {:if ($"received-bits-per-second">=$ActiveThresholddown) do { :set onlineclientsdown ($onlineclientsdown+1);}} };
:foreach ii in=[/ppp active find] do={ :set userX [/ppp active get $ii name];
/interface monitor-traffic [/interface find name=$userX] once do {:if ($"sent-bits-per-second">=$ActiveThresholdup) do { :set onlineclientsup ($onlineclientsup+1);}} };
:if ($onlineclientsdown = 0) do {:set onlineclientsdown (1)};
:if ($onlineclientsup= 0) do {:set onlineclientsup (1)};
:local ratelimitdown ($MaxRateDownload/$onlineclientsdown)
:local ratelimitup ($MaxRateUpload/$onlineclientsup)
:foreach z in=[/ppp active find] do={ :set userX [/ppp active get $z name];
/queue tree set [/queue tree find name=($userX . "_down")] parent=$ParentDownload packet-mark=($userX . "_down") queue=hotspot-default priority=8 max-limit=$ratelimitdown
/queue tree set [/queue tree find name=($userX . "_up")] parent=$ParentUpload packet-mark=($userX . "_up") queue=hotspot-default priority=8 max-limit=$ratelimitup};
######################
######################
:local kbsmaxdown ($MaxRateDownload/1000);
:local kbsmaxup ($MaxRateUpload /1000);
:local kbsthr ($ActiveThresholddown/1000);
:local kbsdown ($ratelimitdown/1000);
:local kbsup ($ratelimitup/1000);
:log warning ("Shaper:");
:log info ("MaxRate Download : " . $MaxRateDownload . " bps /" . $kbsmaxdown . " kbs / Upload : " . $MaxRateUpload . " bps /" . $kbsmaxup . " kbs");
:log info ("Threshold: Download : " . $ActiveThresholddown . " bps /" . $kbsthr . " kbs / Upload : " . $ActiveThresholdup . " bps /" . $kbsthr . " kbs");
:log info ("Connected Users : " . $connected);
:log info ("Active Users : Download : " . $onlineclientsdown . " / Upload : " . $onlineclientsup);
:log info ("User Speed Download : " . $ratelimitdown . " bps /" . $kbsdown . " kbs / Upload : " . $ratelimitup . " bps /" . $kbsup . " kbs");
######################
# (C) Inlarion icq 429-587 Copyright!
######################
:local MaxRateDownload ("2000000");
:local MaxRateUpload ("2000000");
:local ActiveThresholddown ("5000");
:local ActiveThresholdup ("5000");
:local ParentDownload ("Download");
:local ParentUpload ("Upload");
######################
######################
:local z;
:local i;
:local ii;
:local userX;
:global onlineclientsdown (0);
:global onlineclientsup (0);
:global connected (0);
######################
######################
:foreach i in=[/ppp active find] do={ :set userX [/ppp active get $i name];
:global connected ($connected+1);
/interface monitor-traffic [/interface find name=$userX] once do {:if ($"rx-bits-per-second">=$ActiveThresholddown) do { :set onlineclientsdown ($onlineclientsdown+1);}} };
:foreach ii in=[/ppp active find] do={ :set userX [/ppp active get $ii name];
/interface monitor-traffic [/interface find name=$userX] once do {:if ($"tx-bits-per-second">=$ActiveThresholdup) do { :set onlineclientsup ($onlineclientsup+1);}} };
:if ($onlineclientsdown = 0) do {:set onlineclientsdown (1)};
:if ($onlineclientsup= 0) do {:set onlineclientsup (1)};
:local ratelimitdown ($MaxRateDownload/$onlineclientsdown)
:local ratelimitup ($MaxRateUpload/$onlineclientsup)
:foreach z in=[/ppp active find] do={ :set userX [/ppp active get $z name];
/queue tree set [/queue tree find name=($userX . "_down")] parent=$ParentDownload packet-mark=($userX . "_down") queue=hotspot-default priority=8 max-limit=$ratelimitdown
/queue tree set [/queue tree find name=($userX . "_up")] parent=$ParentUpload packet-mark=($userX . "_up") queue=hotspot-default priority=8 max-limit=$ratelimitup};
######################
######################
:local kbsmaxdown ($MaxRateDownload/1000);
:local kbsmaxup ($MaxRateUpload /1000);
:local kbsthr ($ActiveThresholddown/1000);
:local kbsdown ($ratelimitdown/1000);
:local kbsup ($ratelimitup/1000);
:log warning ("Shaper:");
:log info ("MaxRate Download : " . $MaxRateDownload . " bps /" . $kbsmaxdown . " kbs / Upload : " . $MaxRateUpload . " bps /" . $kbsmaxup . " kbs");
:log info ("Threshold: Download : " . $ActiveThresholddown . " bps /" . $kbsthr . " kbs / Upload : " . $ActiveThresholdup . " bps /" . $kbsthr . " kbs");
:log info ("Connected Users : " . $connected);
:log info ("Active Users : Download : " . $onlineclientsdown . " / Upload : " . $onlineclientsup);
:log info ("User Speed Download : " . $ratelimitdown . " bps /" . $kbsdown . " kbs / Upload : " . $ratelimitup . " bps /" . $kbsup . " kbs");
######################
# (C) Inlarion icq 429-587 Copyright!
Source: https://habr.com/ru/post/110745/
All Articles