Class-3 Bandwidth Management

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 77

CLASS- 03

BANDWIDTH MANAGEMENT

M.T.M. Monty
Topics we cover

 What is Bandwidth
 Download and Upload speeds
 Relation between internet speed, download speed and browsing speed?
 Simple Queues
 HTB/CBQ
 PCQ Based Queues
 Bandwidth Control: Day-Night package
 Dedicate Bandwidth
 Shared Control
 Burst Limit
 LAB Work

Prepared by: M.T.M. Monty (montyrak@gmail.com)


What is Internet bandwidth?

Bandwidth is the data speed supported by a network connection. Bandwidth refers to how
much data per unit of time a network connection can handle. Bigger bandwidth allow greater
data to flow through them.

Bandwidth is typically measured in bits per second (bps). Commonly used larger units are
kilobits per second (Kbps), megabits per second (Mbps) and gigabits per second (Gbps).

Prepared by: M.T.M. Monty (montyrak@gmail.com)


What are download and upload speeds?

Two terms are generally used when talking about broadband speeds:

 The download speed is how fast you can pull data from the server to you. Most connections
are designed to download much faster than they upload, since the majority of online activity,
like loading web pages or streaming videos, consists of downloads. Download speed is
measured in megabits per second (Mbps).

 The upload speed is how fast you send data from you to others. Uploading is necessary for
sending big files via email, or in using video-chat to talk to someone else online (since you
have to send your video feed to them). Upload speed is measured in megabits per second
(Mbps).

Prepared by: M.T.M. Monty (montyrak@gmail.com)


What is relation between internet speed, download
speed and browsing speed?
When your Internet Service Provider (ISP) says 2Mbps speed, it means 2 Megabit per second.
As you might be aware 1 byte=8 bits.

When you download something, your browser or your download manager shows the speed
is MBps(Megabytes per seconds)

Notice the capital B and small b in the two speeds.

Hence even if your bandwidth is 2Mbps as promised by your ISP, you'll get download speeds of
2Mbps/8= 1/4 MBps which is 256 KBps. Similarly to get a download speed of 2MBps, you need to
have an internet connection of 16Mbps.

Moreover there are other factors which affect your download speed as well. The network congestion,
background services on your computer which are using the internet connection, etc.
Prepared by: M.T.M. Monty (montyrak@gmail.com)
QUEUE

Queues are used to limit and prioritize traffic:

 limit data rate for certain IP addresses, subnets, protocols, ports, and other parameters

 limit peer-to-peer traffic

 prioritize some packet flows over others

 configure traffic bursts for faster web browsing

 apply different limits based on time

 share available traffic among users equally, or depending on the load of the channel

 Queue implementation in MikroTik RouterOS is based on hierarchical token bucket (HTB).


HTB allows to create hierarchical queue structure and determine relations between queues

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Simple Queue

Bandwidth Management Service is the most popular Feature of MikroTik Router. It is said that
MikroTik Router is mostly used because of its Bandwidth Management service.

The module or service which is used to manage bandwidth in MikroTik Router is Queues.

There are various queue services in MikroTik router for managing user bandwidth. Among these,
simple queue service is mostly used for managing an office internet bandwidth.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


HTB/CBQ

The Hierarchical Token Bucket (HTB) is a faster replacement for the class based queueing
(CBQ) queueing discipline in Linux. It is useful to limit a client's download/upload rate so that the
limited client cannot saturate the total bandwidth. HTB (Hierarchical Token Bucket) is part of QoS
(Quality of Services), to make a hierarchical queue structure and determine relations between
queues (priority, burst possibility, etc)

Prepared by: M.T.M. Monty (montyrak@gmail.com)


HTB Structure

Prepared by: M.T.M. Monty (montyrak@gmail.com)


QUEUE PRIORITY

Priority:

Normally, MikroTik bandwidth is assigned sequentially if they are in same priority. That
means, the user who is top position of Queue list will get first priority to assign bandwidth
and then the second positioned user and then the next positioned user. Priority can be
selected 1 to 8. 1 is high priority and 8 is less priority. High priority user will get
bandwidth first and then less priority user.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


PCQ (Per Connection Queuing)
PCQ used to recognize the current direction and is used because it can Manage bandwidth in a
fair, equitable and massive. PCQ on MikroTik used in conjunction with Queue, either Simple
Queue and Queue Tree.

Lets Say, I have 7 PC which I will share a maximum bandwidth of 512k and a minimum
bandwidth of 73 kb each PC. If only one of my PC is online then he will be able to BW max
512kb, but if there are two PC online BW divided by 2, and so on up to 7 with the distribution
of bandwidth evenly.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Dedicated and Shared Control

 Dedicated Bandwidth:
