{"id":1367,"date":"2015-04-25T14:19:29","date_gmt":"2015-04-25T06:19:29","guid":{"rendered":"https:\/\/ros.tw\/wp\/?p=1367"},"modified":"2015-04-25T14:19:29","modified_gmt":"2015-04-25T06:19:29","slug":"queues-pcq-examples","status":"publish","type":"post","link":"https:\/\/ros.tw\/wp\/?p=1367","title":{"rendered":"Queues &#8211; PCQ Examples"},"content":{"rendered":"<h1 id=\"firstHeading\" class=\"firstHeading\" lang=\"en\"><span dir=\"auto\">Manual:Queues &#8211; PCQ Examples<\/span><\/h1>\n<div id=\"bodyContent\" class=\"mw-body-content\">\n<div id=\"contentSub\"><\/div>\n<div id=\"jump-to-nav\" class=\"mw-jump\"><\/div>\n<div id=\"mw-content-text\" class=\"mw-content-ltr\" dir=\"ltr\" lang=\"en\">\n<p>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.<\/p>\n<h3><span id=\"Equal_Bandwidth_for_a_Number_of_Users\" class=\"mw-headline\">Equal Bandwidth for a Number of Users<\/span><\/h3>\n<p>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.<\/p>\n<p><a class=\"image\" href=\"http:\/\/wiki.mikrotik.com\/wiki\/File:PCQ.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/wiki.mikrotik.com\/images\/8\/81\/PCQ.png\" alt=\"PCQ.png\" width=\"551\" height=\"651\" \/><\/a><\/p>\n<p>There are two ways how to make this: using mangle and queue trees, or, using simple queues.<\/p>\n<p>1. Mark all packets with packet-marks upload\/download: (lets constider that ether1-LAN is public interface to the Internet and ether2-LAN is local interface where clients are connected<\/p>\n<pre>\/ip firewall mangle add chain=prerouting action=mark-packet \\\r\n   in-interface=ether1-LAN new-packet-mark=client_upload\r\n\/ip firewall mangle add chain=prerouting action=mark-packet \\\r\n   in-interface=ether2-WAN new-packet-mark=client_download\r\n<\/pre>\n<p>2. Setup two PCQ queue types &#8211; one for download and one for upload. <i>dst-address<\/i> is classifier for user&#8217;s download traffic, <i>src-address<\/i> for upload traffic:<\/p>\n<pre>\/queue type add name=\"PCQ_download\" kind=pcq pcq-rate=64000 pcq-classifier=dst-address\r\n\/queue type add name=\"PCQ_upload\" kind=pcq pcq-rate=32000 pcq-classifier=src-address\r\n<\/pre>\n<p>3. Finally, two queue rules are required, one for download and one for upload:<\/p>\n<pre>\/queue tree add parent=global-in queue=PCQ_download packet-mark=client_download\r\n\/queue tree add parent=global-out queue=PCQ_upload packet-mark=client_upload\r\n<\/pre>\n<p>If you don&#8217;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:<\/p>\n<pre>\/queue simple add target-addresses=192.168.0.0\/24 queue=PCQ_upload\/PCQ_download\r\n<\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Manual:Queues &#8211; PCQ Examples Per C &hellip; <a href=\"https:\/\/ros.tw\/wp\/?p=1367\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1367","post","type-post","status-publish","format-standard","hentry","category-ros"],"_links":{"self":[{"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1367"}],"version-history":[{"count":1,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1367\/revisions"}],"predecessor-version":[{"id":1368,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1367\/revisions\/1368"}],"wp:attachment":[{"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ros.tw\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}