Syed Jahanzaib Personal Blog to Share Knowledge !

November 12, 2015

Prioritize SpeedTest.Net Results via Mikrotik Queue

Filed under: Uncategorized — Tags: , — Syed Jahanzaib / Pinochio~:) @ 9:48 AM

speedtest-logo-white


Updated August 2020 

Following is just a sample code to allow separate bandwidth if user is doing speedtest on his PC. In this example, when user is connected to mikrotik via pppoe dialer , his queue is created dynamically based on radius profile & he will be limited to this speed for all traffic. What OP wants is that when user test speedtest, he should get full 1mb (even if he is using internet at full speed on other traffic). To accomplish this task, you can create address list of speedtest servers located nearby your region. & then mark packets. Based on these marked packets you can create separate queues for speedtest. This way when user will be using internet , he will get separate bandwidth just for speedtest.

Code Example:

/ip firewall address-list

add address=192.168.0.1-192.168.0.255 list=1mb-ip-pool-address-list
add address=192.168.1.1-192.168.1.255 list=2mb-ip-pool-address-list
# Servers for RWP/Pindi Region, you may look for your local isps speedtest by running speedtest on client & run torch to see the ip addresses
add address=103.103.42.0/24 list=speedtest_servers_list
add address=103.125.178.0/24 list=speedtest_servers_list
add address=42.201.253.0/24 list=speedtest_servers_list
add address=103.135.44.0/24 list=speedtest_servers_list
add address=118.107.138.0/24 list=speedtest_servers_list
add address=103.113.100.0/24 list=speedtest_servers_list
add address=203.135.29.0/24 list=speedtest_servers_list
add address=115.167.73.0/24 list=speedtest_servers_list
add address=202.69.12.0/24 list=speedtest_servers_list
add address=58.65.177.0/24 list=speedtest_servers_list
add address=103.55.68.0/24 list=speedtest_servers_list

/ip firewall mangle

add action=mark-packet chain=forward dst-address-list=speedtest_servers_list new-packet-mark=speedtest_1mb_up passthrough=no src-address-list=1mb-ip-pool-address-list
add action=mark-packet chain=forward dst-address-list=1mb-ip-pool-address-list new-packet-mark=speedtest_1mb_down passthrough=no src-address-list=speedtest_servers_list
add action=mark-packet chain=forward dst-address-list=speedtest_servers_list new-packet-mark=speedtest_2mb_up passthrough=no src-address-list=2mb-ip-pool-address-list
add action=mark-packet chain=forward dst-address-list=2mb-ip-pool-address-list new-packet-mark=speedtest_2mb_down passthrough=no src-address-list=speedtest_servers_list

/queue type
add kind=pcq name=1mb-upload pcq-classifier=src-address pcq-dst-address6-mask=64 pcq-rate=1024k pcq-src-address6-mask=64
add kind=pcq name=1mb-download pcq-classifier=dst-address pcq-dst-address6-mask=64 pcq-rate=1024k pcq-src-address6-mask=64
add kind=pcq name=2mb-upload pcq-classifier=src-address pcq-dst-address6-mask=64 pcq-rate=2048k pcq-src-address6-mask=64
add kind=pcq name=2mb-download pcq-classifier=dst-address pcq-dst-address6-mask=64 pcq-rate=2048k pcq-src-address6-mask=64

/queue simple
add name="additional 1mb queue for speedtest" packet-marks=speedtest_1mb_up queue=1mb-upload/1mb-download target=""
add name="additional 1mb queue for speedtest" packet-marks=speedtest_1mb_down queue=1mb-upload/1mb-download target=""
add name="additional 2mb queue for speedtest" packet-marks=speedtest_2mb_up queue=2mb-upload/2mb-download target=""
add name="additional 2mb queue for speedtest" packet-marks=speedtest_2mb_down queue=2mb-upload/2mb-download target=""

Regard’s
Syed Jahanzaib


below post is OLD ARCHIVED ! used with L7 , not useful.

speedtest


As implemented it yesterday , an old trick, NOTHING NEW really.

(Although I personally don’t see any reason why to prioritize such speed.test.net results, to fake whom, client or yourself ? lol)

Following is an simple demonstration on howto prioritize speedtest.net speed test.
Scenario: Client is allowed to get 512k , but when he will access speedtest.net to check the speed, he will able to see 2mb , (every user will be able to check it on 2mb limit , individually per ip basis) while his normal download/browsing will remain under 512k queue limit as showed in the picture above.

ROS CODE, Tested with 5.x and 6.x versions:


# Mark speedtest in Layer7 firewall
/ip firewall layer7-protocol
add name=speedtest regexp="^.+(speedtest).*\\\$"

