Full Bandwidth Management Parent Queue Tree

This is the combination, continued and completion of bandwidth management methods previously using parent queue tree about to handle all sorts of purposes in an internet network that is more complex. Perhaps if you do not want to think too hard, you simply apply the simple queue to limit bandwidth that so powerful and assertive to limit bandwidth per client on your internet network. The problem is if we share the bandwidth with a simple queue is stiffness, and it’s hard for me to divide into many clients normally. It would be appropriate to be applied to the kind of dedicate internet connection.

 
For example If I have a totally the bandwidth internet connection is up to 2M, after i have tested by speed test, the bandwidth average is 512 kbps. It means that if I have 6 clients, be 512/6 = 86 kbps/clients normally, the ideal number is very small inappropriate for our client. If the bandwidth of up to 2 M calculated with 2000/6 to be around 334 kbps /clients, it can makes browsing and online game stuck if just only one client there who download and play streaming video, because the client spend almost all the average speed (512kbps) other clients will be especially problematic just for browsing or online game. In this case we need the priority to the fourth packets.

Full Bandwidth Management with the parent queue tree complete the lack of packets connection per client, especially to handle the internet network with many clients. The principle is equally divide the bandwidth to all the clients with bandwidth greater than that should be given as the limit bandwidth on each clients, in which we set Online GamesBrowsingDownloadVideo Streaming packets, connection packets. Well, for now I will make the Full Bandwidth Management using the parent queue tree. For more easily to make the complex rule, I will work with the scripts for more quickly.

Situation and Conditions:

Total Bandwidth = Up to 2 M

8 Clients that I have : 

Billing : 192.168.1.11
Client1    : 192.168.1.17
Client2    : 192.168.1.16
Client3    : 192.168.1.15
Client4    : 192.168.1.14
Client5    : 192.168.1.20
Client6    : 192.168.1.21
Master    : 192.168.1.8

In-Interface = ether1
Out-Interface = wlan1

/ip firewall address-list
add address=192.168.1.0/24  disabled=no list=MikroTik comment=””


1. Marking all the connection out and in of the interface Mikrotik router, and create the connection packets that allow you to capture it to the queue tree rule as bandwidth totally. Look at the script below!

1
2
3
4
5
6
7
8
/ip firewall mangle
add action=mark-connection chain=prerouting dst-address=!MikroTik in-interface=ether1 new-connection-mark=All-Inconn disabled=no passthrough=yes comment="CONNECTION-IN"
add action=mark-packet chain=prerouting connection-mark=All-Inconn disabled=no new-packet-mark=All-inpkt passthrough=yes comment="UPSTEAM PACKETS"
add action=mark-connection chain=forward in-interface=wlan1 new-connection-mark=All-Outconn disabled=no passthrough=yes comment="CONNECTION-OUT"
add action=mark-packet chain=forward connection-mark=All-Outconn new-packet-mark=All-Outpkt disabled=no passthrough=yes comment="DOWNSTEAM-PACKETS"
/queue tree
add name=All-Bandwidth parent=global-out packet-mark=All-Outpkt queue=default priority=1 max-limit=2M


The connection that we will use is All-Outconn as the above scripts with the connectionchain=forward out-interface=wlan1, which we subsequently differentiate into different connections to produce different connection packets.

