QoS

Hello-

I am trying to implement QoS on an RB2011UiAS-2HnD-IN and having some difficulty. I mark the packets based on their source address (ip address of the phone) as voip and mark all other traffic as be for best effort. I then implement a simple queue.

Here is the packet marking with source address 192.168.88.32/28 marked voip and all other traffic as be:

3 chain=forward action=mark-packet new-packet-mark=voip passthrough=no src-address=192.168.88.32/28 log=no log-prefix=“”
4 chain=forward action=mark-packet new-packet-mark=be passthrough=no log=no log-prefix=“”

Here’s the queue - It’s a simple queue to give the packets marked voip a 1 Mbps CIR and limit traffic marked be to a 10 Mbps CIR. Here is the queue config:

0 name=“voip” target=ether1-gateway parent=none packet-marks=voip priority=2/2 queue=default-small/default-small limit-at=1M/1M max-limit=1M/1M burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

1 name=“be” target=“” parent=none packet-marks=be priority=8/8 queue=default-small/default-small limit-at=10M/10M max-limit=10M/10M burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

Here’s what I see

  1. In firewall mangle, Byte and Packets, the number of packets being marked does not coincide with the amount of voice or best effort traffic being generated
  2. In the Queue, I don’t see any traffic being matched. My downstream is 125 Mbps and upstream is 25 Mbps - traffic from speedtest runds at 125/25 and not the expected 10/10

What am I doing wrong here? I’m pretty conversant with QoS on Cisco routers and switches, but this is all new to me here.

Thanks

Don’t forget that you need a rule to match traffic with the phone’s IP as the destination must also be marked as priority.
You should probably match based on connection and not packet-by-packet

Prerouting chain:
0: connection-mark=no-mark action=jump jump-target=classify
1: connection-mark=voip action=mark-packet new-packet-mark=voip passthrough=no
2: action=mark-packet new-packet-mark=be

Classify chain:
0: src-address=phone action=mark-connection new-connection-mark=voip
1: connection-mark=no-mark dst-address=phone action=mark-connection new-connection-mark=voip
2: connection-mark=no-mark action=mark-connection new-connection-mark=be
3: action=return

Thanks for the reply but, alas, I am only further confused. Reading your entry below, this is what it looks like to me:

Prerouting chain:
0: If a packet comes in without any mark, jump to classify (how would a packet be marked at this point - wouldn’t this catch all?)
1: If a packet come in with connection-mark=voip, re-mark it as voip (why does it have to be re-marked - does Mikrotik strip the mark?)
2: mark any other packet be

I added what you have and the entire mangle looks like this:

0 D ;;; special dummy rule to show fasttrack counters
chain=prerouting
1 D ;;; special dummy rule to show fasttrack counters
chain=forward
2 D ;;; special dummy rule to show fasttrack counters
chain=postrouting
3 chain=prerouting action=jump jump-target=classify connection-mark=no-mark log=no log-prefix=“”
4 chain=prerouting action=mark-packet new-packet-mark=voip passthrough=no connection-mark=voip log=no log-prefix=“”
5 chain=prerouting action=mark-packet new-packet-mark=be passthrough=yes log=no log-prefix=“”
6 chain=classify action=mark-connection new-connection-mark=voip passthrough=yes src-address=192.168.88.32/28 log=no log-prefix=“”
7 chain=classify action=mark-connection new-connection-mark=voip passthrough=yes dst-address=192.168.88.32/28 connection-mark=no-mark log=no log-prefix=“”
8 chain=classify action=mark-connection new-connection-mark=be passthrough=yes connection-mark=no-mark log=no log-prefix=“”
9 chain=classify action=return log=no log-prefix=“”

On a VoIP call of 1 minute, entry 4 marked 16 packets, entry 6 marked 1 packet, and entry 7 marked none. This seems like a very low number of packets as VoIP is generally 50 packets/second. What am I not understanding?

Anyway, haven’t even gotten to the queue yet - still trying to understand marking.

