Skip to main content

MikroTik QoS Priority and Anti-Lag Calculator

Prioritize WhatsApp calls, Zoom/Teams conferences, and gaming latency above bulk downloads using RouterOS v7 FQ-CoDel Queue Trees.

Input Parameters

Try Example:
Mbps
Mbps
%
%
%

Calculation Results

wanIface
ether1-ISP
lanCidr
192.168.88.0/24
downMbps
100
upMbps
40
headroomPct
95
totalDownMbps
95
totalUpMbps
38
prioDownMbps
28
prioUpMbps
13
regulerDownMbps
67
regulerUpMbps
25
RouterOS Script
# =====================================================================
# InfraCalc.id - MikroTik RouterOS v7 QoS Priority (Zoom, WA Call, DNS, ICMP)
# Total Bandwidth: Download 95M / Upload 38M (Headroom 95%)
# =====================================================================

/ip firewall mangle
# 1. Prioritas 1 (Tertinggi): ICMP Ping, DNS, & VoIP/Meeting (Zoom, WhatsApp Call, Google Meet, MS Teams)
add action=mark-connection chain=prerouting comment="QoS Prio 1 - ICMP & DNS" new-connection-mark=PRIO1_CONN passthrough=yes protocol=icmp
add action=mark-connection chain=prerouting dst-port=53,123 new-connection-mark=PRIO1_CONN passthrough=yes protocol=udp
add action=mark-connection chain=prerouting comment="QoS Prio 1 - Zoom, WA Call, Meet, Teams UDP" dst-port=3478-3481,8801-8810,19302-19309,50000-50060 new-connection-mark=PRIO1_CONN passthrough=yes protocol=udp
add action=mark-packet chain=forward connection-mark=PRIO1_CONN new-packet-mark=PRIO1_PKT passthrough=no

# 2. Prioritas 8 (Bulk/Reguler): Trafik Download Besar, Streaming, & Umum
add action=mark-connection chain=prerouting comment="QoS Prio 8 - Reguler & Bulk Traffic" connection-mark=no-mark new-connection-mark=REGULER_CONN passthrough=yes src-address=192.168.88.0/24
add action=mark-packet chain=forward connection-mark=REGULER_CONN new-packet-mark=REGULER_PKT passthrough=no

/queue type
add kind=fq-codel name=ST-QOS-FQCODEL fq-codel-target=5ms fq-codel-interval=100ms

/queue tree
add max-limit=95M name="1-TOTAL-DOWNLOAD" parent=global queue=ST-QOS-FQCODEL
add limit-at=28M max-limit=95M name="1A-PRIO-REALTIME-DOWN" packet-mark=PRIO1_PKT parent="1-TOTAL-DOWNLOAD" priority=1 queue=ST-QOS-FQCODEL
add limit-at=67M max-limit=95M name="1B-REGULER-BULK-DOWN" packet-mark=REGULER_PKT parent="1-TOTAL-DOWNLOAD" priority=8 queue=ST-QOS-FQCODEL

add max-limit=38M name="2-TOTAL-UPLOAD" parent=ether1-ISP queue=ST-QOS-FQCODEL
add limit-at=13M max-limit=38M name="2A-PRIO-REALTIME-UP" packet-mark=PRIO1_PKT parent="2-TOTAL-UPLOAD" priority=1 queue=ST-QOS-FQCODEL
add limit-at=25M max-limit=38M name="2B-REGULER-BULK-UP" packet-mark=REGULER_PKT parent="2-TOTAL-UPLOAD" priority=8 queue=ST-QOS-FQCODEL

How to Use This Tool

  1. Enter your router's WAN interface name (e.g. ether1-ISP) and local LAN subnet CIDR (e.g. 192.168.88.0/24).
  2. Enter your measured ISP Download and Upload line speeds in Mbps.
  3. Review the allocated Committed Information Rates for Priority 1 Real-Time and Priority 8 Bulk traffic, then copy the RouterOS v7 script into your terminal.

Worked Example: Standard Office 100/40 Mbps Link