# Marking SPEEDTEST.NET in mangle section using L7
/ip firewall mangle
add action=mark-connection chain=forward comment=SPEEDTEST layer7-protocol=speedtest new-connection-mark=speedtest_conn
add action=mark-connection chain=prerouting new-connection-mark=speedtest_conn protocol=tcp src-port=8080
add action=mark-packet chain=prerouting connection-mark=speedtest_conn new-packet-mark=speedtest_pkt passthrough=no
add action=mark-connection chain=postrouting dst-port=8080 new-connection-mark=speedtest_conn protocol=tcp
add action=mark-packet chain=postrouting connection-mark=speedtest_conn new-packet-mark=speedtest_pkt passthrough=no

# ADD PCQ so that i can be applied on per ip bases later in simple queue / zaib
/queue type
add kind=pcq name=download-2mb pcq-burst-rate=0 pcq-burst-threshold=0 pcq-burst-time=10s pcq-classifier=dst-address pcq-dst-address-mask=32 pcq-dst-address6-mask=64 pcq-limit=50 pcq-rate=2048k \
    pcq-src-address-mask=32 pcq-src-address6-mask=64 pcq-total-limit=2000
add kind=pcq name=upload-2mb pcq-burst-rate=0 pcq-burst-threshold=0 pcq-burst-time=10s pcq-classifier=src-address pcq-dst-address-mask=32 pcq-dst-address6-mask=64 pcq-limit=50 pcq-rate=2048k \
    pcq-src-address-mask=32 pcq-src-address6-mask=64 pcq-total-limit=2000

# Add simple QUEUE to limit speedtest.net 2mb PER USER
/queue simple
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment="Limit every Users at 2mb using PCQ. for speedtest only marked by mangle / zaib" direction=both disabled=no interface=all limit-at=0/0 max-limit=0/0 name=\
    "SpeedTest.Net 2Mb per use via g PCQ / zaib" packet-marks=speedtest_pkt parent=none priority=8 queue=upload-2mb/download-2mb target-addresses=192.168.5.0/24 total-queue=default-small

# Add simple QUEUE to limit user PC individually for rest of traffic, static or dynamic up to your network.
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s direction=both disabled=no interface=all limit-at=512k/512k max-limit=512k/512k name="Zaib Desktop 512k A llowed - 192.168.5.2" packet-marks="" \
    parent=none priority=8 queue=default-small/default-small target-addresses=192.168.5.2/32 total-queue=default-small
 

Move the speedtest.net queue on top! Ordering is very important in mikrotik, as rules are processed order wise , zero to bottom

Note: It can further be adjusted in PCQ, QUEUE TREE, etc etc as per network designed.


client


Regard’s
Jz

14 Comments »

  1. can its worked with Radius login user

    Like

    Comment by Deep Patel — November 13, 2015 @ 11:34 AM

  2. AoA, Bhai can we use this same method for other urls , Like if we want users to have a better experience browsing FB.

    Like

    Comment by Nabeel — November 19, 2015 @ 12:26 PM

  3. How to make a priority for PPoE users to the IPTV server (Example: 192.168.3.1:8081)
    Thank you

    Like

    Comment by mojbuk (@mojbuk) — November 26, 2015 @ 7:13 PM

  4. How to make a priority for PPoE customers (radius) to the IPTV server (Example: 192.168.3.1:8081)
    Thank you.

    Like

    Comment by mojbuk (@mojbuk) — November 26, 2015 @ 7:17 PM

  5. Seems to me this layer 7 not working any more for speed test.
    Any one have working layer 7 regexp for speedtest servers ?

    Like

    Comment by PeRo — December 25, 2015 @ 1:59 PM

  6. dear zaib 6.35 rc8 not working this code i wish good day

    Like

    Comment by figde — February 13, 2016 @ 10:54 PM

  7. dear zaib 6.38 rc 8 version not working this code ?? i wish you good day..

    Like

    Comment by figde — February 13, 2016 @ 11:28 PM

  8. This works on 6.35 just fine, however, i have obviously made a mistake. Both upload and download tests get seen and queued as Download in the Queue. Any ideas where I went wrong?

    Thanks.

    Like

    Comment by Al — April 25, 2016 @ 12:58 AM

  9. Works with radius and usermanager!!

    Like

    Comment by Chris Gachibi — September 27, 2016 @ 9:45 AM

  10. When I tried to execute your /queue type, I got error messages from Mikrotik. I am using 6.xx.

    Like

    Comment by trashcan bin — March 16, 2017 @ 7:38 AM

  11. […] Fuente : AACable […]

    Like

    Pingback by Priorizar resultados de SpeedTest.Net a través de Mikrotik Queue – MikrotikTools.Com — August 22, 2017 @ 8:36 AM

  12. Let me see if I understood, so my cliente will have his simple queue created by pppoe server conection and a second exclusively queue just to manage the traffic that goes to the speed teste servers, right ?

    Like

    Comment by Ikarus Telecom Internet — October 5, 2018 @ 10:10 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: