Community discussions

MikroTik App
 
SomeYoungGuy
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Mon Oct 22, 2012 10:18 am

Basic traffic prioritization

Wed Jun 05, 2019 2:38 pm

Hi all,
Let's take voip for example - as the moment voice data and say YouTube data are fighting for priority in my router... I just want to say... ok, all traffic to and from this IP (known static) must be prioritized over any other traffic.

All I seem to come across is "queues", but they seem unrelated to what I want - Queues seem to "throttle" traffic... I would not want that, firstly, although I have say 20mb fiber... it floats around anything from 12mb to 20mb... so if i was to "cut up" my traffic into some kind of voice and normal data... what possible values would i use in each... also i don't want to cap my voice data at all... what if im on 5 calls, or 10 or 50... There is simply no two values it could put in either "channel" that would suite. Also if I do make a voice channel of say 5mb, and leave the remaining 15mb for browsing (in this completely unrealistic situation), now what if im not on any calls... now my 20mb fiber is capped at 15mb for no real reason.

How can I just say prioritize this over that?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Basic traffic prioritization

Wed Jun 05, 2019 2:51 pm

For a start, let's make clear that you cannot really determine the priority used at the ISP side. It is up to the ISP to do that for you. A decent ISP that also offers VoIP will have done that, if not then you will be facing challenges.
Limiting traffic is crucial. When you just pump out traffic at full rate, queues will form at places you cannot control, and all traffic will enqueue first-in first-out so your VoIP traffic will queue behind other data.
So you at least setup a queue system with 2 queues on the upload, with different priority, so VoIP is queued ahead of other traffic.
You need to limit the rate of the data traffic below the actual maximum, so the queues that are outside your control do not fill, and all queues are in the router.
There is no need to "reserve" capacity for voice, it is sufficient to set it to a higher priority, you can set limit-at and max-limit to the capacity of your line.
Then you have a data queue at lower priority which you can set at a quite low limit-at value and max-limit slightly below your line speed.
The data queue will use leftover capacity up to max-limit but when there is voice traffic it always goes first.

When your actual rate is not constant, also not to the VoIP provider (it is no problem when it varies towards remote internet servers), well you are out of luck.
You should understand that voice over IP has quality requirements for the connection, when you cannot meet them it is not going to work or not working satisfactorily.
 
SomeYoungGuy
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Mon Oct 22, 2012 10:18 am

Re: Basic traffic prioritization

Wed Jun 05, 2019 3:10 pm

Lets assume my ISP is perfect - but at some times during the day, my router is at full capacity of the fiber line - lets say that's 20mb/s

Let's for the argument sake say I set up a "voip" queue, and an "all-other-traffic". (I have marked my voip traffic with a mangle rule, so that's sorted.). Now I make a 2mb voip queue, how do i set that up so that the "all-other-traffic" consumes the rest of the bandwidth, but doesnt eat into the 2mb voip channel?

Also, should i be using simple queues or queue tree?
 
R1CH
Forum Guru
Forum Guru
Posts: 1099
Joined: Sun Oct 01, 2006 11:44 pm

Re: Basic traffic prioritization

Wed Jun 05, 2019 3:50 pm

If your connection speed is truly fluctuating like this, then you need to set the queue limit at just under the slowest speed your connection drops to. Everything will be throttled to this rate all the time, which isn't ideal. This is the only way to make QoS work, as otherwise the queuing happens on your modem / ISP and you have no control over the priority there.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Basic traffic prioritization

Wed Jun 05, 2019 4:13 pm

Let's for the argument sake say I set up a "voip" queue, and an "all-other-traffic". (I have marked my voip traffic with a mangle rule, so that's sorted.). Now I make a 2mb voip queue, how do i set that up so that the "all-other-traffic" consumes the rest of the bandwidth, but doesnt eat into the 2mb voip channel?
By setting the priority of the VoIP queue higher than of the other one.
Note that higher priority means a lower value in the priority field in the queue member.
Also, should i be using simple queues or queue tree?
For this, use a queue tree with parent set to the interface you use for the internet link. When that is PPPoE over ethernet, use the PPPoE interface not the ethernet interface. When it is using a VLAN, use the VLAN interface.
simple queue is more targeted towards distributing the available bandwidth over several users inside your home.
However, this can be done with queue tree as well. Select pcq-upload-default as queue type for your low prio queue to do that. It does not make much sense to do this for the VoIP queue.
 
SomeYoungGuy
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 73
Joined: Mon Oct 22, 2012 10:18 am

Re: Basic traffic prioritization

Wed Jun 05, 2019 4:15 pm

Well, I was able to set something up just now - something that i realized is that, going to the speedtest site, and clicking the "GO" button cant really test your internet connection... it can only test what your browser session is able to download at right now... if your sister in the other room is downloading movies at the time you are doing a speed test, this shows as fluctuations in the speed... giving you this sense that your speed isn't quite what you purchased from your ISP...

