Networking

QoS di MikroTik: Bandwidth Management Lengkap

Tutorial QoS MikroTik — simple queue, queue tree, mangle, burst, HTB, dan PCQ untuk ISP dan enterprise

1. Pengenalan QoS di MikroTik

QoS (Quality of Service) adalah mekanisme untuk mengatur dan memprioritaskan traffic jaringan. Di MikroTik, QoS memungkinkan Anda mengontrol bandwidth per user, per aplikasi, atau per grup — memastikan layanan kritis mendapat prioritas dan bandwidth terbagi adil.

1.1 Mengapa QoS Penting?

1.2 Metode QoS di MikroTik

MetodeTipeKegunaanKompleksitas
Simple QueueHTBLimit per IP/userRendah
Queue TreeHTBHierarchical, globalMenengah
Mangle + QueueHTBPer aplikasi/protocolTinggi
PCQHTBEqual bandwidth per userMenengah

2. Simple Queue

Simple Queue adalah cara termudah untuk limit bandwidth. Anda cukup menentukan target (IP address) dan batas kecepatan download/upload.

2.1 Membuat Simple Queue

Terminal MikroTik — Simple Queue
# Limit bandwidth per IP
/queue simple add \
  name=user-001 \
  target=192.168.1.10/32 \
  max-limit=2M/5M \
  comment="User 001 - 2Mbps up, 5Mbps down"

# Limit bandwidth per subnet
/queue simple add \
  name=guest-network \
  target=192.168.10.0/24 \
  max-limit=10M/50M \
  comment="Guest WiFi - shared 10M/50M"

# Limit dengan burst
/queue simple add \
  name=user-burst \
  target=192.168.1.20/32 \
  max-limit=5M/10M \
  burst-limit=10M/20M \
  burst-threshold=3M/7M \
  burst-time=10s/10s

# Limit berdasarkan waktu (hanya berlaku jam tertentu)
/queue simple add \
  name=limited-hours \
  target=192.168.1.30/32 \
  max-limit=1M/2M \
  time=08:00-17:00,mon,tue,wed,thu,fri \
  comment="Limit only during business hours"

# Lihat semua simple queue
/queue simple print
/queue simple print stats

2.2 Simple Queue Properties

ParameterFormatKeterangan
max-limitupload/downloadBatas maksimum bandwidth
limit-atupload/downloadBandwidth minimum (guaranteed)
burst-limitupload/downloadBatas burst (bandwidth tambahan sementara)
burst-thresholdupload/downloadThreshold untuk mengaktifkan burst
burst-timeupload/downloadDurasi burst
priority1-8Prioritas queue (1 = tertinggi)
queuedefault/defaultJenis queue (HTB)
💡 Simple Queue vs Queue Tree

Simple Queue cocok untuk setup sederhana dengan puluhan user. Untuk ratusan hingga ribuan user (ISP), gunakan Queue Tree + PCQ yang jauh lebih efisien dan scalable.

3. Queue Tree

Queue Tree memungkinkan struktur hierarki (parent-child) untuk bandwidth management. Queue tree bekerja berdasarkan packet mark dari mangle, bukan IP address langsung.

3.1 Struktur Queue Tree

Terminal MikroTik — Queue Tree Setup
# Step 1: Mark packet dengan mangle
/ip firewall mangle add \
  chain=forward \
  src-address=192.168.1.0/24 \
  action=mark-packet \
  new-packet-mark=upload \
  passthrough=no

/ip firewall mangle add \
  chain=forward \
  dst-address=192.168.1.0/24 \
  action=mark-packet \
  new-packet-mark=download \
  passthrough=no

# Step 2: Buat parent queue (total bandwidth)
/queue tree add \
  name=TOTAL \
  parent=global \
  max-limit=100M

# Step 3: Buat child queue untuk download
/queue tree add \
  name=DOWNLOAD \
  parent=TOTAL \
  packet-mark=download \
  max-limit=80M \
  priority=1

# Step 4: Buat child queue untuk upload
/queue tree add \
  name=UPLOAD \
  parent=TOTAL \
  packet-mark=upload \
  max-limit=20M \
  priority=1

# Lihat queue tree
/queue tree print
/queue tree print stats

4. Mangle: Packet Marking

Mangle adalah fitur di firewall MikroTik yang digunakan untuk menandai (mark) paket berdasarkan kriteria tertentu. Mark ini kemudian digunakan oleh queue tree, routing, dan fitur lainnya.

4.1 Jenis Marking

Terminal MikroTik — Mangle Rules
# Mark connection (sekali per koneksi)
/ip firewall mangle add \
  chain=forward \
  protocol=tcp \
  dst-port=80,443 \
  action=mark-connection \
  new-connection-mark=http-conn \
  passthrough=yes

# Mark packet berdasarkan connection mark
/ip firewall mangle add \
  chain=forward \
  connection-mark=http-conn \
  action=mark-packet \
  new-packet-mark=http-pkt \
  passthrough=no

