Sample QoS with PCQ for RouterOS 6

I didn’t see many examples fro RouterOS 6 so I thought I could share mine.

We’ve been testing this configuration for a month and seems to do its job. It was tested on a RB2011 with WAN on eth1, and different LANs on the rest of the interfaces (eth2 - 192.168.2.0/24 …)

If you detect any mistake or want to suggest improvements feel free to do it :sunglasses:

# Sample configuration by Carlos Corcoles Toledo
# Only the "firewall mangle" and queue related sections are shown
# Numbers calculated for connection with 30Mbps download and 6Mbps upload with around 100 concurrent users
# The idea is to share the bandwidth equally amongst the users in case of saturation
# The limit-at values are calculated with 100 users in mind (total bandwidth divided by 100)
# For different download and upload speeds change the numbers accordingly


# Mark the connections. Internal traffic has no limit

/ip firewall mangle
add action=mark-connection chain=forward dst-address=192.168.0.0/16 \
    new-connection-mark=conmarkdownload src-address=!192.168.0.0/16
add action=mark-connection chain=forward dst-address=!192.168.0.0/16 \
    new-connection-mark=conmarkupload src-address=192.168.0.0/16

# If the connection was marked, then mark the packets

add action=jump chain=forward connection-mark=!no-mark jump-target=pktmark
add action=mark-packet chain=pktmark connection-mark=conmarkdownload \
    new-packet-mark=packmarkdownload
add action=mark-packet chain=pktmark connection-mark=conmarkupload \
    new-packet-mark=packmarkupload


# Slightly changed default pcq queue sizes

/queue type
add kind=pcq name=pcq-descargas pcq-classifier=dst-address pcq-limit=100 \
    pcq-total-limit=10000
add kind=pcq name=pcq-uploads pcq-classifier=src-address pcq-limit=100 \
    pcq-total-limit=10000


# We create new global upload and download limits

/queue tree
add max-limit=29M name=qosdownload parent=global queue=default
add max-limit=5500k name=qosupload parent=global queue=default

# Then we set the limits for each user

add limit-at=55k max-limit=5500k name=limitupload packet-mark=packmarkupload \
    parent=qosupload queue=pcq-uploads
add limit-at=290k max-limit=29M name=limitdownload packet-mark=packmarkdownload \
    parent=qosdownload queue=pcq-descargas

Nice script!!! Thanks!

Only one thing, why the 10000 in that line:
/queue type
add kind=pcq name=pcq-descargas pcq-classifier=dst-address pcq-limit=100 pcq-total-limit=10000
add kind=pcq name=pcq-uploads pcq-classifier=src-address pcq-limit=100 pcq-total-limit=10000

I did not understand that part, because it doesnt match any values like

http://www.tamax.com.ar/blog/wp-content/QoS_Megis.pdf
see page 29

I did not understand this calculation… from where they got the number “20” ??
pcq.PNG