Obsidean_VM/01-Documentation/Routers/Mikrotik - Network Redes/Bandwith control - Queues.md

80 lines
3.1 KiB
Markdown
Raw Normal View History

2025-02-18 05:37:27 -03:00
### It is better the Mangle - Queue Tree system:
1. Disable the fasttrack to allow the Mangle to function
![[Pasted image 20240302153458.png]]
2. Set two mark packet
![[Pasted image 20240302153602.png]]
![[Pasted image 20240302154348.png]]
![[Pasted image 20240302154400.png]]
```pascal
/ip firewall mangle
add action=mark-packet chain=prerouting comment=client-upload in-interface=\
bridge new-packet-mark=client-upload passthrough=yes
add action=mark-packet chain=prerouting comment=client-download in-interface=\
ether1 new-packet-mark=client-download passthrough=yes
/queue tree
add burst-limit=100M burst-time=10s max-limit=70M name="Trafico Download" \
packet-mark=client-download parent=global priority=1 queue=\
pcq-download-default
add burst-limit=20M burst-time=10s max-limit=15M name="Trafico Upload" \
packet-mark=client-upload parent=global priority=1 queue=pcq-upload-default
```
https://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ_Examples
# Manual:Queues - PCQ Examples
[Jump to navigation](https://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ_Examples#mw-head)[Jump to search](https://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ_Examples#searchInput)
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](https://wiki.mikrotik.com/images/8/81/PCQ.png)](https://wiki.mikrotik.com/wiki/File: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=192.168.0.0/24 queue=PCQ_upload/PCQ_download