# Mark per IP address
/ip firewall mangle add \
  chain=forward \
  src-address=192.168.1.10 \
  action=mark-packet \
  new-packet-mark=user10-upload \
  passthrough=no

# Mark P2P traffic (BitTorrent, dll)
/ip firewall mangle add \
  chain=forward \
  p2p=all-p2p \
  action=mark-packet \
  new-packet-mark=p2p-traffic \
  passthrough=no

# Mark VoIP (SIP/RTP) untuk prioritas tinggi
/ip firewall mangle add \
  chain=forward \
  protocol=udp \
  dst-port=5060,10000-20000 \
  action=mark-packet \
  new-packet-mark=voip-pkt \
  passthrough=no

5. HTB — Hierarchical Token Bucket

HTB adalah algoritma queuing yang digunakan oleh MikroTik. HTB mendukung bandwidth guarantee (limit-at), maximum limit, dan prioritas.

5.1 Konsep HTB

ParameterFungsiAnalogi
limit-atBandwidth minimum yang dijamin"Pasti dapat ini"
max-limitBandwidth maksimum"Tidak lebih dari ini"
priorityPrioritas saat bandwidth penuh

5.2 Prioritas HTB (1-8)

Terminal MikroTik — HTB Priority
# Queue untuk VoIP (prioritas tertinggi)
/queue tree add \
  name=VOIP \
  parent=TOTAL \
  packet-mark=voip-pkt \
  max-limit=5M \
  limit-at=2M \
  priority=1

# Queue untuk web (prioritas tinggi)
/queue tree add \
  name=WEB \
  parent=TOTAL \
  packet-mark=http-pkt \
  max-limit=50M \
  limit-at=20M \
  priority=3

# Queue untuk P2P (prioritas rendah)
/queue tree add \
  name=P2P \
  parent=TOTAL \
  packet-mark=p2p-traffic \
  max-limit=10M \
  limit-at=1M \
  priority=7

# Queue default (prioritas normal)
/queue tree add \
  name=DEFAULT \
  parent=TOTAL \
  packet-mark=no-mark \
  max-limit=30M \
  priority=5

6. Burst: Bandwidth Tambahan Sementara

Burst memungkinkan user mendapatkan bandwidth lebih tinggi dari limit normal untuk durasi singkat. Ini bagus untuk meningkatkan user experience saat browsing awal.

6.1 Cara Kerja Burst

  1. Ketika traffic user di bawah burst-threshold, "kredit" burst terakumulasi
  2. Ketika user membutuhkan bandwidth tinggi, burst diaktifkan
  3. User mendapatkan burst-limit selama burst-time
  4. Setelah burst habis, kembali ke max-limit
Terminal MikroTik — Burst Configuration
# Contoh burst untuk user 5 Mbps
/queue simple add \
  name=user-burst \
  target=192.168.1.50/32 \
  max-limit=5M/5M \
  burst-limit=10M/10M \
  burst-threshold=3M/3M \
  burst-time=8s/8s

# Penjelasan:
# max-limit=5M/5M          : Normal 5 Mbps up/down
# burst-limit=10M/10M      : Burst hingga 10 Mbps
# burst-threshold=3M/3M    : Burst aktif saat traffic < 3 Mbps
# burst-time=8s/8s         : Burst bertahan 8 detik

# Burst bekerja sebagai berikut:
# Saat idle → kredit burst terakumulasi
# Saat download → burst sampai 10 Mbps selama 8 detik
# Setelah 8 detik → turun ke 5 Mbps (max-limit)
# Saat idle lagi → kredit terakumulasi lagi
⚠️ Burst Threshold

Burst-threshold harus lebih rendah dari max-limit. Jika burst-threshold >= max-limit, burst tidak akan pernah terpicu. Rekomendasi: set burst-threshold sekitar 60% dari max-limit.

7. PCQ — Per Connection Queue

PCQ (Per Connection Queue) adalah fitur yang membagi bandwidth secara merata ke semua user tanpa perlu membuat queue individual per IP. PCQ sangat efisien untuk ISP dengan ratusan pelanggan.

7.1 Cara Kerja PCQ

  1. PCQ membuat queue otomatis untuk setiap source/destination address
  2. Bandwidth parent dibagi rata ke semua queue aktif
  3. Saat user baru masuk, bandwidth otomatis di-rebalance
  4. Saat user keluar, bandwidth dialokasikan ke user lain

7.2 Konfigurasi PCQ

Terminal MikroTik — PCQ Setup
# Buat PCQ type untuk download (berdasarkan dst-address)
/queue type add \
  name=pcq-download \
  kind=pcq \
  pcq-rate=5M \
  pcq-limit=50 \
  pcq-classifier=dst-address \
  pcq-total-limit=2000

# Buat PCQ type untuk upload (berdasarkan src-address)
/queue type add \
  name=pcq-upload \
  kind=pcq \
  pcq-rate=2M \
  pcq-limit=50 \
  pcq-classifier=src-address \
  pcq-total-limit=2000

# Terapkan PCQ di simple queue
/queue simple add \
  name=ALL-USERS \
  target=192.168.1.0/24 \
  queue=pcq-upload/pcq-download \
  max-limit=100M/200M \
  comment="Shared bandwidth - 2M up, 5M down per user"

