Manual:Queues - PCQ Examples: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
(31 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Same bandwidth for network users ==
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 major groups: equal bandwidth for a number of users, certain bandwidth equal distribution between users, unknown bandwidth equal distribution between users.


In cases when you need to limit users to a specific bandwidth, you may use PCQ queues. We will limit all users to 64kbps download and 32kbps upload:
=== Equal Bandwidth for a Number of Users ===


[[Image:Fir.JPG]]
Use PCQ type queue when you need to equalize the bandwidth [and set max limit] for a number of users. We will set the 64kbps download and 32kbps upload limits.


[[Image:PCQ.png]]


1. Mark all packets with packet-mark all:
There are two ways how to make this: using mangle and queue trees, or, using simple queues.


/ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark=all passthrough=no
1. Mark all packets with packet-marks upload/download: (lets constider that ether1-WAN is public interface to the Internet and ether2-LAN is local interface where clients are connected


/ip firewall mangle add chain=prerouting action=mark-packet \
    in-interface=ether2-LAN new-packet-mark=client_upload
/ip firewall mangle add chain=prerouting action=mark-packet \
    in-interface=ether1-WAN new-packet-mark=client_download


2. Setup two PCQ queue types - one for download and one for upload. dst-address is classifier for user's download traffic, src-address for upload traffic:
2. Setup two PCQ queue types - one for download and one for upload. ''dst-address'' is classifier for user's download traffic, ''src-address'' for upload traffic:


/queue type name="PCQ_download" kind=pcq pcq-rate=64000 pcq-classifier=dst-address
/queue type add name="PCQ_download" kind=pcq pcq-rate=64000 pcq-classifier=dst-address
/queue type name="PCQ_upload" kind=pcq pcq-rate=32000 pcq-classifier=src-address
/queue type add name="PCQ_upload" kind=pcq pcq-rate=32000 pcq-classifier=src-address




3. Finally, two queue rules required:
3. Finally, two queue rules are required, one for download and one for upload:


/queue tree add parent=global-in queue=PCQ-download packet-mark=all
/queue tree add parent=global queue=PCQ_download packet-mark=client_download
/queue tree add parent=global-out queue=PCQ-upload packet-mark=all
/queue tree add parent=global queue=PCQ_upload packet-mark=client_upload
 
If you don't like using mangle and queue trees, you can skip step 1, do step 2, and step 3 would be to create one simple queue as shown here:
 
/queue simple add target-addresses=192.168.0.0/24 queue=PCQ_upload/PCQ_download
 
 
{{Note | More information about certain and unknown Distribution between routers can be found in [[M:Queues_-_PCQ | PCQ]] manual.}}
 
== See Also ==
 
* [[Manual:Queues_-_PCQ |  PCQ]]
 
[[Category:Manual|QueuesPCQexapmles]]
[[Category:QoS|QueuesPCQexapmles]]
[[Category:Examples|QueuesPCQexapmles]]

Revision as of 11:05, 20 November 2019

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 major groups: equal bandwidth for a number of users, certain bandwidth equal distribution between users, unknown bandwidth equal distribution between users.

Equal Bandwidth for a Number of Users

Use PCQ type queue when you need to equalize the bandwidth [and set max limit] for a number of users. We will set the 64kbps download and 32kbps upload limits.

PCQ.png

There are two ways how to make this: using mangle and queue trees, or, using simple queues.

1. Mark all packets with packet-marks upload/download: (lets constider that ether1-WAN is public interface to the Internet and ether2-LAN is local interface where clients are connected

/ip firewall mangle add chain=prerouting action=mark-packet \
   in-interface=ether2-LAN new-packet-mark=client_upload
/ip firewall mangle add chain=prerouting action=mark-packet \
   in-interface=ether1-WAN new-packet-mark=client_download

2. Setup two PCQ queue types - one for download and one for upload. dst-address is classifier for user's download traffic, src-address for upload traffic:

/queue type add name="PCQ_download" kind=pcq pcq-rate=64000 pcq-classifier=dst-address
/queue type add name="PCQ_upload" kind=pcq pcq-rate=32000 pcq-classifier=src-address


3. Finally, two queue rules are required, one for download and one for upload:

/queue tree add parent=global queue=PCQ_download packet-mark=client_download
/queue tree add parent=global queue=PCQ_upload packet-mark=client_upload

If you don't like using mangle and queue trees, you can skip step 1, do step 2, and step 3 would be to create one simple queue as shown here:

/queue simple add target-addresses=192.168.0.0/24 queue=PCQ_upload/PCQ_download


Icon-note.png

Note: More information about certain and unknown Distribution between routers can be found in PCQ manual.


See Also