I now understand the marking process and what you were trying to show me.I have the voice packets marking correctly passed and source & destination addresses. The general traffic is also being marked correctly as be. Thank you for your help.

With regard to the queue, I have this in place (queue tree):

0 name=“voip” parent=ether1-gateway packet-mark=voip limit-at=1M queue=default priority=2 max-limit=1M burst-limit=0 burst-threshold=0 burst-time=0s
1 name=“be” parent=ether1-gateway packet-mark=be limit-at=20M queue=default priority=8 max-limit=10M burst-limit=0 burst-threshold=0 burst-time=0s

Our connection is 20 down and 10 up. Will the setting here work or should I shave some off the be limit to take into consideration that we won’t always get a true 20/10.
Thanks once again.

Queue tree can only limit traffic in one direction - that being OUTPUT on the interface it’s parented to. So your BE queue is shown to guarantee 20M upstream… (Limit-at = guaranteed minimum)
Try setting this to something like 5M

Thanks for your help. Can you give me a sanity check on the whole thing please?
Marking:
3 chain=prerouting action=jump jump-target=classify connection-mark=no-mark log=no log-prefix=“”
4 chain=prerouting action=mark-packet new-packet-mark=voip passthrough=no connection-mark=voip log=no log-prefix=“”
5 chain=prerouting action=mark-packet new-packet-mark=be passthrough=no log=no log-prefix=“”
6 chain=classify action=mark-connection new-connection-mark=voip passthrough=no src-address=192.168.88.32/28 log=no log-prefix=“”
7 chain=classify action=mark-connection new-connection-mark=be passthrough=no connection-mark=no-mark log=no log-prefix=“”
8 chain=classify action=return log=no log-prefix=“”

Queue:
0 name=“voip” parent=global packet-mark=voip limit-at=1M queue=default priority=2 max-limit=1M burst-limit=0 burst-threshold=0 burst-time=0s
1 name=“be” parent=global packet-mark=be limit-at=9M queue=default priority=5 max-limit=5M burst-limit=0 burst-threshold=0 burst-time=0s

Sure - two things.
First, on the mangle rules, I would suggest adding the criteria “connection-mark=be” to your rule which marks packets as “be” by default. (it’s just good practice to be explicit in this case because if you ever add more classes and are depending on the “no passthrough” above, then it’s easier to make a mistake)

Then there’s the queue tree.

Your BE queue is configured as such:
no burst
max-limit=5M
limit-at=9M
— this means “the most they can do when not bursting is 5M. Guarantee a minimum of 9M” - I wish limit-at had a different name because it’s quite misleading. Limit-at is a guaranteed minimum available bandwidth.

Also, your queues are built using a strategy that’s appropriate for simple queues, not for queue trees.

With queue trees, you need to make a single queue that is parented to a particular interface, say LAN for instance, which will govern the download QoS. If you place it on the WAN interface, then it will govern the upload traffic. A queue tree queue only governs traffic that is being sent out of whatever interface it’s tied to. (I’m not quite sure what the behavior is for a tree that is parented to global - perhaps someone else can chime in on that point).

You should basically have two trees containing three queues each. (a parent with two children)

So build your queues like this:
Call one queue “upstreamQOS” and one queue “downstreamQOS”
Set the upstreamQOS with parent=wan interface, max-limit=your available upstream speed, no limit-at / burst / etc.
Set the downstreamQOS with parent=lan interface, max-limit=your available downstream bandwidth, no limit-at / burst / etc.
These are the queues which track total consumption of your bandwidth in each direction. They need to know how much of each class of traffic is flowing so that combined, they may never total more than the actual bandwidth you have available.

Then you make 2 VoIP queues (one for upstream and one for downstream)
These you will configure just as you did your current VoIP queue - everything looks great on that queue

  • set these two VoIP queues the same way and parent one of them to the upstreamQOS queue, and parent the other to downstreamQOS.

Configure two BE queues as follows:
max-limit=100M (yes 100Meg)
limit-at=5M
priority=8