# Atau terapkan di queue tree (lebih efisien untuk banyak user)
# Step 1: Mark packet download
/ip firewall mangle add \
  chain=forward \
  dst-address=192.168.1.0/24 \
  action=mark-packet \
  new-packet-mark=lan-download \
  passthrough=no

# Step 2: Mark packet upload
/ip firewall mangle add \
  chain=forward \
  src-address=192.168.1.0/24 \
  action=mark-packet \
  new-packet-mark=lan-upload \
  passthrough=no

# Step 3: Queue tree dengan PCQ
/queue tree add \
  name=LAN-DOWNLOAD \
  parent=global \
  packet-mark=lan-download \
  queue=pcq-download \
  max-limit=200M

/queue tree add \
  name=LAN-UPLOAD \
  parent=global \
  packet-mark=lan-upload \
  queue=pcq-upload \
  max-limit=100M

7.3 PCQ Classifier Options

ClassifierKegunaanContoh
src-addressPer source IP (upload)Setiap IP dapat jatah upload sama
dst-addressPer destination IP (download)Setiap IP dapat jatah download sama
src-and-dst-addressPer kombinasi src+dstPer koneksi unik
src-portPer source portPer aplikasi

8. Setup QoS untuk ISP

Terminal MikroTik — ISP QoS Template
# ============================================
# QoS Template untuk ISP (PCQ-based)
# Total bandwidth: 100 Mbps download, 50 Mbps upload
# Per user: 5 Mbps download, 2 Mbps upload
# ============================================

# Step 1: Buat PCQ types
/queue type add name=pcq-down kind=pcq pcq-rate=5M \
  pcq-classifier=dst-address pcq-total-limit=2000
/queue type add name=pcq-up kind=pcq pcq-rate=2M \
  pcq-classifier=src-address pcq-total-limit=2000

# Step 2: Mangle
/ip firewall mangle add chain=forward \
  dst-address=10.0.0.0/8 \
  action=mark-packet new-packet-mark=down passthrough=no
/ip firewall mangle add chain=forward \
  src-address=10.0.0.0/8 \
  action=mark-packet new-packet-mark=up passthrough=no

# Step 3: Queue Tree
/queue tree add name=TOTAL-DOWN parent=global \
  max-limit=100M priority=1
/queue tree add name=TOTAL-UP parent=global \
  max-limit=50M priority=1

/queue tree add name=USER-DOWN parent=TOTAL-DOWN \
  packet-mark=down queue=pcq-down
/queue tree add name=USER-UP parent=TOTAL-UP \
  packet-mark=up queue=pcq-up

# Step 4: Prioritas VoIP
/ip firewall mangle add chain=forward \
  protocol=udp dst-port=5060,10000-20000 \
  action=mark-packet new-packet-mark=voip passthrough=no

/queue tree add name=VOIP parent=TOTAL-DOWN \
  packet-mark=voip max-limit=10M limit-at=5M priority=1

9. Monitoring Queue

Terminal MikroTik — Queue Monitoring
# Monitor simple queue
/queue simple print stats

# Monitor queue tree
/queue tree print stats

# Monitor realtime (seperti "top" untuk queue)
/queue simple monitor [find]

# Cek queue yang aktif
/queue simple print where bytes>0

# Reset counters
/queue simple reset-counters [find]

# Monitor packet marks
/ip firewall mangle print stats

# Torch untuk lihat traffic per IP
/tool torch interface=ether1 src-address=192.168.1.10

Quiz Pemahaman

🧠 Tes Pemahaman: QoS MikroTik

1. Apa perbedaan utama Simple Queue dan Queue Tree?

a) Simple Queue lebih cepat dari Queue Tree
b) Simple Queue berdasarkan IP langsung, Queue Tree berdasarkan packet mark
c) Queue Tree tidak mendukung burst
d) Tidak ada perbedaan

2. Apa fungsi PCQ?

a) Mengenkripsi traffic
b) Memblokir P2P
c) Membagi bandwidth secara merata ke semua user
d) Meningkatkan kecepatan internet

3. Dalam HTB, priority 1 berarti?

a) Prioritas tertinggi — pertama mendapat bandwidth
b) Prioritas terendah
c) Tidak ada prioritas
d) Bandwidth di-disable

4. Mengapa burst-threshold harus lebih rendah dari max-limit?

a) Agar burst lebih cepat
b) Agar queue lebih stabil
c) Agar CPU usage rendah
d) Agar burst bisa terpicu saat traffic di bawah threshold

5. Mengapa ISP sebaiknya menggunakan Queue Tree + PCQ daripada Simple Queue?

a) Simple Queue lebih mahal
b) PCQ lebih efisien dan scalable untuk ratusan user
c) Simple Queue tidak mendukung limit
d) Queue Tree tidak butuh mangle
← SebelumnyaOSPF Multi-Area Selanjutnya →MikroTik User Manager
🔍 Zoom
100%
🎨 Tema