Taking that into account, I have made 2 queues, priority 1(voip) and 8(other), and, and simply set the limits accordingly. I made a call, and clicked the "Go" button on the speed test - with a bit of fiddling, I have the "other" queue going bright red! - while my voip queue is all green, and the call quality was fine.

I wouldn't say this is ideal, but the call quality is fine now.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Basic traffic prioritization

Wed Jun 05, 2019 5:09 pm

Yes, this shows it works OK.
By setting the pcq-upload-default you can equalize the bandwidth between users.
But unfortunately, it is not possible to do that for download. You can trick it by setting a similar queue on your local network, also at a rate just lower than the download rate you should have, but it will not work well because it will be dropping packets after they already have been received.
What you really need is your ISP having a similar setup. E.g. based on DSCP value of the traffic (46 for VoIP traffic).
Incompetent ISPs will claim "not allowed to to that because of net neutrality laws" and it means they are unusable for really reliable VoIP.
 
tippenring
Member
Member
Posts: 304
Joined: Thu Oct 02, 2014 8:54 pm
Location: St Louis MO
Contact:

Re: Basic traffic prioritization

Wed Jun 05, 2019 5:29 pm

I figured I'd post my standard HTB config that I start with. Fasttrack effectively breaks queuing, so I exclude marked packets (this also applies to my mangle rules for IPSec, but that a different example).

In this case, I use mangle to mark typical DSCP VOIP traffic, but it can be anything.

eth6 is my internet interface, and vlan 28 is my internal interface. Since I can't control the ISP flow to my router, I set vlan 28's queues to traffic shape/limit traffic based on my max internet download (300Mbps). It isn't perfect, but if I limit flows to internal hosts at certain bandwidths, then the data flows from ISP to my router should roughly match what I've set on vlan 28's queues.

My queue configs may not be ideal (probably not) but they are effective for what I'm doing in this particular case. I think this could be a good starting place for someone looking at implementing typical queuing.
/ip firewall filter
 add action=fasttrack-connection chain=forward comment="Fast Track Rule - Ignore Connection Marked Packets" connection-mark=no-mark connection-state=established,related

/ip firewall mangle
 add action=mark-connection chain=forward comment="EF" connection-mark=no-mark connection-state=related,new dscp=46 new-connection-mark=cm.high passthrough=yes
 add action=mark-connection chain=forward comment="AF31" connection-mark=no-mark connection-state=related,new dscp=26 new-connection-mark=cm.high passthrough=yes
 add action=mark-connection chain=forward comment="CS3" connection-mark=no-mark connection-state=related,new dscp=24 new-connection-mark=cm.high passthrough=yes

 add action=mark-packet chain=forward connection-mark=cm.high new-packet-mark=pm.high passthrough=no
 add action=mark-packet chain=forward connection-mark=cm.med new-packet-mark=pm.med passthrough=no
 add action=mark-packet chain=forward connection-mark=cm.low new-packet-mark=pm.low passthrough=no

/queue tree
 add max-limit=300M name=q.vlan28.out parent=vlan28 queue=default
 add burst-limit=20M burst-time=1s max-limit=15M name=q.eth6.out parent=eth6-charter queue=default

 add name=q.vlan28.default packet-mark=no-mark parent=q.vlan28.out queue=default
 add limit-at=100M max-limit=200M name=q.vlan28.high packet-mark=pm.high parent=q.vlan28.out priority=1 queue=default
 add limit-at=50M max-limit=200M name=q.vlan28.med packet-mark=pm.med parent=q.vlan28.out priority=3 queue=default
 add limit-at=10M max-limit=50M name=q.vlan28.low packet-mark=pm.low parent=q.vlan28.out priority=5 queue=default

 add name=q.eth6.default packet-mark=no-mark parent=q.eth6.out queue=default
 add limit-at=10M max-limit=20M name=q.eth6.high packet-mark=pm.high parent=q.eth6.out priority=1 queue=default
 add limit-at=5M max-limit=20M name=q.eth6.med packet-mark=pm.med parent=q.eth6.out priority=3 queue=default
 add limit-at=1M max-limit=20M name=q.eth6.low packet-mark=pm.low parent=q.eth6.out priority=5 queue=default
 
pegasus123
Frequent Visitor
Frequent Visitor
Posts: 58
Joined: Tue Jul 24, 2018 7:02 am

Re: Basic traffic prioritization

Thu Jun 06, 2019 11:31 am

You do not need to set limit on each priority, you can just cap overall bandswidth to 85 to 90% ideally and just arrange them accordingly to your case. The limit-at will guarantee that priority to get that amount

e.g. 20mbps down /20mbps up

OVERALL - 18mbps capped

Priority 1 - VOIP - limit-at 5mb max-limit 18mbps
Priority 2 - SURFING - limit-at 5mb max-limit 18mbps
Priority 3 - YOUTUBE- limit-at 5mb max-limit 18mbps
etc.

if higher priority packets consumes bandwidth, then lower priority packets will get less, its just the way it is. But as you see, you do not need to hard cap.

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], davidhirka, jamesperks, mkx and 86 guests