You are on page 1of 3

Queue Types

This was a bit of a bastard to figure out. It took a lot of research and a bit
of experimentation to sort this out, so this will be a lengthy post.
This configuration can be used with multiple ISPs that have different
bandwidth capacities. See the ISP switch scripts, there's a line in them to
adjust the queue parent as required.
Note that these are configuration scripts, and are not intended for the script
editor. You can paste them in to the terminal window.
The first thing that you will need to do is to create the appropriate queue
types. The queue types are used by the queue tree.
If you're wondering why the 1mbit value shows 819KiB, it's because I'm
accounting for bits (8 bits to a byte).
To get the desired value, use MB * 0.8. 1024Kb * 0.8 = 819KiB
This should make the shaping a bit more accurate, but don't take my word for
it. I read it somewhere, and it stuck.
My max upload line speed is 1mbit. Although my slower account has a slower
upload speed, I don't particularly care about it, so I've only created the one
max upload queue that will be assigned to the parent of the Queue Tree.
Create additional max upload queues if you want, and adjust the switch ISP
scripts to adjust the queue types.
# REQUIRED
/queue type
# Max Upload Queue
add kind=pcq name=max_upload_1m pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=819KiB

Below are the standard queues that will be assigned to clients. You don't need
to use them all. Have as few or as many as you want, but you will need at
least one (either rate limited or not).
For the most part, from what I've noticed, is that even if you set a client's
upload speed to say 16k, it will happily burst up to the available bandwidth
that is not being used by other queues. If you want to strictly restrict a
client, you want the rated queues in the next segment.

/queue type
# Upload Queues
add kind=pcq name=upload_512k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=409KiB
add kind=pcq name=upload_256k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=204KiB
add kind=pcq name=upload_128k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=102KiB
add kind=pcq name=upload_64k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=51KiB
add kind=pcq name=upload_32k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=26KiB
add kind=pcq name=upload_16k pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=12KiB

The rate limited queues below will completely restrict a client to the
specific bandwidth. Note that the value entry is different to the value
specified in the non-rated queues above. I don't know why there is this
discrepancy.
I wasn't aware of it initially and shot myself in the foot when I accidentally
limited the bandwidth for a connection to 16b instead of 16kb. Oops.
(In winbox you simply enter the digits with no suffix, but for rated you have
to add a k suffix)
You don't have to add these queues at all if you don't think you'll need them.
/queue type
# Rate Limited Uploads
add kind=pcq name=upload_256k_rate pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-rate=204k
add kind=pcq name=upload_128k_rate pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-rate=102k
add kind=pcq name=upload_64k_rate pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-rate=51k pcq-src-address6-mask=64
add kind=pcq name=upload_32k_rate pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-rate=26k
add kind=pcq name=upload_16k_rate pcq-classifier=src-address \
pcq-dst-address6-mask=64 pcq-rate=12k pcq-src-address6-mask=64

Below are the max download queues. There is one for each ISP that has a
different max bandwidth. The switch scripts change the queue in the parent of
the queue tree as required. You need at least one.
# REQUIRED

/queue type
# Max Download Queues
add kind=pcq name=max_download_10m pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=8192KiB
add kind=pcq name=max_download_6m pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=4915KiB

Below are the standard client download queues. Use what you need. You should
have at least one normal or one rate limited queue.
/queue type
# Download Queues
add kind=pcq name=download_4m pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=3276KiB
add kind=pcq name=download_2m pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=1638KiB
add kind=pcq name=download_1m pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=819KiB
add kind=pcq name=download_512k pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=409KiB
add kind=pcq name=download_256k pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=204KiB
add kind=pcq name=download_128k pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-src-address6-mask=64 pcq-total-limit=102KiB

These are the rate limited download queues. Use what you need. The rate
limiting works VERY well.
/queue type
# Rate Limited Downloads
add kind=pcq name=download_4m_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=3276k pcq-src-address6-mask=64
add kind=pcq name=download_2m_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=1638k pcq-src-address6-mask=64
add kind=pcq name=download_1m_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=819k pcq-src-address6-mask=64
add kind=pcq name=download_512k_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=409k pcq-src-address6-mask=64
add kind=pcq name=download_256k_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=204k pcq-src-address6-mask=64
add kind=pcq name=download_128k_rate pcq-classifier=dst-address \
pcq-dst-address6-mask=64 pcq-rate=102k pcq-src-address6-mask=64

You might also like