Community discussions

MikroTik App
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Bandwidth reservation for gaming

Sun Jun 13, 2010 8:43 pm

Hi,

I would like to know how to automatically reserve some bandwidth for gaming purposes. Currently I can hard-limit (with use of queues and packet marking) all the non-gaming protocols/packets. I've done the basic MikroTik training and read through a couple of Queue/QoS documents. The best one I came across was MikroTik RouterOS Workshop - QoS Best Practice, but it didn't handle any bandwidth reservation :(

My setup is as follow:
For my WAN interface I have a bridged ADSL connection (384kbps down / 192kbps up) where I dial 2 PPPoE connections (both masqueraded) with my MikroTik RB750 (running ROS v3.30).

What I want is to accomplish is:
When no one is playing any games, they should have access to the full 384kbps/192kbps ADSL connection (which is realistically more like 340kbps down and 160kbps up).
As soon as someone is playing a game, then I typically want to leave only 1/3 of the bandwidth for other than gaming use.

I have tried Queue Trees, but had no success with it since my Global In parent did not register anything.

I would appreciate it someone could just send me in the right direction.

Thank you in advance.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Bandwidth reservation for gaming

Sun Jun 13, 2010 9:45 pm

'global-' should work. show us your config - we'll tell you where the error is

for reservation you should just create two leafs, the gaming one with higher priority
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Sun Jun 13, 2010 10:48 pm

Thank you for the quick response Chupaka.

I previously had all my Mangle rules just in the Forward chain, which was probably the cause why nothing showed in the Global-In QT. I've now changed my incoming Mangle rules to the Prerouting chain.
Now I'm stuck with configuring the Queue Tree.

When I set the max-limit of the Internet QT leaf, then its limiting the Internet (non gaming) packets to that limit even if no gaming packets are transmitted/received at the moment.

Here are the parts of my configuration file that I think might be useful/relevant:
/interface bridge
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes \
    comment="" disabled=no forward-delay=15s l2mtu=1520 max-message-age=20s \
    mtu=1500 name=bridge-LAN priority=0x8000 protocol-mode=none \
    transmit-hold-count=6
add admin-mac=00:00:00:00:00:00 ageing-time=5m arp=enabled auto-mac=yes \
    comment="" disabled=no forward-delay=15s l2mtu=1520 max-message-age=20s \
    mtu=1500 name=bridge-SCN priority=0x8000 protocol-mode=none \
    transmit-hold-count=6
/interface ethernet
set 0 arp=enabled auto-negotiation=yes comment="" disabled=no full-duplex=yes \
    l2mtu=1526 mac-address=00:0C:42:5A:F3:45 mtu=1500 name=ether1-Nanostation \
    speed=100Mbps
set 1 arp=enabled auto-negotiation=yes bandwidth=unlimited/unlimited comment=\
    "" disabled=no full-duplex=yes l2mtu=1524 mac-address=00:0C:42:5A:F3:46 \
    master-port=none mtu=1500 name=ether2-Neighbours speed=100Mbps
set 2 arp=enabled auto-negotiation=yes bandwidth=unlimited/unlimited comment=\
    "" disabled=no full-duplex=yes l2mtu=1524 mac-address=00:0C:42:5A:F3:47 \
    master-port=none mtu=1500 name=ether3-Switch speed=100Mbps
set 3 arp=enabled auto-negotiation=yes bandwidth=unlimited/unlimited comment=\
    "" disabled=no full-duplex=yes l2mtu=1524 mac-address=00:0C:42:5A:F3:48 \
    master-port=none mtu=1500 name=ether4-SDSL-Univ speed=100Mbps
set 4 arp=enabled auto-negotiation=yes bandwidth=unlimited/unlimited comment=\
    "" disabled=no full-duplex=yes l2mtu=1524 mac-address=00:0C:42:5A:F3:49 \
    master-port=none mtu=1500 name=ether5-ADSL-MWeb speed=100Mbps
/interface vlan
add arp=enabled comment="" disabled=no interface=ether3-Switch l2mtu=1520 \
    mtu=1500 name=vlan-L2-3 use-service-tag=no vlan-id=2
add arp=enabled comment="" disabled=no interface=ether3-Switch l2mtu=1520 \
    mtu=1500 name=vlan-L1 use-service-tag=no vlan-id=1
/ip pool
add name=default-dhcp ranges=192.168.90.10-192.168.90.254
add name=dhcp-switch ranges=192.168.91.10-192.168.91.254
/ip dhcp-server
add address-pool=default-dhcp authoritative=after-2sec-delay bootp-support=\
    static disabled=no interface=bridge-LAN lease-time=3d name=dhcp-LAN-WiFi
add address-pool=dhcp-switch authoritative=after-2sec-delay bootp-support=\
    static disabled=no interface=ether3-Switch lease-time=3d name=\
    dhcp-LAN-Switch
/interface pppoe-client
add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\
    "MWeb 384kbps Uncapped account" dial-on-demand=no disabled=no interface=\
    ether5-ADSL-MWeb max-mru=1480 max-mtu=1480 mrru=disabled name=\
    pppoe-Mweb-Uncapped password=(hidden) profile=default service-name="" \
    use-peer-dns=no user=(hidden)
add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\
    "WebAfrica Local Only account" dial-on-demand=yes disabled=no interface=\
    ether5-ADSL-MWeb max-mru=1480 max-mtu=1480 mrru=disabled name=\
    pppoe-WA-Local password=(hidden) profile=default service-name="" \
    use-peer-dns=no user=(hidden) 
add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 comment=\
    "OpenWeb (Internet Solutions) Local Only account" dial-on-demand=no \
    disabled=no interface=ether5-ADSL-MWeb max-mru=1480 max-mtu=1480 mrru=\
    disabled name=pppoe-OW-Local password=(hidden) profile=default \
    service-name="" use-peer-dns=no user=(hidden)
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=168k name=QT-Global-Out parent=global-out priority=8
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=336k name=QT-Global-In parent=global-in priority=8
/queue type
set default kind=pfifo name=default pfifo-limit=50
set ethernet-default kind=pfifo name=ethernet-default pfifo-limit=50
set wireless-default kind=sfq name=wireless-default sfq-allot=1514 \
    sfq-perturb=5
set synchronous-default kind=red name=synchronous-default red-avg-packet=1000 \
    red-burst=20 red-limit=60 red-max-threshold=50 red-min-threshold=10
set hotspot-default kind=sfq name=hotspot-default sfq-allot=1514 sfq-perturb=\
    5
add kind=pcq name=DSL-download pcq-classifier=dst-address,dst-port pcq-limit=\
    50 pcq-rate=0 pcq-total-limit=2000
add kind=pcq name=DSL-upload pcq-classifier=src-address,src-port pcq-limit=50 \
    pcq-rate=0 pcq-total-limit=2000
set default-small kind=pfifo name=default-small pfifo-limit=10
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=168k name=QT-Internet-Out packet-mark=Internet-Out parent=\
    QT-Global-Out priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=128k \
    max-limit=168k name=QT-Game-Out packet-mark=Game-Out parent=QT-Global-Out \
    priority=1 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
    max-limit=336k name=QT-Internet-In packet-mark=Internet-In parent=\
    QT-Global-In priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=256k \
    max-limit=336k name=QT-Game-In packet-mark=Game-In parent=QT-Global-In \
    priority=1 queue=default
/interface bridge port
add bridge=bridge-SCN comment="" disabled=no edge=auto external-fdb=auto \
    horizon=none interface=ether2-Neighbours path-cost=10 point-to-point=auto \
    priority=0x80
add bridge=bridge-LAN comment="" disabled=no edge=auto external-fdb=auto \
    horizon=none interface=vlan-L2-3 path-cost=10 point-to-point=auto \
    priority=0x80
add bridge=bridge-SCN comment="" disabled=no edge=auto external-fdb=auto \
    horizon=none interface=ether1-Nanostation path-cost=10 point-to-point=\
    auto priority=0x80
add bridge=bridge-SCN comment="" disabled=no edge=auto external-fdb=auto \
    horizon=none interface=vlan-L1 path-cost=10 point-to-point=auto priority=\
    0x80
/interface bridge settings
set use-ip-firewall=yes use-ip-firewall-for-pppoe=yes \
    use-ip-firewall-for-vlan=yes
/ip address
add address=192.168.90.1/24 broadcast=192.168.90.255 comment="LAN - WiFi" \
    disabled=no interface=bridge-LAN network=192.168.90.0
add address=10.20.60.123/24 broadcast=10.20.60.255 comment=SCN disabled=no \
    interface=bridge-SCN network=10.20.60.0
add address=192.168.89.254/32 broadcast=192.168.89.2 comment=\
    "Nanostation @ 192.168.89.2" disabled=no interface=ether1-Nanostation \
    network=192.168.89.2
add address=(hidden)/25 broadcast=(hidden).127 comment=\
    "SDSL routers @ (hidden).20-21" disabled=no interface=ether4-SDSL-Univ \
    network=(hidden).0
add address=192.168.89.254/32 broadcast=192.168.89.1 comment=\
    "D-ink ADSL router @ 192.168.89.1" disabled=no interface=ether5-ADSL-MWeb \
    network=192.168.89.1
add address=192.168.89.254/32 broadcast=192.168.89.3 comment=\
    "D-ink WiFi AP @ 192.168.89.3" disabled=no interface=ether3-Switch \
    network=192.168.89.3
add address=192.168.91.1/24 broadcast=192.168.91.255 comment="LAN - Switch" \
    disabled=no interface=ether3-Switch network=192.168.91.0
/ip dhcp-server network
add address=192.168.90.0/24 comment="LAN - WiFi" dns-server=192.168.90.1 \
    domain=tuis gateway=192.168.90.1
add address=192.168.91.0/24 comment="LAN - Switch" dns-server=192.168.91.1 \
    domain=tuis gateway=192.168.91.1
/ip dns
set allow-remote-requests=yes cache-max-ttl=1w cache-size=2048KiB \
    max-udp-packet-size=512 primary-dns=168.210.2.2 secondary-dns=10.20.30.1
/ip firewall connection tracking
set enabled=yes generic-timeout=10m icmp-timeout=10s tcp-close-timeout=10s \
    tcp-close-wait-timeout=10s tcp-established-timeout=1d \
    tcp-fin-wait-timeout=10s tcp-last-ack-timeout=10s \
    tcp-syn-received-timeout=5s tcp-syn-sent-timeout=5s tcp-syncookie=no \
    tcp-time-wait-timeout=10s udp-stream-timeout=3m udp-timeout=10s
/ip firewall filter
add action=jump chain=input comment="Filter incoming Internet packets" \
    disabled=no in-interface=pppoe-OW-Local jump-target=FromInternet
add action=jump chain=input comment="Filter incoming Internet packets" \
    disabled=no in-interface=pppoe-WA-Local jump-target=FromInternet
add action=jump chain=input comment="Filter incoming Internet packets" \
    disabled=no in-interface=pppoe-Mweb-Uncapped jump-target=FromInternet
add action=log chain=FromInternet comment=\
    "Log FTP,SSH,Telnet,HTTP,HTTPS and Web Proxy from Internet" disabled=no \
    dst-port=21-23,80,443,8080 log-prefix="Router Accessed From Internet" \
    protocol=tcp
add action=drop chain=FromInternet comment=\
    "Block FTP,SSH,Telnet,HTTP,HTTPS and Web Proxy from Internet" disabled=no \
    dst-port=21-23,80,443,8080 protocol=tcp
add action=drop chain=FromInternet comment="Block ping from Internet" \
    disabled=no protocol=icmp
add action=accept chain=input comment="default configuration" disabled=no \
    protocol=icmp
add action=accept chain=input comment="default configuration" \
    connection-state=established disabled=no
add action=accept chain=input comment="default configuration" \
    connection-state=related disabled=no
add action=drop chain=input comment="default configuration" connection-state=\
    invalid disabled=no
/ip firewall mangle
add action=mark-packet chain=prerouting comment="Mark incoming game packets" \
    disabled=no in-interface=pppoe-Mweb-Uncapped new-packet-mark=Game-In \
    passthrough=no protocol=udp src-port=27015-27020,28015-28020
add action=mark-packet chain=prerouting comment="Mark incoming game packets" \
    disabled=no in-interface=pppoe-Mweb-Uncapped new-packet-mark=Game-In \
    passthrough=no protocol=tcp src-port=6110-6119
add action=mark-packet chain=prerouting comment=\
    "Mark incoming Internet packets" disabled=no in-interface=\
    pppoe-Mweb-Uncapped new-packet-mark=Internet-In passthrough=no
add action=mark-packet chain=forward comment="Mark outgoing game packets" \
    disabled=no new-packet-mark=Game-Out out-interface=pppoe-Mweb-Uncapped \
    passthrough=no port=27015-27020,28015-28020 protocol=udp
add action=mark-packet chain=forward comment="Mark outgoing game packets" \
    disabled=no dst-port=6110-6119 new-packet-mark=Game-Out out-interface=\
    pppoe-Mweb-Uncapped passthrough=no protocol=tcp
add action=mark-packet chain=forward comment="Mark outgoing Internet packets" \
    disabled=no new-packet-mark=Internet-Out out-interface=\
    pppoe-Mweb-Uncapped passthrough=no
/ip firewall nat
add action=masquerade chain=srcnat comment="NAT - SCN" disabled=no \
    dst-address=10.20.0.0/16 out-interface=bridge-SCN
add action=masquerade chain=srcnat comment="NAT - Univ via SCN" disabled=no \
    dst-address=(hidden).0/16 out-interface=bridge-SCN src-address=\
    192.168.90.0/23
add action=masquerade chain=srcnat comment="NAT - D-Link ADSL router" \
    disabled=no out-interface=ether5-ADSL-MWeb src-address=192.168.90.0/23
add action=masquerade chain=srcnat comment="NAT - SCN VPN" disabled=no \
    out-interface=pptp-SCN src-address=192.168.90.0/23
add action=masquerade chain=srcnat comment="NAT - SDSL" disabled=no \
    out-interface=ether4-SDSL-Univ src-address=192.168.90.0/23
add action=masquerade chain=srcnat comment="NAT - MWeb Uncapped" disabled=no \
    out-interface=pppoe-Mweb-Uncapped src-address=192.168.90.0/23
add action=masquerade chain=srcnat comment="NAT - WebAfrica Local Only" \
    disabled=no out-interface=pppoe-WA-Local src-address=192.168.90.0/23
add action=masquerade chain=srcnat comment=\
    "NAT - OpenWeb (Internet Solutions) Local Only" disabled=no \
    out-interface=pppoe-OW-Local src-address=192.168.90.0/23
/ip route
comment="Internet - MWeb Uncapped" disabled=no distance=1 dst-address=\
    0.0.0.0/0 gateway=pppoe-Mweb-Uncapped
add comment=SCN disabled=no distance=1 dst-address=10.20.0.0/16 gateway=\
    10.20.60.1 scope=30 target-scope=10
add check-gateway=ping comment="Univ - SDSL" disabled=no distance=1 \
    dst-address=(hidden).0/16 gateway=(hidden).1 scope=30 target-scope=10
add comment="CS Server" disabled=no distance=1 dst-address=196.38.180.55 \
   gateway=pppoe-OW-Local scope=30 target-scope=10
/queue interface
set ether1-Nanostation queue=ethernet-default
set ether2-Neighbours queue=ethernet-default
set ether3-Switch queue=ethernet-default
set ether4-SDSL-Univ queue=ethernet-default
set ether5-ADSL-MWeb queue=ethernet-default
set vlan-L2-3 queue=default
set bridge-LAN queue=default
set vlan-L1 queue=default
set bridge-SCN queue=default
set pppoe-Mweb-Uncapped queue=default
set pppoe-WA-Local queue=default
set pppoe-OW-Local queue=default
Btw, is the `/export file=<filename> hide-sensitive` supposed to remove the username and password from the .rsc file? Because mine didn't remove any "sensitive" information like username and passwords!
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Bandwidth reservation for gaming

Mon Jun 14, 2010 12:08 am

queue tree seems ok in the light of parameters... max-limit should be equal to your bandwidth (-5-10% to breathe :) see below). actually, you don't need to use 'global-in'. I'd rather use 'global-out' and 'forward' chain for all marking.

