Skip to content

Queue Types

Queue types define the packet scheduling algorithm (also known as queueing discipline or qdisc) that determines how packets are transmitted when bandwidth becomes available. Selecting the appropriate queue type is fundamental to implementing effective Quality of Service (QoS) on your MikroTik router.

RouterOS provides several built-in queue types, each designed for specific traffic management scenarios. Understanding the characteristics and trade-offs of each queue type enables you to implement bandwidth controls that match your network requirements.

Queue types operate at the heart of RouterOS traffic shaping infrastructure. They determine the order in which packets leave the interface queue, how bandwidth is distributed among multiple traffic flows, and how the router responds to congestion.

When packets arrive faster than they can be transmitted, they accumulate in a queue. The queue type defines the algorithm that decides which packet gets transmitted next. This choice directly impacts latency, jitter, throughput, and fairness of bandwidth distribution among your users and applications.

The choice of queue type depends on your specific requirements:

RequirementRecommended Queue Type
Simple packet bufferingPFIFO/BFIFO
Equal bandwidth sharing among usersPCQ
Fairness among concurrent connectionsSFQ
Congestion control with early dropsRED
Hierarchical bandwidth shapingHTB
Bufferbloat elimination (AQM only)FQ-CoDel
Bufferbloat elimination with integrated shapingCAKE

RouterOS supports the following queue type kinds:

KindDescriptionBest For
bfifoByte-based FIFOByte-level buffer limits
pfifoPacket-based FIFOSimple packet buffering
pcqPer Connection QueueEqual bandwidth distribution
sfqStochastic Fairness QueuingFairness among connections
redRandom Early DetectionActive Queue Management
htbHierarchical Token BucketHierarchical traffic shaping
fq-codelFair Queuing Controlled DelayBufferbloat elimination with per-flow fairness
cakeCommon Applications Kept EnhancedIntegrated AQM + shaping for WAN links

PFIFO (Packet First-In, First-Out) and BFIFO (Byte First-In, First-Out) are the simplest queue types available. Both implement basic FIFO logic where the first packet to arrive is the first packet transmitted.

PFIFO manages queue capacity based on the number of packets waiting for transmission. Each packet occupies one queue slot regardless of its size. This provides predictable memory usage but can lead to inefficient bandwidth utilization when packet sizes vary significantly.

Key characteristics:

  • Queue limit measured in packet count
  • Predictable memory usage
  • No prioritization capability
  • Minimal CPU overhead

Configuration:

/queue type add name="PFIFO-100" kind=pfifo fifo-limit=100

BFIFO operates identically to PFIFO but measures queue fullness in bytes rather than packets. This provides more accurate bandwidth control when packets vary significantly in size.

Key characteristics:

  • Queue limit measured in bytes
  • Better bandwidth control with variable packet sizes
  • Slightly higher CPU overhead than PFIFO
  • No prioritization capability

Configuration:

/queue type add name="BFIFO-500KB" kind=bfifo bfifo-limit=500000

When to use FIFO:

  • Simple traffic buffering without QoS requirements
  • Situations where downstream devices handle all prioritization
  • Memory-constrained environments requiring predictable buffer usage

For detailed configuration and parameter explanations, see the PFIFO, BFIFO documentation.

PCQ is one of the most powerful and frequently used queue types in RouterOS. It dynamically divides traffic among multiple sub-streams based on a classifier, making it ideal for equal bandwidth sharing among multiple users or connections.

When you configure a PCQ queue type, the router automatically creates separate sub-queues for each unique value of the configured classifier. For example, if you use dst-address as the classifier, PCQ creates a separate sub-queue for each destination IP address, ensuring each user receives equal bandwidth.

Key characteristics:

  • Automatic per-user/connection bandwidth distribution
  • Dynamic sub-queue creation based on traffic classifiers
  • Configurable maximum rate limits
  • Supports burst for temporary speed increases

Common classifiers:

ClassifierCreates Sub-queue For
dst-addressEach destination IP (download)
src-addressEach source IP (upload)
dst-portEach destination port
src-portEach source port
src-and-dst-addressEach unique IP pair

Configuration example:

/queue type add name="PCQ_download" kind=pcq pcq-rate=10M pcq-classifier=dst-address
/queue type add name="PCQ_upload" kind=pcq pcq-rate=2M pcq-classifier=src-address

When to use PCQ:

  • Equal bandwidth sharing among multiple users
  • Per-IP bandwidth limiting in shared networks
  • Hotspot bandwidth management
  • Guest network bandwidth control

For detailed configuration examples and deployment scenarios, see the PCQ Example documentation.

SFQ (Stochastic Fairness Queuing) attempts to provide fair bandwidth distribution among multiple TCP/IP flows by hashing packet addresses and ports into a limited number of sub-queues. This approach ensures that no single connection can dominate the queue.

SFQ uses a hashing algorithm to categorize packets into a configurable number of sub-queues (buckets). The hash is calculated from source and destination IP addresses and port numbers. Each sub-queue is then serviced in round-robin fashion, ensuring that all flows get equal opportunity to transmit.

Key characteristics:

  • Fair distribution among concurrent connections
  • Reduces head-of-line blocking
  • Uses hashing (not perfect fairness)
  • Configurable queue depth

Configuration:

/queue type add name="SFQ-default" kind=sfq sfq-allows=128 sfq-flows=128 sfq-hash=algo/ip

