Community discussions

 
georgebal
just joined
Topic Author
Posts: 5
Joined: Fri Aug 23, 2019 11:39 am

Trouble with setting priorities

Fri Aug 23, 2019 10:02 pm

Hi,
I recently got into gaming and figured out that when other members of my family use the internet, they cause lag.
Bandwidth is not a problem (the games I play do not need much), but I need to improve the ping times.

My Mikrotik router is connected in bridge mode with a Drytek vigor 130 modem.

I literally followed every single tutorial I found on the internet in order to create priorities in the MikroTik router but,
unfortunately, although they improved the bandwidth, none of the solutions was able to improve my ping times.

My guess is that there must be some simple solution to add priority to packets coming from a single IP address, or, alternatively
to packets going to the specific game ports. That is, let all game packets pass through immediately bypassing any queues.

Thank you in advance for your help/suggestions
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1776
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Trouble with setting priorities

Sat Aug 24, 2019 12:11 pm

Hey

Start with posting your current config (/export hide-sensitive), and indicate what you want to achieve: ip/port/bandwidth/...
 
pe1chl
Forum Guru
Forum Guru
Posts: 5730
Joined: Mon Jun 08, 2015 12:09 pm

Re: Trouble with setting priorities

Sat Aug 24, 2019 3:31 pm

My guess is that there must be some simple solution to add priority to packets coming from a single IP address
Your guess is wrong! There is NO way to do that. You can add priority to packets going to an IP address, but not to packets coming from an IP address.
That is because the packets are in the queue at the ISP, not in the modem or router, and you have absolutely no control over what happens there.

The only way you can sort of fix things is by using one of the bandwidth shaping examples you already found, and use it (2 instances) both for outgoing traffic to
your modem (or you PPPoE interface when you use that), and for outgoing traffic to your bridge to the internal network (= the same as incoming traffic from the modem).
Then you need to configure it in such a way that the traffic limit is set a bit lower than what your connection actually can deliver.
This way you create some headroom and you ensure that there is no long waiting queue at the ISP end full of packets for your family members downloading big
files, and your gaming traffic can proceed a bit sooner.
 
georgebal
just joined
Topic Author
Posts: 5
Joined: Fri Aug 23, 2019 11:39 am

Re: Trouble with setting priorities

Sat Aug 24, 2019 6:14 pm

Hey

Start with posting your current config (/export hide-sensitive), and indicate what you want to achieve: ip/port/bandwidth/...
Hi, thanks!!
bellow is my configuration.
The router is connected via a bridge to the modem on the first ethernet
port.

There are four subnets behind the router, one for each of the first four
ethernet ports.

ethernet 1 (192.168.1.2/24) is for the bridge with the modem (192.168.1.1).
ethernet 2 (192.168.2.1/24) is for the wifi access point
ethernet 3 (192.168.3.1/24) is for my father's desk (computer, printer,
etc)
ethernet 4 (192.168.4.1/24) is for the living room, etc, where my PC
(192.168.4.18) is located.


I would like to improve the ping times for my PC (192.168.4.18) and
improve latency when others are downloading or uploading.
I have tried adding queues of various types, adding mangling in the
firewall, but all i could manage was traffic shaping. Ping times were
not affected.

The connection to the internet is very slow in my area. It can be as be
as low as 10Mbps download /1Mbps upload.



