Translate

Saturday, December 7, 2013

Mikrotik Get Current Number Connection


how to know how many connection was there, for example how many client was in game or
how many people was using that connection.

for example gaming in my connection was marking with vip.conn

chain=postrouting action=mark-connection new-connection-mark=vip.conn    passthrough=yes protocol=udp dst-address-list=GAME out-interface=wan  dst-port=5000-5500 
so we can catch number connection that using vip.conn connection mark with this code:
:global inGaming[/ip firewall connection print count-only where connection-mark~"vip.conn"];

what exactly this for?, well sometimes we need to change dynamically some Tree in Queue Tree, 

if thre are two oe more people gaming then we slowdown the download and youtube tree like this code below:
:global inGaming[/ip firewall connection print count-only where connection-mark~"vip.conn"];
:if ($inGaming > 2) do={;
     /queue tree set [find name="download"] max-limit="430000"
     /queue tree set [find name="youtube"]  max-limit="430k"
};
then simply put it (the script) on event system scheduler (create new schedule) and set interval for 10 sec maybe. so it automatically check every 10 secs.