Parameters:

ParameterDescriptionDefault
sfq-allowsNumber of sub-queues128
sfq-flowsNumber of flows per sub-queue128
sfq-hashHash algorithmalgo/ip

When to use SFQ:

  • Fair distribution among concurrent connections
  • P2P traffic management
  • Situations where you want rough fairness without PCQ complexity
  • When you need to prevent single connections from monopolizing bandwidth

RED (Random Early Detection) is an Active Queue Management (AQM) technique that proactively drops packets before the queue becomes full. This helps prevent TCP congestion avoidance algorithms from triggering globally synchronized drops across all connections.

RED monitors average queue size and begins randomly dropping packets when the average exceeds a minimum threshold. As the average queue size approaches the maximum threshold, the drop probability increases. This approach signals congestion to TCP senders before queue overflow occurs, resulting in smoother, more gradual congestion response.

Key characteristics:

  • Proactive packet dropping before queue overflow
  • Prevents global TCP synchronization
  • Configurable min/max thresholds and drop probabilities
  • Works only with TCP traffic (primarily)

Configuration:

/queue type add name="RED-default" kind=red red-limit=128 red-min-threshold=10 red-max-threshold=50 red-burst=20 red-avg-packet=1000

Parameters:

ParameterDescriptionTypical Range
red-limitMaximum queue size (packets)64-256
red-min-thresholdMinimum queue threshold10-30
red-max-thresholdMaximum queue threshold40-100
red-burstBurst allowance10-40
red-avg-packetAverage packet size1024-1500

When to use RED:

  • Reducing latency variance during congestion
  • Preventing TCP global synchronization
  • Bulk transfer optimization
  • Networks with varying congestion levels

HTB (Hierarchical Token Bucket) is the fundamental queueing discipline underlying all RouterOS queuing. It implements hierarchical token bucket shaping that allows you to create complex bandwidth allocation structures with parent and child queues.

HTB organizes queues in a hierarchy where parent queues can borrow bandwidth from their siblings when available. Each queue operates based on token bucket principles - packets wait for tokens to become available before transmission. This approach enables sophisticated bandwidth sharing where different classes of traffic can be guaranteed minimum bandwidth while sharing unused capacity.

Key characteristics:

  • Hierarchical queue structure
  • Guaranteed minimum bandwidth (CIR)
  • Bandwidth borrowing between queues
  • Priority-based servicing

Configuration:

/queue type add name="HTB-parent" kind=htb
/queue tree add parent=global queue=HTB-parent

When to use HTB:

  • Hierarchical QoS implementations
  • Complex bandwidth allocation schemes
  • Traffic classification with guaranteed minimums
  • When you need parent queues to manage child queue relationships

HTB is used implicitly in all RouterOS queue trees and simple queues. For detailed HTB configuration, see the HTB documentation.

Selecting the appropriate queue type requires understanding your specific requirements and the characteristics of each option.

  1. Simple buffering only? → Use PFIFO or BFIFO
  2. Equal sharing among users? → Use PCQ
  3. Fairness among connections? → Use SFQ
  4. Proactive congestion management? → Use RED
  5. Complex hierarchical shaping? → Use HTB

Often, you will combine queue types in hierarchical structures:

  • HTB parent with PCQ children - Hierarchical bandwidth allocation with per-user fairness
  • HTB parent with SFQ children - Traffic classes with connection-level fairness
  • HTB parent with RED children - Traffic classes with proactive congestion management
  • PCQ for user fairness within traffic classes - Most common production configuration

A typical ISP or enterprise configuration might look like:

/queue type
add name=PCQ_download kind=pcq pcq-rate=10M pcq-classifier=dst-address
add name=PCQ_upload kind=pcq pcq-rate=2M pcq-classifier=src-address
/queue tree
add parent=global queue=PCQ_download packet-mark=download
add parent=global queue=PCQ_upload packet-mark=upload

This provides 10Mbps download and 2Mbps upload shared equally among all users.

ParameterDescriptionApplies To
kindQueue type algorithmAll
nameUnique identifierAll
queueParent queue referenceTree queues
ParameterDescriptionRange
fifo-limitMax packets in queue0-65535
bfifo-limitMax bytes in queue0-4294967295
ParameterDescriptionRange
pcq-rateMaximum total bandwidth0-100000000000
pcq-classifierTraffic classifierdst-address, src-address, ports
pcq-limitMax sub-queues1-100000
pcq-burst-rateBurst data rate0-100000000000
pcq-burst-thresholdBurst threshold0-100000000000
pcq-burst-timeBurst time window1s-60s
ParameterDescriptionRange
sfq-allowsNumber of sub-queues1-128
sfq-flowsFlows per sub-queue1-128
sfq-hashHash algorithmalgo/ip
ParameterDescriptionRange
red-limitMax queue size0-4294967295
red-min-thresholdMin threshold0-4294967295
red-max-thresholdMax threshold0-4294967295
red-burstBurst allowance0-4294967295
red-avg-packetAverage packet size0-4294967295
ParameterDescriptionRange
htb-rateGuaranteed rate0-100000000000
htb-ceilMaximum rate0-100000000000
htb-priorityQueue priority1-8
htb-burst-rateBurst rate0-100000000000
htb-burst-thresholdBurst threshold0-100000000000
htb-burst-timeBurst time1s-60s