Managing Bandwidth with Queue Trees and PCQ on MikroTik Print

  • Mikrotik
  • 28

Hello again, everyone! I’m Corels from Emmanuel Corels Creatives, and today we’re diving into a very practical topic: managing your network’s bandwidth using MikroTik’s Queue Trees and PCQ (Per Connection Queue). If you’ve ever wondered how to ensure that no single device hogs all your bandwidth or how to prioritize critical traffic (like VoIP or business applications), this guide is for you.

In this article, I’ll explain what Queue Trees and PCQ are, why they’re useful in real-world scenarios, and then walk you through a step-by-step configuration. By the end, you’ll have the tools to take control of your network’s traffic—and all in a friendly, beginner-focused way.


What’s the Problem?

Imagine you’re running a small office network. Most users are browsing the web and checking email, but one user’s video streaming or large file downloads are causing slow speeds for everyone else. Or perhaps you want to ensure that your VoIP calls always get top priority. This is where bandwidth management comes in. By shaping and controlling traffic, you can make sure each device gets its fair share and that critical applications perform optimally.


Understanding Queue Trees and PCQ

Queue Trees:
Queue Trees allow you to create hierarchical traffic shaping rules. You can define a parent queue that represents the total available bandwidth on an interface (for example, 20 Mbps on your WAN). Under that parent, you can create child queues for different types of traffic or even for individual devices. This structure helps you prioritize traffic and allocate bandwidth according to your needs.

PCQ (Per Connection Queue):
PCQ is a clever algorithm that automatically splits available bandwidth among active connections. It’s especially useful in networks with many users because it ensures fairness: every connection gets an equal share of the bandwidth allocated to that queue. For instance, if you set up a PCQ queue for download traffic, no matter how many users are online, each connection will receive a fair slice of the pie.


Real-World Scenario

Let’s say your office’s WAN link is 20 Mbps. You want:

  • VoIP traffic to have high priority (ensuring clear calls).
  • General web browsing and email to share the remaining bandwidth fairly.
  • A notorious coworker’s video streaming to be limited to 2 Mbps so that it doesn’t affect others.

Using Queue Trees and PCQ, you can set up a parent queue of 20 Mbps and then create child queues for each traffic category with appropriate priorities and limits.


Step-by-Step Configuration

Step 1: Define the Parent Queue

  1. Open WinBox and navigate to Queues → Queue Tree.
  2. Click the “+” button to add a new queue.
  3. Name: Enter something descriptive like Total_WAN.
  4. Parent: Set it to your WAN interface (e.g., ether1 or the PPPoE interface).
  5. Max Limit: Enter 20M (for 20 Mbps).
  6. Click OK.

This parent queue defines the total bandwidth available for outbound traffic on your WAN.


Step 2: Create a Child Queue for VoIP Traffic

  1. In Queue Tree, click the “+” button again.
  2. Name: Enter VoIP_Priority.
  3. Parent: Set to Total_WAN.
  4. Packet Mark: Here, we’ll mark VoIP packets via a mangle rule (more on that next).
  5. Priority: Set a high priority (e.g., 1—remember, lower numbers mean higher priority in MikroTik).
  6. Optionally, set a Max Limit (for instance, 5 Mbps if you want to reserve a chunk exclusively for VoIP).
  7. Click OK.

Real-world use: When VoIP packets are marked and processed by this queue, they’ll get preference over other types of traffic, ensuring clear and stable calls.


Step 3: Create a Mangle Rule to Mark VoIP Traffic

  1. Go to IP → Firewall → Mangle.
  2. Click the “+” button.
  3. Chain: Select forward (since we want to mark traffic that’s passing through).
  4. Protocol: Choose udp (many VoIP protocols use UDP).
  5. Dst. Port: Enter 5060 (commonly used for SIP) or the specific port your VoIP system uses.
  6. In the Action tab, select mark-packet.
  7. New Packet Mark: Name it voip-packets.
  8. Click OK.

This rule marks VoIP packets, so our child queue can pick them up and prioritize them.


Step 4: Set Up a Child Queue for Video Streaming (Bandwidth Limit)

  1. In Queue Tree, add a new child queue.
  2. Name: Enter Limit_Video_Streaming.
  3. Parent: Set to Total_WAN.
  4. Target: If you want to limit a specific device, enter its IP (e.g., 192.168.88.50/32). If it’s for all video traffic, use a packet mark or a separate policy.
  5. Max Limit: Set it to 2M/2M to cap at 2 Mbps.
  6. Click OK.

This queue ensures that the video streaming device never exceeds 2 Mbps, preserving bandwidth for other activities.


Step 5: Create a Child Queue Using PCQ for General Traffic

  1. In Queue Tree, add another child queue.
  2. Name: Enter General_Traffic.
  3. Parent: Set to Total_WAN.
  4. Packet Mark: Leave blank if you want it to catch all remaining traffic, or mark specific traffic if desired.
  5. Queue Type: Select or create a PCQ type. To create one:
    • Go to Queues → Queue Types.
    • Click “+” and choose pcq as the kind.
    • Set a Rate that defines the maximum bandwidth per connection, for instance, 1M (1 Mbps per connection).
    • Name it pcq-download.
  6. Back in your child queue, assign the PCQ type for download (and optionally for upload).
  7. Click OK.

This PCQ queue will dynamically allocate bandwidth among all remaining connections, ensuring fairness.


Final Thoughts and Testing

After configuring your Queue Trees and mangle rules:

  • Monitor in WinBox: Use the Queue Tree view to see real-time statistics. You’ll see how much traffic flows through each queue.
  • Test Performance: Run a speed test on various devices. Confirm that VoIP calls remain clear, general traffic is fairly shared, and the video streaming device never exceeds its 2 Mbps cap.
  • Adjust as Needed: Bandwidth management is not “set and forget.” Tweak priorities, rates, and limits as your network usage patterns change.

By using Queue Trees and PCQ, you can finely control your network’s bandwidth, ensuring smooth performance even during peak usage. This practical approach not only keeps your network running efficiently but also guarantees that critical services like VoIP have the necessary resources to function optimally.

I hope you found this guide helpful. If you have any questions or need further assistance, feel free to reach out. Happy networking, and here’s to a fair and balanced bandwidth for all!


Explained with practical clarity by
Corels – Admin, Emmanuel Corels Creatives


Does this help?

« Back