Community discussions

MikroTik App
 
IntrusDave
Forum Guru
Forum Guru
Topic Author
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Simplified DSCP/QoS Setup Script

Sun Sep 18, 2016 9:09 pm

Here is a simplified (8 queue instead of 64 queue) script to setup basic DSCP and QoS.
Simply set your WAN interface name, and your WAN UPLOAD speed. It will generate the queue tree and mangle rules to get you started.
#Set interface here
:local outboundInterface "wan0"

#Set bandwidth of the interface (remember, this is for OUTGOING)
:local interfaceBandwidth 4M

#Set where in the chain the packets should be mangled
:local mangleChain postrouting

#Don't mess with these. They set the parameters for what is to follow
:local queueName ("QoS_" . $outboundInterface)
:local qosClasses [:toarray "Network Control,Internetwork Control,Critical,Flash Override,Flash,Immedate,Priority,Routine"]

/ip firewall mangle add action=set-priority \
	chain=postrouting new-priority=from-dscp-high-3-bits \
	passthrough=yes comment="Respect DSCP tagging"
/ip firewall mangle add action=set-priority \
	chain=postrouting new-priority=2 packet-size=0-123 \
	passthrough=yes protocol=tcp tcp-flags=ack comment="Prioritize ACKs"
/ip firewall mangle add action=set-priority \
	chain=postrouting priority=0 dscp=0 new-priority=8  \
	passthrough=yes comment="Set Pri 8 on packets with no tag at all"


:for indexA from 0 to 7 do={
    /ip firewall mangle add action=mark-packet chain=$mangleChain comment=("pri_" . $indexA+1) \
         disabled=no priority=($indexA+1) new-packet-mark=("priority_" . $indexA+1) passthrough=no
}

/queue tree add max-limit=$interfaceBandwidth name=$queueName parent=$outboundInterface priority=1
:for indexA from=0 to=7 do={
	:local subClass ([:pick $qosClasses $indexA] )
	/queue tree add \ 
		name=($indexA+1 . ". " . $subClass . " - " . $outboundInterface ) \
		parent=$queueName \
		priority=($indexA+1) \
		queue=ethernet-default \
		packet-mark=("priority_" . $indexA+1) \
		comment=("Priority " . $indexA+1 . " traffic")
}
 
User avatar
amt
Long time Member
Long time Member
Posts: 529
Joined: Fri Jan 16, 2015 2:05 pm

Re: Simplified DSCP/QoS Setup Script

Mon Jun 19, 2017 1:32 pm

what will happen after this ? what will be the benefits ?
 
IntrusDave
Forum Guru
Forum Guru
Topic Author
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Simplified DSCP/QoS Setup Script

Mon Jun 19, 2017 5:55 pm

Your router will honor the QOS tagging in the packets
 
User avatar
amt
Long time Member
Long time Member
Posts: 529
Joined: Fri Jan 16, 2015 2:05 pm

Re: Simplified DSCP/QoS Setup Script

Tue Jun 20, 2017 8:02 am

Hi Dave,
I would like to make videos faster for the customer then voip can i use QoS for this option ?
 
IntrusDave
Forum Guru
Forum Guru
Topic Author
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Simplified DSCP/QoS Setup Script

Tue Jun 20, 2017 9:18 am

Yes, you would need to mangle rules to mark the packets with the priority that you want them to have.
 
User avatar
amt
Long time Member
Long time Member
Posts: 529
Joined: Fri Jan 16, 2015 2:05 pm

Re: Simplified DSCP/QoS Setup Script

Tue Jun 20, 2017 9:36 am

Hi dave,
What about your rules ? how they worked ?

Thanks
 
IntrusDave
Forum Guru
Forum Guru
Topic Author
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Simplified DSCP/QoS Setup Script

Tue Jun 20, 2017 9:48 am

The mangle rules created by the script only mark the packets for DSCP. You will need to create new rules to set the DSCP for the video packets. Keep in mind that QoS only works for your outbound traffic. Unless you are using an MPLS for your WAN, you can not control your inbound QoS.
 
User avatar
amt
Long time Member
Long time Member
Posts: 529
Joined: Fri Jan 16, 2015 2:05 pm

