MikroTik Hierarchical Queueing: Precise Bandwidth Control for ISP Networks

MikroTik Hierarchical Queueing: Precise Bandwidth Control for ISP Networks

Build predictable subscriber, sector, and backhaul performance with Queue Trees, packet marks, and PCQ.

For an ISP or WISP, bandwidth management is not simply about setting a speed limit for a customer. It is about protecting the upstream connection, preventing a congested sector from affecting the rest of the network, delivering the correct service-plan speed, and keeping latency under control when the network is busy.

MikroTik RouterOS Queue Trees use Hierarchical Token Bucket, commonly called HTB, to create a structured bandwidth policy. Instead of managing a long, flat list of independent limits, an operator can build a hierarchy that reflects the actual network: backhaul capacity at the top, sectors or distribution areas below it, and service plans or individual subscribers at the bottom.

The objective: Make sure no individual subscriber, plan, sector, or traffic class can consume capacity that another critical part of the network needs.

Why Flat Simple Queues Become Difficult at Scale

Simple Queues are useful for small deployments and straightforward subscriber limits. They are easy to understand and quick to deploy. However, a large Simple Queue configuration can become harder to manage as the network grows.

Simple Queues are processed in order. In a long queue list, traffic may need to be evaluated against many entries before it reaches the applicable queue. They also do not naturally express the relationship between a subscriber, a service plan, a sector, and the upstream circuit.

Queue Trees are usually a better fit when you need to:

  • Cap an entire uplink or backhaul circuit.
  • Limit total usage for a sector, tower, VLAN, or service area.
  • Guarantee bandwidth for business customers or critical traffic.
  • Allow lower-priority traffic to use unused capacity without affecting important services.
  • Use PCQ to fairly distribute bandwidth among multiple subscribers.
  • Build a repeatable structure that can grow with the network.

How the Hierarchy Works

A practical Queue Tree design mirrors the physical and logical structure of the network. A typical layout may look like this:

Backhaul or upstream circuit

↳ Sector or service-area allocation

↳ Service-plan traffic class

↳ Individual subscribers, often managed with PCQ

The top-level queue protects the actual available capacity. The sector-level queue prevents one sector from consuming more than its assigned share. The plan-level or subscriber-level queue enforces the service the customer purchased.

RouterOS uses limit-at for committed bandwidth and max-limit for the maximum allowed bandwidth. In general, the sum of child limit-at values should not exceed the parent queue's max-limit.

Plan the Direction Before Building the Tree

Queue Trees are one-directional. For subscriber traffic, build separate logic for upload and download. Always think about traffic from the router's point of view.

Traffic DirectionTraffic Arrives FromTypical Queue Parent
Subscriber uploadCustomer VLAN or access networkUpstream or backhaul interface
Subscriber downloadUpstream or internet-facing interfaceCustomer VLAN or sector interface

For this example, assume:

  • ether1-uplink is the upstream internet or backhaul interface.
  • vlan-sector-north is a subscriber-facing sector VLAN.
  • The upstream circuit is limited to 500 Mbps.
  • The north sector is allocated 180 Mbps upload and 300 Mbps download.
  • Subscribers in the example plan receive up to 50 Mbps.
Upload: protect backhaul and sector capacity. Article example • limits are ceilings, not guaranteed simultaneous throughput
The upload tree is rooted at the upstream interface. PCQ shares the sector allocation among matching subscribers, subject to the configured per-subscriber rate. Select the illustration for a larger view.

Step 1: Create an Address List for the Service Plan

Address lists give RouterOS a clean way to identify subscribers that belong to a plan, sector, customer class, or VLAN. In a production ISP environment, these lists may be maintained through static assignments, DHCP leases, PPP profiles, RADIUS, scripts, or an automation platform.

/ip firewall address-list
add list=plan-50m-north address=10.20.10.0/24 comment="North sector 50 Mbps subscribers"

Step 2: Mark the Subscriber Traffic

Queue Trees use packet marks to identify which traffic belongs in each leaf queue. The following example marks upload traffic entering from the north-sector VLAN and download traffic arriving from the upstream interface.

/ip firewall mangle
add chain=prerouting in-interface=vlan-sector-north \
    src-address-list=plan-50m-north \
    action=mark-packet new-packet-mark=north-50m-upload \
    passthrough=no comment="HQ: North 50M subscriber upload"

add chain=prerouting in-interface=ether1-uplink \
    dst-address-list=plan-50m-north \
    action=mark-packet new-packet-mark=north-50m-download \
    passthrough=no comment="HQ: North 50M subscriber download"
Important: Review FastTrack before enabling Queue Trees. FastTracked traffic can bypass mangle and queue processing. Any traffic that must be shaped needs to be excluded from FastTrack, or FastTrack must be disabled for that traffic class.

For larger or more complex policies, connection marks can reduce repeated matching work. Mark the connection once, then mark the packets that belong to that connection.

/ip firewall mangle
add chain=prerouting connection-state=new \
    src-address-list=plan-50m-north \
    action=mark-connection new-connection-mark=north-50m-conn \
    passthrough=yes comment="HQ: Mark North 50M outbound connections"

add chain=prerouting connection-state=new \
    dst-address-list=plan-50m-north \
    action=mark-connection new-connection-mark=north-50m-conn \
    passthrough=yes comment="HQ: Mark North 50M inbound connections"

