MTCNA Class-05: Bandwidth Control & Traffic Shaping
Class-05: Bandwidth Control & Traffic Shaping
Objectives -
Introduction to Bandwidth Management
Simple Queues for Traffic Limiting
Managing User Bandwidth with Simple Queues
Traffic Shaping and Priority Queuing
Creating ISP packages (burst/day-night plans) & Bandwidth Monitoring
Concept Overview -
Bandwidth Management is the process of controlling network traffic to ensure fair distribution of available bandwidth, prevent congestion, and improve performance for critical services.
Traffic Shaping is a bandwidth management technique that delays and regulates packet flow to smooth network traffic, reduce bursts, and meet defined Quality of Service (QoS) policies.
How It Works (Theory)
Bandwidth management in MikroTik is based on traffic classification, marking, and queue scheduling.
Traffic Classification
Identify packets by IP, MAC, port, protocol, or Layer7 (application signatures).
Example: Recognizing VoIP packets by UDP ports 5060, or identifying YouTube traffic by Layer7 patterns.
Traffic Marking
Assign a label to traffic (e.g., "VOIP", "SOCIAL", "BROWSING") using Mangle Rules.
Marked packets can be handled differently later in the process.
Queuing and Scheduling
Packets enter queues where bandwidth limits and priorities are enforced.
MikroTik uses HTB (Hierarchical Token Bucket) for scheduling:
max-limit → Hard cap on bandwidth.
limit-at → Minimum guaranteed bandwidth.
priority → Order in which queues get available bandwidth.
Traffic Shaping
Uses controlled delays and prioritization to smooth bursts and prevent congestion.
Examples:
Rate Limiting → Restricts data rate to a set speed.
Burst Mode → Allows temporary higher speeds for short periods.
PCQ (Per Connection Queue) → Distributes bandwidth equally among multiple users.
Main Tools in MikroTik for Bandwidth Management :
Advantages -
Optimized Resource Use → Maximum efficiency of available bandwidth.
Improved User Experience → Reduced buffering and lag.
Control Over Applications → Block or slow down non-essential services.
Scalability → Works for small offices to large ISPs.
LAB: Creating ISP Packages (User Bandwidth Control)
Step 1: Simple Queue (Basic Plan)
/queue simple
add name="1Mbps User" target=192.168.1.10 max-limit=1M/1M
add name="2Mbps User" target=192.168.1.20 max-limit=2M/2M
Step 2: Burst Speed Plan
/queue simple
add name="Burst Plan" target=192.168.1.30 \
max-limit=2M/2M \
burst-limit=4M/4M \
burst-threshold=1M/1M \
burst-time=10s
Step 3: Day/Night Plan
Step A: Create Time-Based Queue
/queue simple
add name="Day Plan" target=192.168.1.40 max-limit=1M/1M time=8h-23h59m
add name="Night Plan" target=192.168.1.40 max-limit=3M/3M time=0h-7h59m
Step 4: PCQ-Per Connection Queue (ISP Level Bandwidth Sharing)
/queue type
add name=pcq-download kind=pcq pcq-rate=2M pcq-classifier=dst-address
add name=pcq-upload kind=pcq pcq-rate=2M pcq-classifier=src-address
/queue tree
add name="Download Control" parent=global queue=pcq-download
add name="Upload Control" parent=global queue=pcq-upload
Bandwidth Monitoring
Step 1: Torch (Real-time monitoring)
/tool torch interface=ether1
Step 2: Interface Traffic
/interface monitor-traffic ether1
Step 3: Queue Monitoring
/queue simple print stats
Step 4: Graphing (GUI or CLI)
/tool graphing interface add interface=ether1