Hi everyone, in this post I want to show you how to set up MikroTik Queue Tree for beginners. Queue Tree is a more flexible way to manage bandwidth than Simple Queue. Traffic is first marked with mangle, then each mark is limited by queues arranged like a tree: one parent for the total bandwidth, and several branches for each group.
This article continues from Simple Queue and PCQ. The lab is a MikroTik CHR RouterOS 7.25.2 with two LAN clients, 192.168.56.101 and 192.168.56.102. I walk through the simplest example, limiting the download of two clients with different shares, then test priority and limit-at, which often confuse people.
How Queue Tree Works
Understand the flow

There are two parts you need to create.
1. Mangle : marks packets, for example packets from client 1 get the mark klien1-pkt
2. Queue Tree : limits packets based on that markUnlike Simple Queue, which uses a target IP, Queue Tree has no target. Queue Tree only recognizes packet marks. The parent determines where the queue is attached. An interface parent limits traffic leaving that interface, so parent bridge1 limits the download to the clients, while parent ether1 limits the upload to the internet.
I removed the lan-56 Simple Queue from the PCQ article first, so there are not two limits working on the same traffic.
/queue simple remove lan-56Marking Packets with Mangle
Create the mangle rules

/ip firewall mangle add chain=forward src-address=192.168.56.101 action=mark-connection new-connection-mark=klien1-conn passthrough=yes comment="klien 1"
/ip firewall mangle add chain=forward connection-mark=klien1-conn action=mark-packet new-packet-mark=klien1-pkt passthrough=no
/ip firewall mangle add chain=forward src-address=192.168.56.102 action=mark-connection new-connection-mark=klien2-conn passthrough=yes comment="klien 2"
/ip firewall mangle add chain=forward connection-mark=klien2-conn action=mark-packet new-packet-mark=klien2-pkt passthrough=noThe pattern always has two steps. First, the connection opened by the client gets a connection mark. Second, every packet in that connection gets a packet mark. Because the connection mark sticks to the connection, reply packets from the internet heading to the client are marked too, even though their src-address is a server on the internet. In WinBox, these rules are created in IP, Firewall, on the Mangle tab.
Pay attention to passthrough. On mark-connection choose yes, so the packet continues to the mark-packet rule below it. On mark-packet choose no, so the mark is not overwritten by another rule.
My experience: The first time I ran print, the last three rules briefly showed the I flag, meaning invalid. It turned out to be only momentary, because print ran at the same time the rules were being added. When I ran print again, every rule was normal. So do not panic if you see the I flag right after adding rules, just check again a few seconds later.
Creating the Queue Tree
Create the parent queue

Click Queues, the Queue Tree tab, then New. Set Name to download-lan, Parent to bridge1, click the plus sign next to Max Limit and enter 512k. Click OK. This parent queue limits the total download of the whole LAN.
Create the branch for client 1

Click New again. Set Name to klien1-down, Parent to download-lan, click the plus sign next to Packet Marks and enter klien1-pkt, and set Max Limit to 128k. Click OK.
Finish in the terminal

I created the branch for client 2 in the terminal, and checked the whole result at the same time.
/queue tree add name=klien2-down parent=download-lan packet-mark=klien2-pkt max-limit=384k
/queue tree printThe terminal version of the two previous queues:
/queue tree add name=download-lan parent=bridge1 max-limit=512k
/queue tree add name=klien1-down parent=download-lan packet-mark=klien1-pkt max-limit=128kThe parent queue does not need a packet mark. A branch queue must have a packet mark, because without a mark no packets go into it.
Testing with Two Clients
Client 1 download

Both clients download a large file at the same time. Client 1 gets about 123 Kb/s, matching the 128k max-limit.
Client 2 download

Client 2 gets about 369 Kb/s, matching the 384k max-limit. Together they total about 512k, the same as the parent queue.
Check the statistics and mangle counters

/queue tree print stats
/ip firewall mangle print stats where !dynamicThe rate of klien1-down is 128480 and klien2-down is 382464 bps, while download-lan is 510944 bps. The mark-packet mangle counters also keep increasing. If the mangle counters stay at zero, the rules do not match the traffic, and the queue tree will not work at all. This is the fastest way to troubleshoot Queue Tree.
Priority and Limit-at
Priority decides which branch is served first when branches compete for the parent bandwidth. The value ranges from 1 to 8, and 1 is the highest. Limit-at is the guaranteed share for that branch.
Test priority without limit-at

I changed the max-limit of both branches to 512k, then gave client 1 priority 1 and client 2 priority 8.
/queue tree set klien1-down max-limit=512k priority=1
/queue tree set klien2-down max-limit=512k priority=8The result is that client 1 takes 510944 bps and client 2 gets a rate of 0. The download on client 2 practically stops. Priority without limit-at can leave a low priority branch with nothing at all.
Guarantee bandwidth with limit-at

/queue tree set klien2-down limit-at=128kAfter client 2 was given limit-at 128k, its rate rose to 128480 bps, while client 1 dropped to 385448 bps. This is the order in which Queue Tree hands out bandwidth: every branch gets its limit-at first, then the rest goes to the branch with the highest priority up to its own max-limit. Make sure the sum of limit-at across all branches does not exceed the parent max-limit.
Common Problems and How to Fix Them
Queue Tree does not limit anything
Check the mangle counters with print stats. If they are zero, check the chain, src-address, and mark names. The packet mark name in mangle and in the queue tree must be exactly the same. Downloads that were already running before the rules were created are sometimes not marked, so restart the download after the rules are active.
Upload is not limited
Parent bridge1 only limits traffic toward the clients. Create a second parent queue with parent ether1 or your WAN interface, then create branches with the same packet marks to limit the upload.
Traffic still slips through because of FastTrack
FastTracked packets bypass mangle. If the router uses the default configuration with a FastTrack rule, add connection-mark=no-mark to the FastTrack rule or disable it temporarily for testing.
Conflict with Simple Queue
If the same traffic is also limited by a Simple Queue, the smallest limit applies and the results get confusing. Choose one method for each type of traffic.
At this point you can build a Queue Tree with mangle, arrange parent and branch queues, and understand priority and limit-at from real test results. In the next article we will cover how to set up a MikroTik PPPoE client for an internet connection from your ISP. If you have a Queue Tree setup for gaming or streaming, share it in the comments.