2. Take the connections of All-Outconn then divide it into the connections to every client, and make connection packets every client that will captured by the queue tree per client.
Here are the following scripts :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/ip firewall mangle
add action=mark-connection chain=forward comment="Billing" disabled=no dst-address=192.168.1.11 new-connection-mark=Billing-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client1" disabled=no dst-address=192.168.1.17 new-connection-mark=Client1-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client2" disabled=no dst-address=192.168.1.16 new-connection-mark=Client2-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client3" disabled=no dst-address=192.168.1.15 new-connection-mark=Client3-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client4" disabled=no dst-address=192.168.1.14 new-connection-mark=Client4-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client5" disabled=no dst-address=192.168.1.20 new-connection-mark=Client5-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Client6" disabled=no dst-address=192.168.1.21 new-connection-mark=Client6-conn passthrough=yes connection-mark=All-Outconn
add action=mark-connection chain=forward comment="Master" disabled=no dst-address=192.168.1.8 new-connection-mark=Master-conn passthrough=yes connection-mark=All-Outconn
/ip firewall mangle
add action=mark-packet chain=forward new-packet-mark=Billing-pkt passthrough=yes connection-mark=Billing-conn comment="BILLING DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client1-pkt passthrough=yes connection-mark=Client1-conn comment="CLIENT1 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client2-pkt passthrough=yes connection-mark=Client2-conn comment="CLIENT2 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client3-pkt passthrough=yes connection-mark=Client3-conn comment="CLIENT3 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client4-pkt passthrough=yes connection-mark=Client4-conn comment="CLIENT4 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client5-pkt passthrough=yes connection-mark=Client5-conn comment="CLIENT5 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Client6-pkt passthrough=yes connection-mark=Client6-conn comment="CLIENT6 DOWNSTEAM"
add action=mark-packet chain=forward new-packet-mark=Master-pkt passthrough=yes connection-mark=Master-conn comment="MASTER DOWNSTEAM"
/queue tree
add name=Billing parent=All-Bandwidth packet-mark=Billing-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client1 parent=All-Bandwidth packet-mark=Client1-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client2 parent=All-Bandwidth packet-mark=Client2-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client3 parent=All-Bandwidth packet-mark=Client3-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client4 parent=All-Bandwidth packet-mark=Client4-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client5 parent=All-Bandwidth packet-mark=Client5-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Client6 parent=All-Bandwidth packet-mark=Client6-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name=Master parent=All-Bandwidth packet-mark=Master-pkt queue=default priority=8 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s


The scripts above consists with mangle and queue tree rule. From here we are already making the connections per ip address of clients, such as 

  • Connections Per Client : Billing-conn, Client1-conn, Client2-conn, Client3-conn, Client4-conn, Client5-conn, Client6-conn, Master-conn
  • Connection Packets Per Client : Billing-pkt, Client1-pkt, Client1-pkt, Client2-pkt, Client3-pkt, Client4-pkt, Client5-pkt, Client6-pkt, Master-pkt


3. The Connections per client that we have divided will separated into four packets connection such as browsing, online games, download, streaming video per client. Here are the forth part of four different packets connection. If there are any packets that have not been defined I asked for suggestions from those of you that had experience.

Part I : Making the packets per client for download and the queue tree with priority as you wish, here the following scripts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/ip firewall layer7-protocol
add comment="" name=download regexp="^.*get.+\\.(exe|rar|iso|zip|7zip|flv|mkv|avi|mp4|3gp|rmvb|mp3|img|dat|mov).*\$"
/ip firewall mangle
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=billing-dpkt passthrough=no packet-mark=Billing-pkt comment=Billing-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client1-dpkt passthrough=no packet-mark=Client1-pkt comment=Client1-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client2-dpkt passthrough=no packet-mark=Client2-pkt comment=Client2-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client3-dpkt passthrough=no packet-mark=Client3-pkt comment=Client3-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client4-dpkt passthrough=no packet-mark=Client4-pkt comment=Client4-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client5-dpkt passthrough=no packet-mark=Client5-pkt comment=Client5-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=client6-dpkt passthrough=no packet-mark=Client6-pkt comment=Client6-Down
add chain=forward layer7-protocol=download action=mark-packet new-packet-mark=master-dpkt passthrough=no packet-mark=Master-pkt comment=Master-Down
 
/queue tree
add name=Billing-Down parent=Billing packet-mark=billing-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client1-Down parent=Client1 packet-mark=client1-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client2-Down parent=Client2 packet-mark=client2-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client3-Down parent=Client3 packet-mark=client3-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client4-Down parent=Client4 packet-mark=client4-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client5-Down parent=Client5 packet-mark=client5-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Client6-Down parent=Client6 packet-mark=client6-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s
add name=Master-Down parent=Master packet-mark=master-dpkt queue=default priority=6 limit-at=180k max-limit=180k burst-limit=256k burst-threshold=135k burst-time=2s


Here we take and use the connections per client and differentiate into connection packets of downloaded by the extension files, so if there are any the extension files that you think is important, just add the the extension files that you want to the layer 7 protocols from the above scripts.

Part II. Making the video packet connection per client complete with the queue tree and priority as you please. Here the following scripts

1
2
/ip firewall layer7-protocol
add comment="" name=streaming regexp="^.*get.+\\.(c.youtube.com|cdn.dailymotion.com|metacafe.com|mccont.com).*\$"


If the above script doesn’t works, try the second regexp on the script below!

1
2
/ip firewall layer7-protocol
add comment="" name=streaming regexp="videoplayback|video"

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/ip firewall mangle
add comment=Billing-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=billing-spkt passthrough=no packet-mark=Billing-pkt
add comment=Client1-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client1-spkt passthrough=no packet-mark=Client1-pkt
add comment=Client2-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client2-spkt passthrough=no packet-mark=Client2-pkt
add comment=Client3-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client3-spkt passthrough=no packet-mark=Client3-pkt
add comment=Client4-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client4-spkt passthrough=no packet-mark=Client4-pkt
add comment=Client5-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client5-spkt passthrough=no packet-mark=Client5-pkt
add comment=Client6-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=client6-spkt passthrough=no packet-mark=Client6-pkt
add comment=Master-Streams chain=forward layer7-protocol=streaming action=mark-packet new-packet-mark=master-spkt passthrough=no packet-mark=Master-pkt
 
/queue tree
add name=Billing-Streams parent=Billing packet-mark=billing-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client1-Streams parent=Client1 packet-mark=client1-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client2-Streams parent=Client2 packet-mark=client2-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client3-Streams parent=Client3 packet-mark=client3-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client4-Streams parent=Client4 packet-mark=client4-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client5-Streams parent=Client5 packet-mark=client5-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client6-Streams parent=Client6 packet-mark=client6-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Master-Streams parent=Master packet-mark=master-spkt queue=default priority=8 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s


This is the similar method in making the connection packets like download packets is by using a layer 7 protocols, the content of streaming video other sites that have not been defined, please you add on the layer 7 protocols if you think that is important, and adjust the priority and limit speed on the queue tree as you please.

c. Membuat packets Online game per client lengkap dengan queue treenya, berikut ini adalah scriptsnya :

Part III : Making the Online games packet connection per client complete with the queue tree and priority, here the following scripts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/ip firewall mangle
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=tcp dst-port=5340-5352,6000-6152,10001-10011,14009-14030,18901-18909 comment="Online Game Portal"
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=tcp dst-port=39190,27780,29000,22100,10009,4300,15001,15002,7341,7451
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=tcp dst-port=40000,9300,9400,9700,7342,8005-8010,37466,36567,8822
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=tcp dst-port=47611,16666,20000,5105,29000,18901-18909,9015
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=udp dst-port=27005,27015
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=udp dst-port=27005-27020,13055,7800-7900,12060-12070
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=udp dst-port=8005-8010,9068,1293,1479,9401,9600,30000
add action=mark-packet chain=forward packet-mark=All-Outpkt new-packet-mark=gpkt passthrough=yes protocol=udp dst-port=14009-14030,42051-42052,40000-40050,13000-13080
/ip firewall mangle
add action=mark-packet chain=forward new-packet-mark=billing-gpkt passthrough=no dst-address=192.168.1.11 packet-mark=gpkt comment=Billing-Game
add action=mark-packet chain=forward new-packet-mark=client1-gpkt passthrough=no dst-address=192.168.1.17 packet-mark=gpkt comment=Client1-Game
add action=mark-packet chain=forward new-packet-mark=client2-gpkt passthrough=no dst-address=192.168.1.16 packet-mark=gpkt comment=Client2-Game
add action=mark-packet chain=forward new-packet-mark=client3-gpkt passthrough=no dst-address=192.168.1.15 packet-mark=gpkt comment=Client3-Game
add action=mark-packet chain=forward new-packet-mark=client4-gpkt passthrough=no dst-address=192.168.1.14 packet-mark=gpkt comment=Client4-Game
add action=mark-packet chain=forward new-packet-mark=client5-gpkt passthrough=no dst-address=192.168.1.20 packet-mark=gpkt comment=Client5-Game
add action=mark-packet chain=forward new-packet-mark=client6-gpkt passthrough=no dst-address=192.168.1.21 packet-mark=gpkt comment=Client6-Game
add action=mark-packet chain=forward new-packet-mark=master-gpkt passthrough=no dst-address=192.168.1.8 packet-mark=gpkt comment=Master-Game
/queue tree
add name=Billing-Game parent=Billing packet-mark=billing-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client1-Game parent=Client1 packet-mark=client1-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client2-Game parent=Client2 packet-mark=client2-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client3-Game parent=Client3 packet-mark=client3-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client4-Game parent=Client4 packet-mark=client4-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client5-Game parent=Client5 packet-mark=client5-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Client6-Game parent=Client6 packet-mark=client6-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s
add name=Master-Game parent=Master packet-mark=master-gpkt queue=default priority=1 limit-at=220k max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s


