Bandwidth Management
MD. MAHBUB HASAN PAVEL
Amber IT Limited
[email protected]
What is Bandwidth?
Bandwidth describes the rate at which data can be transferred to your
computer from a Website or Internet service within a specific time.
Therefore the amount of Bandwidth you have (the Bandwidth 'strength')
determines the efficiency and speed of your Internet activity – that is,
when you open Webpages, Download Files and so on.
Example: A Pipe with water running through it – the wider the Pipe, the greater
the volume of water that can flow through it. The same applies to Bandwidth
strength and the flow of the volume of data.
Bandwidth is generally measured in ‘bits/second' or ‘bytes/second’.
Measurement Units: bps, kbps, mbps, gbps etc.
Download Link - training.amberit.com.bd/ispab
Is Your Bandwidth enough?
Yes and no, various answer!!!
Usually Bandwidth is depends on –
The Rate (bps)
The applications people using
The time
Load, etc.
Therefore, Managing Bandwidth …
Is a kind of art, no fixed rules here
Can be flexible or rigid
Need a clear definition of what is “enough”
Download Link - training.amberit.com.bd/ispab
Bandwidth Management
Bandwidth Management is the process of measuring and controlling
the communications (Traffic, Packets) on a Network Link, to avoid
filling the Link to Capacity or Overfilling the Link, which would result
in Network Congestion and Poor Performance of the Network.
Download Link - training.amberit.com.bd/ispab
Bandwidth Management – Policy
Consider your Network Environment
Create a Policy (Simple Queues, PCQ)
Apply the Policy
Quality of Service (QoS)
The Policy will work while Traffic traversed from one Interface to another (i.e. LAN to WAN).
Download Link - training.amberit.com.bd/ispab
Bandwidth Management Techniques
1. Simple Queues
2. PCQ (Per Connection Queue)
Download Link - training.amberit.com.bd/ispab
1 – Simple Queues
Simple Queues is he simplest way to Limit Data Rate for specific IP
Addresses or Subnets.
You can also use Simple Queues to build advanced QoS applications.
They have useful integrated features:
- Can shape Traffic/IP
- Applying queue rules on chosen time intervals
- Priorities
- Using multiple packet marks from /ip firewall mangle
- Shaping of bidirectional Traffic (upload + download)
Download Link - training.amberit.com.bd/ispab
1 – Simple Queues (Cont…)
MIR – Maximum Information Rate (max-limit)
CIR – Committed Information Rate (limit-at)
Queues consists of two (02) parts:
Matching: (source, destination)
Scheduling: how traffic will be scheduled for transmission from queue.
Download Link - training.amberit.com.bd/ispab
1 – Simple Queues – Parental Control
1.a – Parent Queues
1.b – Child Queues
Download Link - training.amberit.com.bd/ispab
1.a – Parent Queues
In a Parent Queues, we will assign Full Bandwidth which we subscribed
from ISP.
To create a Parent Queues the steps are:
Go to Queues Menu
Then Simple Queues
Add [+] a Simple Queue
In General Option:
Name=Name of Queue
Target Address=LAN Subnet (x.x.x.x/x)
Max Limit=Upload/Download
Then press OK
Download Link - training.amberit.com.bd/ispab
1.b – Child Queues
To build Child Queues, we will assign a certain amount of Bandwidth
for each & every individuals IPs in a Network under a Parent Queue.
To create a Child Queues the steps are:
Go to Queues Menu
Then Simple Queues
Add [+] a Simple Queue
In General Option:
Name=Name of Queue
Target Address=Individual IP (x.x.x.x)
Max Limit=Upload/Download
In Advanced Option:
Parent=Name of Parent
Then press OK
Download Link - training.amberit.com.bd/ispab
Quality of Service (QoS)
Quality of Service (QoS) refers to the capability of a Network to
provide better service to selected Network Traffic (Mail, DNS,
FTP or BDIX or Cache like Youtube/Facebook etc.) over various
Technologies.
Download Link - training.amberit.com.bd/ispab
Case Study – Quality of Service (QoS)
Suppose your Management decided to provide better Bandwidth
over Mail for faster Email Communication i.e. all the Users will get a
higher Bandwidth while Mail Corresponds.
The steps are:
1. Add a Simple Queue (like before)
2. Set the Queue Name
3. Target Address=LAN Subnet or 0.0.0.0/0 (any)
4. Dst.=IP of Mail Server
5. Assign the Max. Bandwidth
6. Placed before 0
Download Link - training.amberit.com.bd/ispab
2 – PCQ (Per Connection Queue)
Per Connection Queue (PCQ) is a queuing discipline that can be used
to dynamically equalize or shape Traffic for multiple Users, using little
administration.
It is possible to divide PCQ scenarios into three (03) major groups:
1. Equal Bandwidth for a number of Users
2. Certain Bandwidth equal distribution between Users
3. Unknown Bandwidth equal distribution between Users
Download Link - training.amberit.com.bd/ispab
PCQ Parameters
pcq-classifier (dst-address | dst-port | src-address | src-port; default) : selection
of sub-stream identifiers
pcq-rate (number) : maximal available data rate of each sub-steam
pcq-limit (number) : queue size of single sub-stream (in KiB)
pcq-total-limit (number) : maximum amount of queued data (in KiB)
Download Link - training.amberit.com.bd/ispab
PCQ Rate Examples
Download Link - training.amberit.com.bd/ispab
Bandwidth Shape using PCQ
Queue Types
- PCQ-Upload
- PCQ-Download
To Shape the Bandwidth in MikroTik using PCQ, we have to create
two (02) Policy from Queue Types to Control Upload and
Download Traffic. Then we will introduce that Policies into Simple
Queues. We can do the same things for Multiple LAN Subnet also.
Download Link - training.amberit.com.bd/ispab
Upload Control – “PCQ-Upload”
PCQ-Upload: it will control the Upload Traffic.
To add a PCQ-Upload Policy the steps are:
Go to Queues
Then Queue Types
Add [+] a New Queue Type
- Name=PCQ-Policy Name
- Kind=pcq
- Rate=Assigned Bandwidth/Per IP
- Classifier=Src. Address (for Upload)
Then OK
Download Link - training.amberit.com.bd/ispab
Download Control – “PCQ-Download”
PCQ-Download: it will control the Download Traffic.
To add a PCQ-Download Policy the steps are:
Go to Queues
Then Queue Types
Add [+] a New Queue Type
- Name=PCQ-Policy Name
- Kind=pcq
- Rate=Assigned Bandwidth/Per IP
- Classifier=Dst. Address (for Upload)
Then OK
Download Link - training.amberit.com.bd/ispab
Bandwidth Control – PCQ & Simple Queues
Though PCQ is chosen as Policy to Manage Bandwidth,
we have to introduce PCQ Policy into Simple Queues.
No need to assign MIR & CIR
In Advanced Option,
- set Queue Type=PCQ-Upload/PCQ-Download
Download Link - training.amberit.com.bd/ispab
QoS for BDIX – if you are not connected with BDIX
Accumulate the BDIX Prefixes
Create an Address List
Mark all the Packets whose destination is BDIX
Bandwidth Policy – PCQ
Introduce PCQ in Simple Queue with Packet Marks
Placed before 0
Download Link - training.amberit.com.bd/ispab
Address List for BDIX
To create Address Lists in MikroTik, the steps are:
Go to IP Menu
Then go to Firewall
Then Address Lists
Add [+] Address Lists
/ip firewall address-list
add address=27.147.128.0/17 list=BDIX
add address=43.224.108.0/22 list=BDIX
add address=43.224.112.0/22 list=BDIX
add address=43.224.116.0/22 list=BDIX
. . . . (and many more)
Download Link - training.amberit.com.bd/ispab
Packet Mark – “The Mangle”
Mangle is a kind of 'marker' that marks packets for future processing
with special marks.
prerouting – within the Router
postrouting – outside the Router
Download Link - training.amberit.com.bd/ispab
Packet Mark for BDIX
To isolate the Traffic for BDIX Prefix, we have to mark all the packets with destined IP matching to BDIX Prefix.
To do that:
Go to IP Menu
Then go to Firewall
Then Mangle and add [+] a Mangle Rule
Download Link - training.amberit.com.bd/ispab
QoS – Add a Queue with Packet Mark
Prepare a Bandwidth Policy – PCQ
Introduce Packet Mark & PCQ – Simple Queues
Placed before 0
Download Link - training.amberit.com.bd/ispab
What is Scripting?
Scripting – provides a way to automate some Router maintenance
tasks by means of executing user-defined Scripts bounded to some
event occurrence.
Download Link - training.amberit.com.bd/ispab
Getting Started with Scripting
Prerequisites:
Familiar with MikroTik Menu
Knowledge about MikroTik CLI
Download Link - training.amberit.com.bd/ispab
Writing a Script – MikroTik
“System Scripts” is the default Path to write
any Script in MikroTik.
Creating a Script:
Go System Menu
Then go to Scripts
Add [+] a Script with meaningful Name
Write your Script in Source Filed
To Run a Script:
Select a Script
Then click “Run Script”
Download Link - training.amberit.com.bd/ispab
Example: A Script to add multiple Queues in a
single Command
Create a Parent Queues first
Then execute the below Script from New Terminal:
:for i from=2 to=254 do={/queue simple add name=("PC-$i") target=("172.16.1.$i")
parent=Total-BW max-limit=1M/1M limit-at=512k/512k time=0s-
1d,sun,mon,tue,wed,thu,fri,sat}
Download Link - training.amberit.com.bd/ispab
Example – Day/Night Bandwidth Package
for Simple Queues & PCQ
This is an example of writing a Script.
Suppose you are Local Internet Service Provider (LSP) and you declared a promotional offer for your Customer
that your Customer will get Double Bandwidth in Night time and in Day time it will Rollback as previous.
For Simple Queues:
Day: /queue simple set Pavel limit-at=1M/1M max-limit=1M/1M
Night: /queue simple set Pavel limit-at=2M/2M max-limit=2M/2M
For PCQ:
queue type set [find name=PCQ-DOWN] pcq-rate=1M
Day
queue type set [find name=PCQ-UP] pcq-rate=1M
queue type set [find name=PCQ-DOWN] pcq-rate=2M
Night
queue type set [find name=PCQ-UP] pcq-rate=2M
Download Link - training.amberit.com.bd/ispab
Run a Script – Manually
Have you created any Script?
- YES
- NO
How to Run a Script?
To Run a Script the steps are:
Go to System Menu
Then Scripts
Select a Script the click Run Script
Download Link - training.amberit.com.bd/ispab
Scheduling
Scheduler – The scheduler can trigger script execution at a particular
time moment, after a specified time interval, or both.
Have you Configured SNTP?
- Yes
- No
- Don’t know about SNTP
Download Link - training.amberit.com.bd/ispab
Configuring SNTP
Simple Network Time Protocol (SNTP) is a Networking Protocol for
clock synchronization between Computer Systems. It is a simplified
version of Network Time Protocol (NTP) and generally used when full
implementation of NTP is not needed.
Benefits of Configuring SNTP:
You can keep the System Time updated.
You can analyze the System Log for any event occurred.
If the System Time is not been updated then any Script & Scheduler may not work perfectly.
Download Link - training.amberit.com.bd/ispab
SNTP is needed for a MikroTik – Why?
Frequently we experienced problem with System Time of MikroTik i.e. it can’t handle the
Time by itself. If we setup System Time manually then it will work until next Reboot. If
we have any Time Server then we can fixed this problem permanently by Configuring our
Router as a SNTP Client so that it can synchronize the Time with that Server.
Step 1: Step 2:
Go to System Menu Go to System Menu
Then SNTP Client Then Clock
Then set Enable the SNTP Client and set the Then Select the Time Zone as Asia/Dhaka
Primary & Secondary NTP Server
Download Link - training.amberit.com.bd/ispab
Scheduler Properties
interval (time; default: 0s) – interval between two script executions, if time
interval is set to zero, the script is only executed at its start time, otherwise
it is executed repeatedly at the time interval is specified.
name (name) – name of the task.
on-event (name) – name of the script to execute. It must be presented at
/system script
run-count (read-only: integer) – to monitor script usage, this counter is
incremented each time the script is executed.
start-date (date) – date of the first script execution.
start-time (time) – time of the first script execution.
startup – execute the script 3 seconds after the system startup.
Download Link - training.amberit.com.bd/ispab
Run a Script by Scheduler
To Run a Script by Scheduler, the steps are:
Go System Menu
Then go to Scheduler
Add [+] a Schedule
Download Link - training.amberit.com.bd/ispab
Thank You !!!
Md. Mahbub Hasan Pavel
Manager, Network & System Administration
Amber IT Limited
Mobile: +880 1713 396442
Email:
[email protected] Download Link - training.amberit.com.bd/ispab