Bandwidth Limiting with Simple Queues
Bandwidth Limiting with Simple Queues
Section titled âBandwidth Limiting with Simple QueuesâRouterOS Version: 7.x+ Difficulty: Beginner Estimated Time: 30 minutes
TL;DR (Quick Start)
Section titled âTL;DR (Quick Start)âFor the impatient: hereâs the 30-second version.
# Limit client to 5M upload / 10M download with 2M guaranteed/queue simple add target=192.168.88.100/32 max-limit=5M/10M limit-at=2M/2M name=client-limitOverview
Section titled âOverviewâSimple Queues are RouterOSâs most intuitive tool for bandwidth management, designed to limit and prioritize traffic for specific targets like IP addresses, subnets, or interfaces. Unlike the more complex Queue Tree system, Simple Queues provide an integrated solution that handles both upload and download limitations in a single configuration entry.
Understanding Simple Queues is essential for network administrators who need to ensure fair bandwidth distribution, prevent network congestion, and guarantee service levels for critical applications.
The Queue Hierarchy: Where Simple Queues Fit
Section titled âThe Queue Hierarchy: Where Simple Queues FitâRouterOS implements a sophisticated queuing system based on Hierarchical Token Bucket (HTB) algorithm. Understanding this hierarchy is crucial for effective bandwidth management:
Key Concepts:
- Processing Order: Every packet must traverse Simple Queues sequentially until it matches a rule or reaches the end
- Bidirectional Control: Simple Queues can limit both upload and download in a single entry
- Target-Based: Queues identify traffic based on source/destination addresses and interfaces
Understanding Rate Limiting vs. Rate Equalizing
Section titled âUnderstanding Rate Limiting vs. Rate EqualizingâSimple Queues can operate in two fundamental modes, controlled by the queue size parameter:
Rate Limiting (Shaper Mode)
Section titled âRate Limiting (Shaper Mode)âWhen queue-size=0, packets exceeding the rate limit are dropped immediately:
Incoming Traffic: ââââââââââââââââââââ (20 Mbps)Rate Limit: ââââââââââ (10 Mbps)Result: ââââââââââ (10 Mbps - excess dropped)Use cases:
- Strict bandwidth enforcement
- Preventing network abuse
- Compliance with ISP limitations
Rate Equalizing (Scheduler Mode)
Section titled âRate Equalizing (Scheduler Mode)âWhen queue-size=unlimited, packets exceeding the rate limit are queued and delayed:
Incoming Traffic: ââââââââââââââââââââ (20 Mbps burst)Rate Limit: ââââââââââ (10 Mbps)Result: ââââââââââââââââââââââ (20 Mbps delivered over time)Use cases:
- Smoothing bursty traffic
- Maintaining user experience during congestion
- Buffering for variable-speed connections
The Two-Rate System: CIR and MIR
Section titled âThe Two-Rate System: CIR and MIRâSimple Queues implement a sophisticated two-rate limiting system:
Committed Information Rate (CIR) - limit-at
Section titled âCommitted Information Rate (CIR) - limit-atâThe guaranteed minimum bandwidth that a queue will receive regardless of network congestion:
# Guarantee 5 Mbps minimum for critical server/queue simple add target=192.168.1.100 limit-at=5M/5M max-limit=20M/20M name=critical-serverMaximum Information Rate (MIR) - max-limit
Section titled âMaximum Information Rate (MIR) - max-limitâThe maximum allowed bandwidth when network capacity is available:
Burst Mechanism: Temporary Speed Boosts
Section titled âBurst Mechanism: Temporary Speed BoostsâThe burst feature allows queues to exceed their max-limit temporarily when average usage is below the threshold:
Burst Parameters
Section titled âBurst Parametersâ- burst-limit: Maximum speed during burst (e.g., 50M)
- burst-threshold: Average rate trigger for burst allowance (e.g., 8M)
- burst-time: Time window for average calculation (e.g., 8s)
Burst Logic Flow
Section titled âBurst Logic FlowâExample: A user with 10M max-limit can burst to 50M when their average usage over the last 8 seconds is below 8M.
Prerequisites
Section titled âPrerequisitesâ- RouterOS 7.x+ device with administrative access
- Basic understanding of IP addressing and network interfaces
- Test client connected to ether2 (or adjust interface names accordingly)
- Important: Ensure FastTrack is disabled for traffic you want to queue (see Troubleshooting section)
Configuration Steps
Section titled âConfiguration StepsâThis minimal example demonstrates bandwidth limiting for a single client, showcasing the core Simple Queue functionality.
Step 1: Create Basic Bandwidth Limit
Section titled âStep 1: Create Basic Bandwidth LimitâLimit a test client to 10 Mbps download and 5 Mbps upload:
/queue simple add target=192.168.88.100/32 max-limit=5M/10M name=test-client-limitStep 2: Add Guaranteed Bandwidth
Section titled âStep 2: Add Guaranteed BandwidthâEnsure the client gets at least 2 Mbps even during network congestion:
/queue simple set test-client-limit limit-at=2M/2MVerification
Section titled âVerificationâConfirm the queue is created and processing traffic:
Check Queue Configuration
Section titled âCheck Queue Configurationâ/queue simple print detail where name=test-client-limitExpected Output:
Flags: X - disabled, I - invalid, D - dynamic 0 name="test-client-limit" target=192.168.88.100/32 parent=none packet-marks="" priority=8 queue=default-small/default-small limit-at=2M/2M max-limit=5M/10M burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small total-priority=8 total-limit-at=0/0 total-max-limit=0/0 total-burst-limit=0/0 total-burst-threshold=0/0 total-burst-time=0s/0sMonitor Queue Statistics
Section titled âMonitor Queue Statisticsâ/queue simple print stats where name=test-client-limitExpected Output (when traffic is flowing):
0 name="test-client-limit" bytes=1,234,567/9,876,543 packets=1,234/9,876 dropped=0/0 rate=1.2Mbps/8.5Mbps packet-rate=15pps/125pps queued-bytes=0/0 queued-packets=0/0 invalid=noAdvanced Concepts
Section titled âAdvanced ConceptsâTarget Specification and Traffic Direction
Section titled âTarget Specification and Traffic DirectionâSimple Queues determine traffic direction based on the target specification:
# Target matches source address = UPLOAD traffic# Target matches destination address = DOWNLOAD traffic
/queue simple add target=192.168.1.100/32 max-limit=5M/10M# 192.168.1.100 â Internet = 5M upload limit# Internet â 192.168.1.100 = 10M download limitInterface-Based Targeting
Section titled âInterface-Based TargetingâTarget traffic based on the interface rather than IP addresses:
# Limit all traffic on ether2 interface/queue simple add target="" interface=ether2 max-limit=50M/50M name=ether2-limitSubnet-Based Limiting
Section titled âSubnet-Based LimitingâApply bandwidth limits to entire network segments:
# Limit entire guest network/queue simple add target=192.168.100.0/24 max-limit=20M/20M name=guest-network-limitTime-Based Queues
Section titled âTime-Based QueuesâActivate bandwidth limits only during specific time periods:
# Limit gaming traffic during business hours/queue simple add target=192.168.1.0/24 max-limit=10M/10M time=8h-17h,mon,tue,wed,thu,fri name=business-hours-limitPacket Mark Integration
Section titled âPacket Mark IntegrationâUse firewall mangle marks for more sophisticated traffic classification:
# First, mark P2P traffic in firewall mangle/ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark=p2p-traffic p2p=all-p2p
# Then create queue for marked traffic/queue simple add packet-marks=p2p-traffic max-limit=1M/1M name=p2p-throttlePriority and Parent-Child Relationships
Section titled âPriority and Parent-Child RelationshipsâCreate hierarchical bandwidth allocation:
# Parent queue for entire department/queue simple add target=10.1.0.0/24 max-limit=100M/100M name=dept-total
# Child queues for specific services/queue simple add target=10.1.0.10/32 parent=dept-total max-limit=50M/50M name=dept-server priority=1/queue simple add target=10.1.0.0/24 parent=dept-total max-limit=30M/30M name=dept-users priority=5Priority Rules:
- Lower numbers = higher priority (1 = highest, 8 = lowest)
- Higher priority queues get bandwidth first
- Priority only matters between child queues of the same parent
Per-Connection Queuing (PCQ)
Section titled âPer-Connection Queuing (PCQ)âDistribute bandwidth equally among multiple connections:
# Create PCQ queue types/queue type add name=pcq-download kind=pcq pcq-rate=2M pcq-classifier=dst-address/queue type add name=pcq-upload kind=pcq pcq-rate=1M pcq-classifier=src-address
# Apply to subnet/queue simple add target=192.168.1.0/24 queue=pcq-upload/pcq-download name=fair-sharingThis ensures each IP address gets up to 1M upload and 2M download, regardless of how many connections they have.
Common Use Cases
Section titled âCommon Use Casesâ1. ISP Customer Bandwidth Plans
Section titled â1. ISP Customer Bandwidth Plansâ# Residential 50/10 plan/queue simple add target=192.168.100.0/24 max-limit=10M/50M name=residential-plan
# Business 100/100 plan with guaranteed 20M/queue simple add target=10.10.0.0/24 limit-at=20M/20M max-limit=100M/100M name=business-plan2. Guest Network Limitation
Section titled â2. Guest Network Limitationâ# Limit guest WiFi to prevent abuse/queue simple add target=192.168.200.0/24 max-limit=5M/20M name=guest-wifi-limit3. Critical Service Prioritization
Section titled â3. Critical Service Prioritizationâ# Guarantee bandwidth for VoIP server/queue simple add target=192.168.1.50/32 limit-at=2M/2M max-limit=10M/10M priority=1 name=voip-server
# Limit bulk file transfers/queue simple add packet-marks=bulk-transfer max-limit=5M/5M priority=8 name=bulk-limit4. Fair Bandwidth Distribution
Section titled â4. Fair Bandwidth Distributionâ# Equal sharing among users with burst capability/queue type add name=fair-pcq-down kind=pcq pcq-rate=10M pcq-classifier=dst-address pcq-burst-rate=50M pcq-burst-threshold=5M pcq-burst-time=10s/queue type add name=fair-pcq-up kind=pcq pcq-rate=5M pcq-classifier=src-address
/queue simple add target=192.168.1.0/24 queue=fair-pcq-up/fair-pcq-down name=fair-usersTroubleshooting
Section titled âTroubleshootingâProblem: Queue Shows No Traffic Despite Active Connections
Section titled âProblem: Queue Shows No Traffic Despite Active ConnectionsâSymptoms:
- Queue statistics show 0 bytes/packets
- Network traffic is flowing normally
- Queue appears correctly configured
Root Cause: FastTrack is bypassing the queue system.
Solution: Disable FastTrack for queued traffic:
# Check current FastTrack rules/ip firewall filter print where action=fasttrack-connection
# Add exception before FastTrack rule/ip firewall filter add chain=forward action=accept src-address=192.168.88.100 place-before=0/ip firewall filter add chain=forward action=accept dst-address=192.168.88.100 place-before=0
# Or disable FastTrack entirely (impacts performance)/ip firewall filter set [find action=fasttrack-connection] disabled=yesProblem: Download Limits Not Working
Section titled âProblem: Download Limits Not WorkingâSymptoms:
- Upload limits work correctly
- Download speeds exceed configured limits
- Queue shows upload traffic but minimal download traffic
Root Cause: Incorrect target specification or packet flow understanding.
Diagnosis:
# Check packet flow direction/tool torch interface=ether2 duration=10
# Verify target matches actual traffic/queue simple print statsSolution: Ensure target specification matches the actual traffic direction:
# For a client at 192.168.1.100:# Correct: target=192.168.1.100/32 (matches both src and dst)# Wrong: target=192.168.1.100/32 interface=ether1 (conflicting direction)Problem: Burst Not Working as Expected
Section titled âProblem: Burst Not Working as ExpectedâSymptoms:
- Traffic never exceeds max-limit
- Burst parameters seem ignored
- Average rate calculations unclear
Diagnosis:
# Monitor burst statistics/queue simple print stats-detail where name=your-queueCommon Issues:
- burst-threshold too low: Set it between limit-at and max-limit
- burst-time too short: Use 8-16 seconds for typical scenarios
- Continuous high usage: Burst only works when average is below threshold
Solution:
# Properly configured burst example/queue simple set your-queue burst-limit=50M/50M burst-threshold=8M/8M burst-time=8s/8sProblem: Multiple Queues Conflicting
Section titled âProblem: Multiple Queues ConflictingâSymptoms:
- Unexpected bandwidth allocation
- Some queues not getting expected traffic
- Inconsistent performance
Root Cause: Queue order matters - first match wins.
Solution: Reorder queues from most specific to least specific:
# Check current order/queue simple print
# Move specific queue before general one/queue simple move specific-client-queue destination=0Problem: Parent-Child Queue Issues
Section titled âProblem: Parent-Child Queue IssuesâSymptoms:
- Child queues exceed parent limits
- Bandwidth not properly distributed
- Priority not working
Diagnosis:
# Check parent-child relationships/queue simple print where parent!=noneBest Practices:
- Parent max-limit should be â„ sum of children max-limits
- Parent limit-at should be â„ sum of children limit-at
- Set priorities only on child queues
Problem: PCQ Not Distributing Fairly
Section titled âProblem: PCQ Not Distributing FairlyâSymptoms:
- Some users getting more bandwidth than others
- PCQ sub-streams not visible
- Uneven distribution
Diagnosis:
# Check PCQ sub-streams/queue simple print stats where name=your-pcq-queue# Look for pcq-queues countCommon Issues:
- Wrong classifier: Use dst-address for download, src-address for upload
- Insufficient total bandwidth: PCQ rate Ă expected users should not exceed total
- NAT interference: PCQ sees translated addresses, not original clients
Solution:
# Correct PCQ for post-NAT scenario/queue type add name=pcq-lan-down kind=pcq pcq-rate=10M pcq-classifier=dst-address pcq-dst-address-mask=24Performance Considerations
Section titled âPerformance ConsiderationsâHardware Acceleration
Section titled âHardware AccelerationâSimple Queues disable hardware acceleration, forcing all traffic through the CPU:
# Check if hardware offloading is active/interface ethernet print where name=ether2# Look for "auto-negotiation=yes" and "full-duplex=yes"
# Monitor CPU usage during high traffic/system resource printImpact:
- Reduced maximum throughput
- Increased CPU utilization
- Higher latency under load
Mitigation:
- Use powerful RouterBOARD models for high-bandwidth queuing
- Consider Queue Tree with hardware-capable queue types
- Implement queuing only where necessary
Memory Usage
Section titled âMemory UsageâQueue buffers consume RAM, especially with large queue sizes:
# Monitor memory usage/system resource print
# Check queue buffer usage/queue simple print stats-detailGuidelines:
- Default queue sizes are usually sufficient
- Increase queue size only for high-latency links
- Monitor memory usage on devices with limited RAM
Scalability Limits
Section titled âScalability LimitsâSimple Queues have practical limits:
- Processing overhead: Each packet checks every queue in order
- Rule count: Performance degrades with hundreds of queues
- Update frequency: Frequent queue modifications impact performance
Best Practices:
- Keep queue count reasonable (< 100 for most scenarios)
- Use PCQ for many similar users instead of individual queues
- Place most specific/active queues first in the list
Related Topics
Section titled âRelated TopicsâPrerequisites
Section titled âPrerequisitesâ- IP Address Configuration - understand client addressing
- NAT Masquerade - NAT runs before queuing
Advanced QoS
Section titled âAdvanced QoSâ- Queue Tree - hierarchical bandwidth management with packet marks
- Firewall Mangle - traffic classification for queue tree
Related Topics
Section titled âRelated Topicsâ- DHCP Server - identify clients for queuing
- Hotspot - per-user bandwidth with hotspot
- Torch - verify queue effectiveness