# aug/24/2019 17:52:45 by RouterOS 6.40.4
# software id = YTK1-UF3S
#
# model = RouterBOARD 750G r3
# serial number = 6F38075321B8
/interface bridge
add name=bridge1
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=dhcp_pool2 ranges=192.168.2.101-192.168.2.239
add name=dhcp_pool3 ranges=192.168.3.101-192.168.3.239
add name=dhcp_pool4 ranges=192.168.4.101-192.168.4.239
add name=dhcp_pool5 ranges=192.168.5.101-192.168.5.239
/ip dhcp-server
add address-pool=dhcp_pool2 disabled=no interface=ether2 name=dhcp2
add address-pool=dhcp_pool3 disabled=no interface=ether3 name=dhcp3
add address-pool=dhcp_pool4 disabled=no interface=ether4 name=dhcp4
/queue type
add kind=pcq name=PCQ pcq-classifier=dst-address pcq-dst-address6-mask=64 \
pcq-rate=2M pcq-src-address6-mask=64
add kind=pcq name=Download pcq-classifier=dst-address pcq-dst-address6-mask=\
64 pcq-src-address6-mask=64
add kind=pcq name=Upload pcq-classifier=src-address pcq-dst-address6-mask=64 \
pcq-src-address6-mask=64
set 8 pcq-rate=256k
set 9 pcq-rate=1k pcq-total-limit=1000KiB
/interface bridge port
add bridge=bridge1 interface=ether1
/ip address
add address=192.168.2.1/24 interface=ether2 network=192.168.2.0
add address=192.168.3.1/24 interface=ether3 network=192.168.3.0
add address=192.168.4.1/24 interface=ether4 network=192.168.4.0
add address=192.168.5.1/24 interface=ether5 network=192.168.5.0
add address=192.168.1.2/24 interface=ether1 network=192.168.1.0
/ip dhcp-server lease
add address=192.168.3.10 always-broadcast=yes client-id=1:2c:53:4a:1:11:8b \
comment="echo eth" mac-address=2C:53:4A:01:11:8B server=dhcp3
add address=192.168.3.3 client-id=1:a0:21:b7:c1:b4:98 comment=readynas \
mac-address=A0:21:B7:C1:B4:98 server=dhcp3
add address=192.168.4.2 always-broadcast=yes client-id=1:6c:3b:6b:b8:2:13 \
comment="r7 port1" mac-address=6C:3B:6B:B8:02:13 server=dhcp4
add address=192.168.4.21 always-broadcast=yes comment="sony tv eth" \
mac-address=AC:9B:0A:E2:6B:89 server=dhcp4
add address=192.168.4.25 client-id=1:c:fe:45:a8:14:1 comment="ps4 eth" \
mac-address=0C:FE:45:A8:14:01 server=dhcp4
add address=192.168.4.23 client-id=1:0:6:dc:43:7f:39 comment="popcorn eth" \
mac-address=00:06:DC:43:7F:39 server=dhcp4
add address=192.168.2.42 always-broadcast=yes client-id=1:4c:32:75:57:81:f7 \
comment="haris ipad" mac-address=4C:32:75:57:81:F7 server=dhcp2
add address=192.168.2.41 always-broadcast=yes client-id=1:74:1b:b2:c0:35:62 \
comment="haris iphone" mac-address=74:1B:B2:C0:35:62 server=dhcp2
add address=192.168.4.18 always-broadcast=yes client-id=1:d4:3d:7e:95:71:aa \
comment="prinias eth" mac-address=D4:3D:7E:95:71:AA server=dhcp4
add address=192.168.2.44 always-broadcast=yes client-id=1:24:92:e:5c:4:72 \
comment="despo tablet" mac-address=24:92:0E:5C:04:72 server=dhcp2
add address=192.168.2.43 always-broadcast=yes client-id=1:88:32:9b:65:cf:1c \
comment="despo phone" mac-address=88:32:9B:65:CF:1C server=dhcp2
add address=192.168.2.13 address-lists="" always-broadcast=yes client-id=\
1:78:4f:43:a6:41:1a comment="haris mbp wifi" mac-address=\
78:4F:43:A6:41:1A server=dhcp2
add address=192.168.3.12 always-broadcast=yes client-id=1:0:e0:4c:36:12:21 \
comment="haris mbp eth" mac-address=00:E0:4C:36:12:21 server=dhcp3
add address=192.168.4.12 client-id=1:0:e0:4c:36:12:21 comment="haris mbp eth" \
mac-address=00:E0:4C:36:12:21 server=dhcp4
add address=192.168.5.2 client-id=1:64:d1:54:8c:c3:77 comment="r6 port 1" \
mac-address=64:D1:54:8C:C3:77
add address=192.168.3.248 client-id=1:0:62:6e:70:5a:f comment="armakcam8 eth" \
mac-address=00:62:6E:70:5A:0F server=dhcp3
add address=192.168.2.248 always-broadcast=yes client-id=1:e8:ab:fa:a2:72:ba \
comment="armakcam8 wifi" mac-address=E8:AB:FA:A2:72:BA server=dhcp2
add address=192.168.2.51 mac-address=F4:F5:D8:D8:23:10 server=dhcp2
add address=192.168.2.52 always-broadcast=yes mac-address=48:D6:D5:F0:7C:20 \
server=dhcp2
add address=192.168.2.53 always-broadcast=yes mac-address=48:D6:D5:95:54:1F \
server=dhcp2
add address=192.168.2.55 always-broadcast=yes mac-address=E4:F0:42:24:E6:B1 \
server=dhcp2
add address=192.168.2.4 client-id=1:b8:27:eb:9f:79:f3 comment="octopi wifi" \
mac-address=B8:27:EB:9F:79:F3 server=dhcp2
add address=192.168.4.3 client-id=1:0:d0:4b:86:30:68 comment=lacie \
mac-address=00:D0:4B:86:30:68 server=dhcp4
add address=192.168.2.45 always-broadcast=yes comment="redmi george" \
mac-address=7C:03:AB:DF:63:87 server=dhcp2
add address=192.168.2.10 always-broadcast=yes client-id=1:7c:dd:90:8c:63:f5 \
comment="echo wifi" mac-address=7C:DD:90:8C:63:F5 server=dhcp2
add address=192.168.2.49 always-broadcast=yes client-id=1:0:51:2f:5b:4d:9c \
comment=turbox mac-address=00:51:2F:5B:4D:9C server=dhcp2
add address=192.168.3.4 client-id=1:b8:27:eb:ca:2c:a6 comment=octopi \
mac-address=B8:27:EB:CA:2C:A6 server=dhcp3
add address=192.168.3.61 client-id=1:b8:27:eb:a0:ea:13 comment="asproneri pi" \
mac-address=B8:27:EB:A0:EA:13 server=dhcp3
add address=192.168.2.48 always-broadcast=yes client-id=1:fc:87:43:4c:3f:54 \
comment="despos huawei" mac-address=FC:87:43:4C:3F:54 server=dhcp2
add address=192.168.3.5 always-broadcast=yes client-id=1:c4:65:16:3e:fa:d5 \
comment="hp color printer" mac-address=C4:65:16:3E:FA:D5 server=dhcp3
/ip dhcp-server network
add address=192.168.2.0/24 gateway=192.168.2.1
add address=192.168.3.0/24 gateway=192.168.3.1
add address=192.168.4.0/24 gateway=192.168.4.1
add address=192.168.5.0/24 gateway=192.168.5.1
/ip dns
set allow-remote-requests=yes servers=192.168.1.1,8.8.4.4,8.8.8.8
/ip route
add distance=2 gateway=192.168.1.1 pref-src=192.168.1.2
add distance=1 dst-address=192.168.7.0/24 gateway=192.168.4.2
/system clock
set time-zone-name=Europe/Athens
/system routerboard mode-button
set enabled=no on-event=""
/system script
add name=qos owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\
Set interface here\r\
\n:local outboundInterface \"wan0\"\r\
\n\r\
\n#Set bandwidth of the interface (remember, this is for OUTGOING)\r\
\n:local interfaceBandwidth 4M\r\
\n\r\
\n#Set where in the chain the packets should be mangled\r\
\n:local mangleChain postrouting\r\
\n\r\
\n#Don't mess with these. They set the parameters for what is to follow\r\
\n:local queueName (\"QoS_\" . \$outboundInterface)\r\
\n:local qosClasses [:toarray \"Network Control,Internetwork Control,Criti\
cal,Flash Override,Flash,Immedate,Priority,Routine\"]\r\
\n\r\
\n/ip firewall mangle add action=set-priority chain=postrouting dst-port=1\
119,3724,6113 new-priority=3 passthrough=yes protocol=tcp\r\
\n/ip firewall mangle add action=set-priority chain=postrouting dst-port=6\
052,5062,5060,12000-32000,3478,3479 new-priority=3 passthrough=yes protoco\
l=udp\r\
\n/ip firewall mangle add action=set-priority chain=postrouting new-priori\
ty=from-dscp-high-3-bits passthrough=yes comment=\"Respect DSCP tagging\"\
\r\
\n/ip firewall mangle add action=set-priority chain=postrouting new-priori\
ty=2 packet-size=0-123 passthrough=yes protocol=tcp tcp-flags=ack comment=\
\"Prioritize ACKs\"\r\
\n/ip firewall mangle add action=set-priority chain=postrouting priority=0\
\_dscp=0 new-priority=8 passthrough=yes comment=\"Set Pri 0 on packets wi\
th no tag at all\"\r\
\n\r\
\n\r\
\n:for indexA from 0 to 7 do={\r\
\n /ip firewall mangle add action=mark-packet chain=\$mangleChain comme\
nt=(\"pri_\" . \$indexA+1) \\\r\
\n disabled=no priority=(\$indexA+1) new-packet-mark=(\"priority_\
\" . \$indexA+1) passthrough=no\r\
\n}\r\
\n\r\
\n/queue tree add max-limit=\$interfaceBandwidth name=\$queueName parent=\
\$outboundInterface priority=1\r\
\n:for indexA from=0 to=7 do={\r\
\n\t:local subClass ([:pick \$qosClasses \$indexA] )\r\
\n\t/queue tree add \\ \r\
\n\t\tname=(\$indexA+1 . \". \" . \$subClass . \" - \" . \$outboundInterfa\
ce ) \\\r\
\n\t\tparent=\$queueName \\\r\
\n\t\tpriority=(\$indexA+1) \\\r\
\n\t\tqueue=ethernet-default \\\r\
\n packet-mark=(\"priority_\" . \$indexA+1) \\\r\
\n comment=(\"Priority \" . \$indexA+1 . \" traff\
ic\")\r\
\n}"
/tool graphing interface
 