Finally, set one queue’s parent to the upstreamQOS queue, and the other to the downstreamQOS queue.

  • so the obvious question is “why 100M?” The answer is that you’re actually limiting the speed with the upstreamQOS/downstreamQOS parent queues, NOT with the sub-queues. The sub queues simply define the min-guarantee (limit-at) and the priority - which priority ONLY comes into play after two queues at the same level have both been granted their guaranteed minimum bandwidth. (so the BE queue will take priority over VoIP queue if VoIP is above its limit-at speed, but BE is below its limit-at speed, regardless of priority - but this is actually what you want)
    Basically, think of the parent queue as a shared bank account, and it’s the sub-queues that actually do the spending. As long as there is remaining bandwidth in the main queue, any sub-queue may spend it, but only up to the sub queue’s limits. If a sub queue has a higher limit than the parent queue, that doesn’t mean that it can spend MORE than the parent, because the parent just doesn’t have it to spend…

I’m interested too

P.S. and I would like to know why I cannot give you rep anymore.. :confused:

It seems that the queue isn’t working like I want as we still seem to get some packet loss on voice upstream. When that was happening, there was a moderate amount of upstream traffic and only 2 voice calls.

Here’s my setup:

Mark:
3 chain=prerouting action=mark-connection new-connection-mark=voip passthrough=yes src-address=192.168.7.32/28 connection-mark=no-mark log=no log-prefix=“”
4 chain=prerouting action=mark-connection new-connection-mark=be passthrough=yes connection-mark=no-mark log=no log-prefix=“”
5 chain=prerouting action=mark-packet new-packet-mark=voip passthrough=yes connection-mark=voip log=no log-prefix=“”
6 chain=prerouting action=mark-packet new-packet-mark=be passthrough=yes connection-mark=be log=no log-prefix=“”

Queue:
0 name=“downstreamQOS” parent=lan-ge-master packet-mark=“” limit-at=0 queue=default priority=1 max-limit=50M burst-limit=0 burst-threshold=0 burst-time=0s
1 name=“voipDOWN” parent=downstreamQOS packet-mark=voip limit-at=2M queue=default priority=2 max-limit=2M burst-limit=0 burst-threshold=0 burst-time=0s
2 name=“beDOWN” parent=downstreamQOS packet-mark=be limit-at=5M queue=default priority=8 max-limit=100M burst-limit=0 burst-threshold=0 burst-time=0s
3 name=“upstreamQOS” parent=wan packet-mark=“” limit-at=0 queue=default priority=1 max-limit=20M burst-limit=0 burst-threshold=0 burst-time=0s
4 name=“voipUP” parent=upstreamQOS packet-mark=voip limit-at=2M queue=default priority=2 max-limit=2M burst-limit=0 burst-threshold=0 burst-time=0s
5 name=“beUP” parent=upstreamQOS packet-mark=be limit-at=5M queue=default priority=8 max-limit=100M burst-limit=0 burst-threshold=0 burst-time=0s


The connection is 50 up/20 down. Should this setup give me what I need?

Depending on how the ISP is limiting the 20 upstream bandwidth (that’s how the queues are set currently, I assume that your statement of 50up / 20down was flip-flopped), you may actually have slightly less than 20… especially if they’re doing policing and if the interface is physically running at 1Gbps…

Try throttling the upstream down to 18M (90%) and see if this helps - if not, try something silly like 10M. Basically, when the line rate is significantly faster than a policed rate, the simple passing of packets can place the link “over budget” if the policer is using too small of a time interval because each 1500-byte frame is actually crossing the wire at 1Gbps, which doesn’t take long to push a very small-interval’s average rate above 20M…

Also, the policer is going to consider packet overhead, whereas the queue might be considering only IP payload…

Also - it’s possible that there is packet loss on the ISP’s transport - meaning that the available bandwidth in your area might be getting congested, and it’s not your own packets stepping on each other, but your neighbors’ packets stepping on yours.

See my post about Qos here.