In broad terms, dedicated Internet is exactly what it sounds like: Internet access and
bandwidth dedicated to one user and one user alone. Say, I have 10Mb Bandwidth, and I am
using it alone.

 Shared Control:

Sharing a minimum bandwidth to a maximum number of client called Shared control.

Lets say, I have 2Mb bandwidth and I have more than Twenty clients by assigning 512kb
bandwidth in each is a example of shared control.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Burst

Bursts are used to allow higher data rates for a short period of time.
Every 1/16 part of the burst-time, the router calculates the average
data rate of each class over the last burst-time seconds. If this
average data rate is less than burst-threshold, burst is enabled and
the actual data rate reaches burst-limit bps, otherwise the actual data
rate falls to max-limit or limit-at.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Burst

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Burst

Initially, the average data rate in the last 16 seconds is 0 Kbps. Since the
average data rate is smaller than the burst-threshold, Then the burst can be
done.

• After First second, the average data rate is


(0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+512) / 16 = 32kbps, still Smaller than
burst-threshold. Burst can be done.
• For the second second, the average data rate is
(0+0+0+0+0+0+0+0+0+0+0+0+0+0+512+512) / 16 = 64kbps.
• Similarly for the third second, the average data rate is
(0+0+0+0+0+0+0+0+0+0+0+0+0+512+512+512) / 16 = 96kbps.
• After 4 seconds, arrive at a time when the average data rate is more Big from
burst-threshold. Burst can no longer be done, and Data rate drops to max-limit
(256kbps).

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Burst
BURST CALCULATION FORMULA

Max-limit=256kbps, burst-time=16,
burst-threshold=128kbps, burst-limit=512kbps.

128 / 512 * 16 = 4 Second

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Burst
Burst limit is the maximum limit of bandwidth that can be consumed
in a short time determined by burst-time

Burst Time is the period of time, in seconds, over which the average
data rate is calculated.

Max limit is the maximum limit of bandwidth that can be consumed


by the computer subject to limitation

A burst threshold is a trigger or an inverting point or a limitation of


the real bandwidth received as a burst-limit constraint.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Prepared by: M.T.M. Monty (montyrak@gmail.com)
 Create a Simple Queue (Dedicated & Shared)
 Check Queue Traffic
 Queue Priority
 Parent-Child Queue
 Per Connection Queue (PCQ)
 Queue Tree Based
 Simple Queue Based
 NTP Configuration
 Bandwidth Control: Day Night Package
 Burst Limit

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue (Dedicated)

The Created Queue will show like this, with the assigning specific Bandwidth
for specific IP. You can Rearrange the Queue by dragging and drop.

Bandwidth assigned against a specific IP is known as Dedicated Bandwidth.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue

After Creating some Queues, If we don’t want to allow any other IP’s into the
Internet apart from above IP’s/Queues. In that case We will have to create a
queue by assigning minimum value for the rest of IP’s. It should be in full IP
block.

Make sure the queue should be in last of all queues.

Because, Simple Queue List works in Ascending Orders.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue

Or, If want to assign 2Mbps bandwidth for the rest of IP’s, apart from above
QUEUES. In that case We will create a queue by 2Mbps for the rest of IP’s. It
should be in full block.

Rest of IP’s Queue Must be in bottom of Queue list.

Importantly, it is needed to sort your queue list in ascending mode. You