georgebal
just joined
Topic Author
Posts: 5
Joined: Fri Aug 23, 2019 11:39 am

Re: Trouble with setting priorities

Sat Aug 24, 2019 6:15 pm

My guess is that there must be some simple solution to add priority to packets coming from a single IP address
Hi, many thanks for the quick reply!

I hadn't thought of this. If I understand correctly, there is not much I
can do for the incoming traffic, except from limiting the bandwidth for
the other members of my family. i.e. add a queue containing all the
other IPs and limiting their download bandwidth to e.g. 80% of the
maximum bandwidth, right?

For the outgoing traffic, limiting the available bandwidth in a queue
mostly results to bandwidth shaping. Is there a way to also improve ping
times? I have found that adding a priority to a queue does not make any
significant difference with respect to ping times. I thought maybe
trying different queue types and queue lengths but I'm not very familiar
with this.
 
pe1chl
Forum Guru
Forum Guru
Posts: 5730
Joined: Mon Jun 08, 2015 12:09 pm

Re: Trouble with setting priorities

Sat Aug 24, 2019 7:47 pm

For outgoing, you as well need to shape the entire output to slightly less than what you get from your ISP and then you can assign priorities within that.
As you are not filling the queue in the modem but keep the limting queue in the router, outgoing packets can "jump the queue" and be sent first when you assign them a higher priority.
I have no experience with gaming but I use this for voice traffic. I use the DSCP value in each packet to determine the priority. I have no idea whether gaming software is setting a suitable DSCP value for the traffic that needs to be realtime. If not, you could arrange that using a mangle rule based on IP address, port numbers, etc.

