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?
- Fair usage: Mencegah satu user menghabiskan semua bandwidth
- Prioritas: VoIP dan video conference lebih diprioritaskan dari download
- Billing: Menawarkan paket berbeda (1 Mbps, 5 Mbps, 10 Mbps)
- Stabilitas: Mencegah link overload yang menyebabkan packet loss
1.2 Metode QoS di MikroTik
| Metode | Tipe | Kegunaan | Kompleksitas |
|---|---|---|---|
| Simple Queue | HTB | Limit per IP/user | Rendah |
| Queue Tree | HTB | Hierarchical, global | Menengah |
| Mangle + Queue | HTB | Per aplikasi/protocol | Tinggi |
| PCQ | HTB | Equal bandwidth per user | Menengah |
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
# 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
| Parameter | Format | Keterangan |
|---|---|---|
max-limit | upload/download | Batas maksimum bandwidth |
limit-at | upload/download | Bandwidth minimum (guaranteed) |
burst-limit | upload/download | Batas burst (bandwidth tambahan sementara) |
burst-threshold | upload/download | Threshold untuk mengaktifkan burst |
burst-time | upload/download | Durasi burst |
priority | 1-8 | Prioritas queue (1 = tertinggi) |
queue | default/default | Jenis queue (HTB) |
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
# 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
# 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
| Parameter | Fungsi | Analogi |
|---|---|---|
limit-at | Bandwidth minimum yang dijamin | "Pasti dapat ini" |
max-limit | Bandwidth maksimum | "Tidak lebih dari ini" |
priority | Prioritas saat bandwidth penuh |
5.2 Prioritas HTB (1-8)
- Priority 1: Tertinggi — untuk VoIP, DNS, ICMP
- Priority 2-3: Tinggi — untuk web browsing, email
- Priority 4-5: Normal — untuk download reguler
- Priority 6-7: Rendah — untuk P2P, update
- Priority 8: Terendah — untuk bulk transfer
# 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
- Ketika traffic user di bawah burst-threshold, "kredit" burst terakumulasi
- Ketika user membutuhkan bandwidth tinggi, burst diaktifkan
- User mendapatkan burst-limit selama burst-time
- Setelah burst habis, kembali ke max-limit
# 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 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
- PCQ membuat queue otomatis untuk setiap source/destination address
- Bandwidth parent dibagi rata ke semua queue aktif
- Saat user baru masuk, bandwidth otomatis di-rebalance
- Saat user keluar, bandwidth dialokasikan ke user lain
7.2 Konfigurasi PCQ
# 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
| Classifier | Kegunaan | Contoh |
|---|---|---|
src-address | Per source IP (upload) | Setiap IP dapat jatah upload sama |
dst-address | Per destination IP (download) | Setiap IP dapat jatah download sama |
src-and-dst-address | Per kombinasi src+dst | Per koneksi unik |
src-port | Per source port | Per aplikasi |
8. Setup QoS untuk ISP
# ============================================ # 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
# 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?
2. Apa fungsi PCQ?
3. Dalam HTB, priority 1 berarti?
4. Mengapa burst-threshold harus lebih rendah dari max-limit?
5. Mengapa ISP sebaiknya menggunakan Queue Tree + PCQ daripada Simple Queue?