In this case we make the online-games connection at first, based on out-interface=wlan1 and tcp and udp of many ports that used by the online games. Then make the online games connection packets per ip address client from that, finally we capture the packets online games on queue tree and the priority as you wish.

Part IV. Make browsing connection packets per client complete with tree queue and give the priority, here the following script :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/ip firewall mangle
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Billing-pkt new-packet-mark=billing-bpkt protocol=tcp comment="BILLING BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client1-pkt new-packet-mark=client1-bpkt protocol=tcp comment="CLIENT1 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client2-pkt new-packet-mark=client2-bpkt protocol=tcp comment="CLIENT2 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client3-pkt new-packet-mark=client3-bpkt protocol=tcp comment="CLIENT3 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client4-pkt new-packet-mark=client4-bpkt protocol=tcp comment="CLIENT4 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client5-pkt new-packet-mark=client5-bpkt protocol=tcp comment="CLIENT5 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Client6-pkt new-packet-mark=client6-bpkt protocol=tcp comment="CLIENT6 BROWSING"
add action=mark-packet chain=forward connection-bytes=0-1000000 src-port=80,443 passthrough=no packet-mark=Master-pkt new-packet-mark=master-bpkt protocol=tcp comment="MASTER BROWSING"
/queue tree
add name="Billing-Browsing" parent=Billing packet-mark=billing-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client1-Browsing" parent=Client1 packet-mark=client1-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client2-Browsing" parent=Client2 packet-mark=client2-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client3-Browsing" parent=Client3 packet-mark=client3-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client4-Browsing" parent=Client4 packet-mark=client4-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client5-Browsing" parent=Client5 packet-mark=client5-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Client6-Browsing" parent=Client6 packet-mark=client6-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s
add name="Master-Browsing" parent=Master packet-mark=master-bpkt queue=default priority=2 limit-at=256k max-limit=256k burst-limit=720k burst-threshold=192k burst-time=2s


Take and use the connection per client then we make the new browsing connection by capturing based on port 80 and 443 (HTTP and HTTPS ports) and adding small bytes connection-bytes=0-1000000, port that commonly used in browsing the url site, small bytes of data may also be included here from the other three connection packets else, but small enough.


Once you collect the script above, then you adjust the scripts according to the interface of mikrotik router, the number and ip address of clients that you have, and give the priority of the queue tree as you please. After finished it, you just need to copy all the scripts to new terminal window of mikrotik winbox. The connection Packets which are beyond the fourth main connection packets (download, browsing, vedio streaming, and online games) of the queue tree should be captured by the connection packets of each parents queue tree per client. The result of those all of the above script as shown like the pictures above!

Rolar para cima