add chain=prerouting in-interface=vlan-sector-north \
    connection-mark=north-50m-conn \
    action=mark-packet new-packet-mark=north-50m-upload \
    passthrough=no comment="HQ: Mark North 50M upload packets"

add chain=prerouting in-interface=ether1-uplink \
    connection-mark=north-50m-conn \
    action=mark-packet new-packet-mark=north-50m-download \
    passthrough=no comment="HQ: Mark North 50M download packets"

Choose one marking approach for a traffic class. Do not deploy both examples for the same traffic unless the design has been adjusted to prevent overlapping rules.

Step 3: Create PCQ Types for Fair Subscriber Distribution

Per Connection Queue, or PCQ, is useful when multiple subscribers share a plan or sector allocation. For download traffic, PCQ commonly classifies by destination address. For upload traffic, it commonly classifies by source address.

/queue type
add name=pcq-50m-download kind=pcq \
    pcq-rate=50M pcq-classifier=dst-address \
    comment="50 Mbps per subscriber download"

add name=pcq-50m-upload kind=pcq \
    pcq-rate=50M pcq-classifier=src-address \
    comment="50 Mbps per subscriber upload"

Step 4: Build the Queue Tree

The following example creates an upload branch rooted at the upstream interface and a download branch rooted at the north-sector VLAN. The sector queues are inner queues that control aggregate capacity; the plan queues are leaf queues that process marked traffic.

/queue tree
add name=Backhaul-Up parent=ether1-uplink max-limit=500M \
    comment="HQ: Total upstream capacity"

add name=Sector-North-Up parent=Backhaul-Up max-limit=180M \
    comment="HQ: North sector upload allocation"

add name=North-Plan-50M-Up parent=Sector-North-Up \
    packet-mark=north-50m-upload queue=pcq-50m-upload \
    max-limit=180M comment="HQ: North 50M plan upload"

add name=Sector-North-Down parent=vlan-sector-north max-limit=300M \
    comment="HQ: North sector download allocation"

add name=North-Plan-50M-Down parent=Sector-North-Down \
    packet-mark=north-50m-download queue=pcq-50m-download \
    max-limit=300M comment="HQ: North 50M plan download"

As additional service plans are introduced, add additional marked leaf queues beneath the appropriate sector parent. For example, a business plan can receive a higher limit-at value or a higher priority than best-effort residential traffic.

/queue tree
add name=North-Business-Up parent=Sector-North-Up \
    packet-mark=north-business-upload queue=pcq-business-upload \
    limit-at=40M max-limit=150M priority=2 \
    comment="HQ: North business upload priority"
Download: share the sector allocation with PCQ. The article’s download tree has a separate egress parent
The download parent is the customer-facing sector interface. The per-subscriber ceiling does not override the sector’s aggregate capacity or upstream constraints. Select the illustration for a larger view.

Operational Design Considerations

  • Start with measured capacity: Shape slightly below the real, tested throughput of an upstream circuit or wireless backhaul.
  • Separate infrastructure traffic: Router management, tower monitoring, backhaul control, VoIP, and business services may need protected traffic classes.
  • Use meaningful names: Queue names should identify the direction, site, sector, and purpose.
  • Keep the hierarchy consistent: Use the same parent and child structure at every site where possible.
  • Avoid packet-mark sprawl: Use address lists, plan-level classes, PCQ, and automation instead of unnecessary unique packet marks.
  • Test before production: Validate queue rules in a maintenance window or controlled segment before rolling them out network-wide.
A queue works only when traffic reaches it. Classification, packet marks, queue selection, and validation belong together
Confirm packet-mark and queue counters under controlled traffic. Validate latency and fairness as well as raw speed, and review FastTrack behavior for shaped traffic. Select the illustration for a larger view.

Validate the Configuration

After deployment, confirm that mangle counters increase and that the appropriate Queue Tree entries show traffic. If packet marks are not incrementing, the queue cannot shape the traffic.

/ip firewall mangle print stats where comment~"HQ"

/queue tree print stats

During validation, test more than raw speed. Run simultaneous subscriber traffic, monitor latency, check queue drops, and verify that one heavily used subscriber does not prevent other subscribers from receiving the bandwidth they should have.

What success looks like: The backhaul stays within planned capacity, sector congestion is contained, subscriber plans are enforced accurately, and critical services remain responsive during periods of high demand.

A Better Way to Scale Bandwidth Policy

Hierarchical Queueing is not just a way to slow traffic down. It is a way to make bandwidth behavior intentional. When a network has clear parent limits, sector allocations, plan classes, and subscriber fairness, congestion becomes manageable instead of unpredictable.

Every ISP network has different access technologies, oversubscription goals, traffic patterns, and service obligations. The examples above are a starting framework, not a universal copy-and-paste configuration. A well-designed Queue Tree should match the actual interfaces, subscriber addressing, backhaul capacity, and business priorities of the network it serves.

Need Help Designing MikroTik QoS?

Link Technologies, Inc. helps ISPs, WISPs, hosting providers, and enterprise organizations design, deploy, document, and support scalable MikroTik RouterOS bandwidth-management policies.

Contact Our Team Explore Our Services
Technical References
MikroTik RouterOS Queues Documentation
MikroTik PCQ Example
MikroTik Mangle Documentation

Link Technologies, Inc.
IT Infrastructure • Wireless • Fiber • Hosting • Cloud Services
shop.linktechs.net • sales@linktechs.net • 314-735-0270

Leave your comment

*
Only registered users can leave comments.