How to Share Bandwidth Equally with MikroTik PCQ

Aisyah Aldina

Illustration of a pizza cut into equal slices for a guide on sharing bandwidth equally with MikroTik PCQ

Hi everyone, in this post I want to show you how to share bandwidth equally with MikroTik PCQ. PCQ, or Per Connection Queue, is a queue type that automatically splits bandwidth evenly across every IP. You do not need to create one queue per client. A single Simple Queue for the whole network is enough, and every active client gets the same share.

This article continues from how to limit bandwidth on MikroTik with Simple Queue. The lab is a MikroTik CHR RouterOS 7.25.2 with two LAN clients, 192.168.56.101 and 192.168.56.102. I compared the results without PCQ and with PCQ side by side, including the case where one client opens many connections at once, like when running a download manager.

The Problem with One Shared Queue

Create a queue for one subnet

Simple Queue lan-56 for subnet 192.168.56.0/24 with the default-small queue type
/queue simple add name=lan-56 target=192.168.56.0/24 max-limit=256k/512k comment="limit satu LAN"

This queue limits the whole LAN to a total of 256k upload and 512k download. Its default queue type is default-small, a regular queue that does not split bandwidth per client. The limit is deliberately small because the lab uses a CHR free license, which is capped at about 1 Mbps per interface.

The second client falls behind

Without PCQ the second client gets only about 78 Kb/s

The first client runs 4 downloads at once, while the second client runs only 1 download.

for i in 1 2 3 4; do wget -q -O /dev/null "https://speed.cloudflare.com/__down?bytes=50000000" & done

As a result, the second client gets only about 78 Kb/s out of the 512k total.

See connections per client with Torch

Torch shows the first client opening three connections and the second client one connection
/tool torch interface=bridge1 dst-address=0.0.0.0/0 duration=5s

Torch shows that 192.168.56.101 has three active connections to the server, while 192.168.56.102 has only one. Without PCQ, bandwidth is shared per connection, so the client that opens the most connections gets the biggest share.

The queue total is already full

The total queue download is already full at 512 kbps
/queue simple print stats where name=lan-56

The queue download rate is 512.0kbps, which means the limit works, but the bandwidth is not shared fairly.

Enabling PCQ on a Simple Queue

Open the existing queue

Simple Queue window with a subnet target and max limit 256k/512k

In Queues, double click the lan-56 queue. Make sure Target is the subnet 192.168.56.0/24 and Max Limit is the total bandwidth you want to share.

Choose the PCQ queue type

Choosing the pcq-upload-default Queue Type on the Advanced tab

Click the Advanced tab. In Queue Type, under the Target Upload column, choose pcq-upload-default.

Upload and download

Queue Type set to pcq-upload-default for upload and pcq-download-default for download

Under the Target Download column, choose pcq-download-default, then click OK. The terminal version:

/queue simple set lan-56 queue=pcq-upload-default/pcq-download-default

These two queue types are built into RouterOS 7, so you do not need to create a new queue type.

Results After Enabling PCQ

The second client gets an equal share

With PCQ the second client gets about 249 Kb/s, half of 512k

Without changing anything on the clients, the second client’s download rises from 78 Kb/s to about 249 Kb/s, roughly half of 512k. The first client still uses 4 connections, but now its total share is also half.

Check the number of PCQ queues

Queue statistics showing pcq-queues 3/2
/queue simple print stats where name=lan-56

A new column appears, pcq-queues=3/2. The second number is the count of active download queues, which is 2 because two clients are downloading. PCQ creates one sub queue for each IP automatically.

A single client gets the full bandwidth

When the first client stops, the second client gets the full bandwidth at about 496 Kb/s

I stopped the downloads on the first client. A few seconds later, the second client climbed to about 496 Kb/s, close to the full 512k. This is the strength of PCQ with pcq-rate 0: no bandwidth goes to waste when only a few clients are active, and it is split evenly again as soon as other clients start using it.

My experience: Before trying it, I assumed PCQ needed a lot of extra configuration such as mangle and Queue Tree, like in older tutorials. It turns out that on RouterOS 7 you only need to change the queue type on an existing Simple Queue, and the effect shows up within seconds. Mangle and Queue Tree are only needed for more complex setups, for example prioritizing by traffic type.

Understanding PCQ Settings

View the default PCQ details

Details of the pcq-upload-default and pcq-download-default queue types with classifier and pcq-rate 0
/queue type print detail where kind=pcq

There are a few important values.

pcq-classifier=src-address : upload is grouped by the sender IP (the client)
pcq-classifier=dst-address : download is grouped by the destination IP (the client)
pcq-rate=0                 : no per client limit, max-limit is shared evenly
pcq-limit=50KiB            : queue size per client, not a speed limit
pcq-total-limit=2000KiB    : total queue size for all clients

Limiting the Maximum Speed per Client with pcq-rate

With pcq-rate 0, a single client on its own can use the entire max-limit. If you want every client to stay capped at a certain speed even when the network is quiet, for example a 256k plan per room in a boarding house, create a new queue type with pcq-rate.

Create a queue type with pcq-rate

Creating the pcq-down-256k queue type with pcq-rate 256k and applying it to the Simple Queue
/queue type add name=pcq-down-256k kind=pcq pcq-classifier=dst-address pcq-rate=256k
/queue simple set lan-56 queue=pcq-upload-default/pcq-down-256k

In WinBox, create the queue type in Queues on the Queue Types tab, click New, choose Kind pcq, fill in Rate and Classifier, then select that queue type on the Advanced tab of the Simple Queue.

Test with one client

A client on its own is still capped at about 249 Kb/s because of pcq-rate 256k

I ran a download on the second client only. This time the speed stayed at about 249 Kb/s, even though earlier a client on its own could get 496 Kb/s. So pcq-rate becomes the upper limit per client, while the queue max-limit remains the total limit for all clients. If pcq-rate multiplied by the number of active clients exceeds max-limit, PCQ goes back to splitting evenly.

Common Problems and How to Fix Them

Bandwidth is still not shared evenly

Check that the upload and download queue types are not swapped. Upload must use the src-address classifier and download must use dst-address. If they are swapped, all clients are treated as a single queue.

Some clients are not included in the split

Queues are processed from the top. If there is a dedicated per IP Simple Queue above the PCQ queue, that client uses that queue instead. Remove the per IP queue or move it below if you want every client to be part of PCQ.

The limit does not work at all

Check that the target is the LAN subnet, not the WAN IP, and check the FastTrack rule in IP Firewall Filter as covered in the Simple Queue article.

The speed per client feels low

PCQ splits max-limit across all active clients. With a max-limit of 20M and 10 active clients, each client gets about 2M. Raise max-limit to match your actual internet speed, usually slightly below the speed your ISP provides.

At this point the bandwidth of one network is shared evenly and automatically across every client with PCQ. In the next article we will cover MikroTik Queue Tree, which is used when you need more flexible bandwidth control with mangle. If you use PCQ on a network with many users, share the max-limit setting that works well for you in the comments.

Leave a Comment