Re: Simplified DSCP/QoS Setup Script

Tue Jun 20, 2017 10:06 am

thanks for your help...
 
neutronlaser
Member
Member
Posts: 445
Joined: Thu Jan 18, 2018 5:18 pm

Re: Simplified DSCP/QoS Setup Script

Fri Feb 01, 2019 4:46 pm

Script fails and says 'ambiguous value of parent, more than one possible value matches input'
 
neutronlaser
Member
Member
Posts: 445
Joined: Thu Jan 18, 2018 5:18 pm

Re: Simplified DSCP/QoS Setup Script

Sun Mar 10, 2019 1:03 am

What a crock, just put some QoS in quickset already.
 
User avatar
c400
just joined
Posts: 15
Joined: Tue Nov 07, 2017 11:19 pm

Re: Simplified DSCP/QoS Setup Script

Mon Apr 15, 2019 9:45 pm

Hello,
Will this work, if i add it next line after "Set Pri 8 on packets with no tag at all"?
/ip firewall mangle add action=set-priority chain=postrouting new-priority=5 passthrough=yes protocol=tcp port=22
thx for a great script!
 
IntrusDave
Forum Guru
Forum Guru
Topic Author
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Simplified DSCP/QoS Setup Script

Tue Apr 16, 2019 5:21 am

that should work just fine, but place it before the Priority 8 line.
 
User avatar
prozak
newbie
Posts: 45
Joined: Sat Jan 16, 2010 4:01 am

Re: Simplified DSCP/QoS Setup Script

Wed Jun 12, 2019 6:48 pm

Hello.
I have a Question,
Does this script really honor and prioritizes VoIP instead of bulk traffic like web downloads?
Isn't there any need to set limit-at to guarantee critical dscp tagging enough bandwidth?
I mean in case there's a link saturation by bulk traffic so to avoid any VoIP jitters?

Also another sort of irrelevant question
If your VoIP service is through a VPN, are the packets tagged? or are they masked through VPN with no tag?

Any comments will be appreciated
 
User avatar
c400
just joined
Posts: 15
Joined: Tue Nov 07, 2017 11:19 pm

Re: Simplified DSCP/QoS Setup Script

Sun Aug 18, 2019 9:37 am

Trying to prioritize traffic over LTE, found that outgoing speed can vary from 10mbits to 25mbits. Should i set
:local interfaceBandwidth
to minimum value? Or it will be harmful for maximum bandwidth?
thx!
 
crazycharley
just joined
Posts: 6
Joined: Mon Mar 08, 2021 9:19 pm

Re: Simplified DSCP/QoS Setup Script

Sat Jan 29, 2022 5:58 pm

Probably a real newbie question, but here goes.

I am now bored waiting for fibre or even FTTC to arrive in my area so bought a LHG 4G kit (RBLHGR&R11e-4G). It is working pretty well and providing around 30-40Mbps down and around 10Mbps up (I know that's not fast but compared to 10/1Mbps its a new world!).

It is set up as the main router, so providing DHCP server, firewall etc, with open ports set up for my NAS and CCTV. With working from home still going on we frequently have up to three Zoom/Teams calls going on and now that I can ditch my landline am looking at adding a SIP dual FXS adapter for VoIP, so I tried using this script and I am not sure that it is making any difference - but I notice that the queues use "ethernet-default" as the queue type in the script. If I use Winbox and look at the queue type for the lte1 interface it is set to "no queue". Should I change the queue type for the lte1 interface to something else and change the script to match?

Any help would be great, and thanks for a great script - I wouldn't have a clue how to have done this!
 
zx128k
Frequent Visitor
Frequent Visitor
Posts: 67
Joined: Wed Oct 16, 2013 12:24 pm

Re: Simplified DSCP/QoS Setup Script

Fri May 24, 2024 11:34 pm

The mangle rules created by the script only mark the packets for DSCP. You will need to create new rules to set the DSCP for the video packets. Keep in mind that QoS only works for your outbound traffic. Unless you are using an MPLS for your WAN, you can not control your inbound QoS.
What this means, I can't use DSCP based QOS to prioritize incoming traffic from WAN to LAN???

Who is online

Users browsing this forum: No registered users and 9 guests