Computed example: An ISP connection of 100/40 Mbps shaped at 95% headroom yields 95M down / 38M up. Priority 1 Real-Time receives a guaranteed floor of 28M down / 13M up, while Priority 8 Bulk receives 67M down / 25M up managed by FQ-CoDel.

Example Input
{
  "downMbps": 100,
  "upMbps": 40,
  "headroomPct": 95,
  "prioDownPct": 30,
  "prioUpPct": 35,
  "wanIface": "ether1-ISP",
  "lanCidr": "192.168.88.0/24"
}
Calculated Output
wanIface:
ether1-ISP
lanCidr:
192.168.88.0/24
downMbps:
100
upMbps:
40
headroomPct:
95
totalDownMbps:
95
totalUpMbps:
38
prioDownMbps:
28
prioUpMbps:
13
regulerDownMbps:
67
regulerUpMbps:
25

Core Concept & Engineering Notes

Quality of Service (QoS) and anti-lag traffic scheduling in MikroTik RouterOS prioritize latency-sensitive interactive traffic—such as WhatsApp voice calls, Zoom conferences, Google Meet, Microsoft Teams, DNS lookups, and online gaming ICMP packets—above high-volume, elastic bulk downloads and streaming video. Without active priority queuing, a single client initiating an unconstrained multi-thread download can congest the ISP modem buffer, triggering severe bufferbloat where network round-trip latency surges from 15 ms to over 300 ms, resulting in jitter and dropped audio. This calculator implements a structured RouterOS v7 Queue Tree architecture integrated with the modern FQ-CoDel (Fair Queuing Controlled Delay) active queue management algorithm. Unlike legacy First-In First-Out (FIFO) queues where large bulk packets clog the pipeline and delay smaller voice packets, FQ-CoDel dynamically separates individual conversation flows into sub-queues. It inspects buffer dwell time and drops or marks packets via Explicit Congestion Notification (ECN) as soon as packet transit time exceeds a 5-millisecond target. To maintain traffic sovereignty at the router and prevent queuing in the ISP ONT, total shaping capacity is throttled to 95% headroom of the measured line rate. Firewall mangle rules segregate packets into two primary tiers: Priority 1 (Real-Time interactive communications) backed by a dedicated Committed Information Rate (Limit-At) floor of 30% download and 35% upload, and Priority 8 (Regular/Bulk traffic). When real-time video meetings are inactive, the entire parent bandwidth dynamically remains available to regular users up to the Max-Limit ceiling with zero wasted capacity.

How It Was Calculated (Formulas & Steps)

Frequently Asked Questions (FAQ)

Why is FQ-CoDel in RouterOS v7 superior to SFQ or PCQ for eliminating lag?

FQ-CoDel combines fair queuing per flow with the CoDel algorithm, which actively drops or marks packets before buffer dwell time exceeds 5 ms. This keeps gaming ping and voice packets crisp and responsive even under heavy torrent downloads or 4K streams.

Why must the Queue Tree total bandwidth be set slightly below the ISP bandwidth (95% Headroom)?

If you configure 100% of your ISP bandwidth, surplus packets accumulate in the ISP modem or OLT buffer where you have no priority scheduling control. Setting a 5%–10% headroom forces the bottleneck to occur inside the MikroTik router where QoS rules can govern packet order.

Which UDP ports are automatically prioritized by this script?

The script prioritizes ICMP (Ping), UDP 53 (DNS), UDP 123 (NTP), and standard WebRTC/RTP/STUN media port ranges utilized by Zoom, WhatsApp Calling, Google Meet, and MS Teams (ports 3478-3481, 8801-8810, 19302-19309, and 50000-50060).

Does Queue Tree function if FastTrack remains active in the firewall filter?

No. FastTracked packets bypass connection tracking inspection and queue trees completely. You must disable the `action=fasttrack-connection` firewall filter rule for Queue Tree QoS to operate effectively.

References & Notes

Last updated: Content Status: Draft (Pending Editorial Review)

Note: Results above are mathematical estimates based on standard formulas. Always verify against official vendor documentation and site conditions before production deployment.