To get a prioritized queue I use a mangle rule to set priority from high 3 bits of DSCP in the mangle postrouting chain, then I assign a packet mark depending on the priority.
Also I define a queue tree on the outgoing interface with the maximum rate (which is like 90-95% of the advertised rate of the connection) and below that there are 8 queues each with a match on those 8 packet marks and with a Limit At of about 1/5 of the total limit.
/ip firewall mangle
add action=set-priority chain=postrouting comment="From dscp high 3 bits" \
    new-priority=from-dscp-high-3-bits passthrough=yes
add action=mark-packet chain=postrouting comment="Priority 0" \
    new-packet-mark=prio0 passthrough=no priority=0
add action=mark-packet chain=postrouting comment="Priority 1" \
    new-packet-mark=prio1 passthrough=no priority=1
add action=mark-packet chain=postrouting comment="Priority 2" \
    new-packet-mark=prio2 passthrough=no priority=2
add action=mark-packet chain=postrouting comment="Priority 3" \
    new-packet-mark=prio3 passthrough=no priority=3
add action=mark-packet chain=postrouting comment="Priority 4" \
    new-packet-mark=prio4 passthrough=no priority=4
add action=mark-packet chain=postrouting comment="Priority 5" \
    new-packet-mark=prio5 passthrough=no priority=5
add action=mark-packet chain=postrouting comment="Priority 6" \
    new-packet-mark=prio6 passthrough=no priority=6
add action=mark-packet chain=postrouting comment="Priority 7" \
    new-packet-mark=prio7 passthrough=no priority=7

/queue tree
add limit-at=30M max-limit=30M name=xs4all parent=pppoe-xs4all-inet
add limit-at=8M max-limit=28M name=xs4all-p1 packet-mark=prio7 parent=xs4all \
    priority=1 queue=default
add limit-at=8M max-limit=28M name=xs4all-p2 packet-mark=prio6 parent=xs4all \
    priority=2 queue=default
add limit-at=8M max-limit=28M name=xs4all-p3 packet-mark=prio5 parent=xs4all \
    priority=3 queue=default
add limit-at=8M max-limit=28M name=xs4all-p4 packet-mark=prio4 parent=xs4all \
    priority=4 queue=default
add limit-at=8M max-limit=28M name=xs4all-p5 packet-mark=prio3 parent=xs4all \
    priority=5 queue=default
add limit-at=8M max-limit=28M name=xs4all-p6 packet-mark=prio0 parent=xs4all \
    priority=6 queue=pcq-upload-default
add limit-at=8M max-limit=28M name=xs4all-p7 packet-mark=prio2 parent=xs4all \
    priority=7 queue=default
add limit-at=8M max-limit=28M name=xs4all-p8 packet-mark=prio1 parent=xs4all \
    queue=default
   
This is a generic 8-level DSCP based priority queue, which may be more than you really require but it is the standard way to set things up.
You may find when looking at stats that certain levels are rarely used.
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1776
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Trouble with setting priorities

Mon Aug 26, 2019 10:37 pm

If you want to have good gaming experience, then indeed you'll need to limit total download from router to all networks together to less than what modem can do.
Similar for upload, limit all upload traffic to less what modem can upload. 90-95% is a safe starting point.

your wan is ether1, update config of script
:local outboundInterface \"wan0\"\
So the script in export does only 1 side of the story: upload.

Download still to be done.
 
georgebal
just joined
Topic Author
Posts: 5
Joined: Fri Aug 23, 2019 11:39 am

Re: Trouble with setting priorities

Sun Sep 01, 2019 8:55 am

Thank you very much, sorry for the slow response, I was away. I will try your suggestions and let you know.
 
georgebal
just joined
Topic Author
Posts: 5
Joined: Fri Aug 23, 2019 11:39 am

Re: Trouble with setting priorities

Mon Sep 02, 2019 9:23 am

Hi,
I tried your suggestions and... IT WORKS!!!!!
The trick was, as you suggested, to limit the bandwidth on the port that goes to the modem. This way, the queue gets formed on
the router rather than the modem and, hence, the priorities have meaning.
Thank you

Who is online

Users browsing this forum: No registered users and 17 guests