also check that your line is not congested, because if game packets are dropped on the other side of the link, you cannot give them higher priority...
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Mon Jun 14, 2010 1:43 am

I've already set the the max-limit to -10% of the line's bandwidth. I need to limit the incoming traffic too, since HTTP downloads can easily be like 300kbps down and 10-20kbps up, which makes it almost impossible to limit HTTP traffic on just `global-out`.

The Queue Tree setup is definitely not working as I would like it. Currently its as if I'm just using Simple Queues :(

This is how the QT reacts to a CS1.6 game + HTTP downloads. See the Avg. Rate column of the QT tab:
Internet Limited 1.png
And this is how the QT reacts to just HTTP downloads. See the Avg. Rate column of the QT tab:
Internet Limited 2.png
CS1.6 use about 25kbps downstream and 20kbps upstream, but it doesn't like a congested network, which is why I want to reserve at 192kbps of the 384kbps downstream and 100kbps of the 192kbps upstream.
I can adjust the QT-Internet-In max-limit to 192kbps, but then it would limit my Internet to 192kbps even when I'm not playing games at all!
You do not have the required permissions to view the files attached to this post.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Bandwidth reservation for gaming

Mon Jun 14, 2010 2:32 am

well, in general it works as it should. game traffic receives the bandwidth it uses
I need to limit the incoming traffic too, since HTTP downloads can easily be like 300kbps down and 10-20kbps up, which makes it almost impossible to limit HTTP traffic on just `global-out`.
kind of misunderstood here... 'global-in' and 'global-out' are just two points where you can build your queues (actually, simple queues use 'global-*' parents). you cannot select incoming traffic at all - you receive what your ISP send to you, not less, not more. so nothing wrong when you use 'global-out' for the traffic client downloads
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Fri Jun 18, 2010 11:48 pm

Would it be possible to toggle between 2 Queue Trees, based on a kbps threshold of 'game' packets in/out?
For example:
  1. If the 'game' packets reach 10kbps, then activate the Gaming Queue Tree and disable the NonGaming QT
  2. and if the 'game' packets drop to below 5kbps again, then switch back to the original QT states.
Here's an example of how my QT structure looks, with the Gaming QT disabled:
ToggleQTs.png
Thanks in advance.
You do not have the required permissions to view the files attached to this post.
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Mon Jun 28, 2010 11:10 am

Bump.

Any ideas for achieving something like I've posted in my previous post?
If it would be possible to script something like that, should I perhaps try the Scripting section of the forum?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Bandwidth reservation for gaming

Tue Jun 29, 2010 12:08 pm

on your screenshot, there's no active queue for 'game' traffic - you cannot control it...

and, anyway, enabling/disabling queues is wrong - you should just make a setup that will work 'in place'
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Wed Jun 30, 2010 12:02 am

yes. I know that I didn't have any active queue for 'game' traffic since I wanted to switch between the 2 copies of queue trees.

I also know that it's a bad idea to enable/disable queues automatically, but I have no idea how to reserve bandwidth for gaming ONLY when someone is playing already. It would be silly to limit the bandwidth 24/7 just so that someone could play his/her game.

Ideas would be appreciated.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Bandwidth reservation for gaming

Fri Jul 02, 2010 2:38 pm

if you have two leaves with different priority, the leaf with higher priority (lower number) will reach 'max-limit' first. so you should use game leaf with priority=1, and 'the_rest' leaf with max-limit=your_bandwidth
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Bandwidth reservation for gaming

Fri Jul 02, 2010 3:17 pm

Thanks. I'll give that I try, but I'm still a bit skeptical about that solution, since the game uses only 25kbps but requires like 128kbps of the line to be available.

Who is online

Users browsing this forum: Bing [Bot], dwnldr, m3das and 140 guests