can do it by clicking on Hash (#)

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue

If we disable Mr. Liton’s Queue, The user’s traffic will automatically shift to
the Rest of IP’s Queue.

It is needed to create a queue by mentioning whole IP block in the Target


Address. Bandwidth is up to your choice, how much you want to assign for the
rest of IP’s. And it should be in the bottom of queue list. Otherwise, those IP’s
are not in the queue list, they will get the full bandwidth. And even in the
queue list, they will get the full bandwidth when the queue will be disable.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue
Check Queue Traffic

To Check Queue Traffic

Tx (Download) = Transmit (packets transmitted out the interface)


Rx (Upload) = Receive (packets received on the interface)

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue (Shared)

Assigning multiple IP’s in a Queue with a specific amount of Bandwidth means


The allocated bandwidths are sharing among themselves. Which is known as
shared Bandwidth.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Creating a Simple Queue (Shared)

OR, You can also assign to Full IP Block with a specific Bandwidth. Which will
be shared among all the user’s within the IP block.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Queue Priority

As we have already discussed about the Queue Priority. From here we can able
To set the Priority. Lowest value is the highest priority. By default its value is
8. Value 1 is the highest Priority and value 8 is the lowest Priority.
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Parent-Child Queue

Create a Parent Queue by Assigning Some Child IP’s

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Parent-Child Queue
Creating Child Queue under parent Queue

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Parent-Child Queue
Creating Child Queue under parent Queue

Select the parent

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Parent-Child Queue
Creating Child Queue under parent Queue

The queue list is now looks like above. Mr. Nasir and
Mr. Ratan are now child queue where is their parent
queue is Accounts Dept.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Parent-Child Queue
Creating Child Queue under parent Queue

You can also create a Parent queue by assigning full


bandwidth, and keep the user’s queue as child under the
Parent Queue

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

This Queue will


capture download
traffic Packets

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

This Queue will


capture upload
traffic Packets

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method

Now the Queue will look like this.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method
Lets try with downloading a file.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Mangle and Queue Tree Method
Lets try with downloading a file.

Here One host is consuming the total Bandwidth. But when


user will be more, speed will be split equally with them all.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Simple Queue Method

Rate = 1M
I am setting here whatever
the bandwidth is, doesn’t
matter. From each
connection it will get highest
1Mbps Download speed
accordingly.

Create PCQ
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Per Connection Queue (PCQ)
Simple Queue Method

Rate = 1M
As download PCQ, The same
process is here. Set 1Mbps
upload speed for each
connection.

Create PCQ
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Per Connection Queue (PCQ)
Simple Queue Method

Create QUEUE
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Per Connection Queue (PCQ)
Simple Queue Method

Create QUEUE
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Per Connection Queue (PCQ)
Simple Queue Method

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Simple Queue Method
Lets Try with downloading a file

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Per Connection Queue (PCQ)
Simple Queue Method
Lets Try with downloading a file

The download speed is 1Mbps whereas the


QUEUE has assigned with unlimited bandwidth

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Difference between Queue Tree and Simple Queue

Queue Tree: By Using this method bandwidth management like this, no need to
Define speed on each clients because bandwidth will be shared equal for all.

Simple Queue: Simple Queue works serially in ascending order. It means first
queue will get the highest priority and the last queue will get the lowest priority.
But Queue tree process all the queues at the same time.

This is the main differences between them.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Network Time Protocol (NTP)

NTP stands for Network Time Protocol, and it is an Internet protocol used
to synchronize the time of a computer client or server to another server or
reference time source. NTP is an Internet standard protocol originally
developed by Professor David L. Mills at the University of Delaware of
USA.

Prepared by: M.T.M. Monty (montyrak@gmail.com)


WHY NTP?

o To get exact clock on Router.

o To save clock information without routers interval Memory

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Clock Setting

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Clock Setting

Prepared by: M.T.M. Monty (montyrak@gmail.com)


NTP Configuration

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Let us consider, we will control Mr. Rahim’s Bandwidth in Day-Night Basis.

From 08:00 am to 19:59 pm he will get 1Mbps (Day Bandwidth)


From 20:00 pm to 07:59 am he will get 2 Mbps (Night Bandwidth)

So, What we need to do?

Step-01: Create queue for Day (1Mb) and Night (2Mb)


Step-02: Create script for Day and Night.
Step-03: Create scheduler for Day (8.00 AM=19:59 PM) and Night (20:00 PM to 7:59 AM)

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create a QUEUE for Day

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create a QUEUE for Night

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Script for Day :


Name : Day
Source : /queue simple enable Rahim-DAY
/queue simple disable Rahim-NIGHT

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Script for Day :


Name : Day
Source : /queue simple enable Rahim-DAY
/queue simple disable Rahim-NIGHT
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Day Night Package

Night Queue will be disable automatically. It means script is okay

Let’s Check the created Script is correctly working or Not

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Script for Night:


Name : Night
Source : /queue simple enable Rahim-NIGHT
/queue simple disable Rahim-DAY
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Day Night Package

Day Queue will be automatically disable after running the Script. Means script is okay

Run Count will count the time


of running the script

Let’s Check the Script

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Schedule for Day:


Name: Day
Start Time:08:00:00
Interval :1d 00:00:00 or 24:00:00; after 1 Day
On event :Day

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Schedule for Day: Event name should be same as Script


Name: Day
Start Time:08:00:00
Interval :1d 00:00:00 or 24:00:00; after 1 Day
On event :Day

Prepared by: M.T.M. Monty (montyrak@gmail.com)


Day Night Package

Create Schedule for Night:


Name: Night
Start Time:20:00:00
Interval :1d 00:00:00 or 24:00:00; after 1 Day
On event :Night
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Day Night Package

Configuration is done. Now we can check by changing time. And the both
Queue will be on and off after a certain time which has been mentioned.
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Burst Limit

Burst Calculation:
Burst Limit/ Burst Threshold * Burst Time = Client Burst
5120/1024*100= 20 Second
Therefore, Client Burst Will Be 20 Seconds
Prepared by: M.T.M. Monty (montyrak@gmail.com)
Thank You Very Much!!

Prepared by: M.T.M. Monty (montyrak@gmail.com)

You might also like