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


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

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

Following is an simple demonstration on howto prioritize speed test.
Scenario: Client is allowed to get 512k , but when he will access 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 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= 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 -" packet-marks="" \
    parent=none priority=8 queue=default-small/default-small target-addresses= total-queue=default-small

Move the 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.



%d bloggers like this: