I used to use this limitation on public hotspot. Where everyone free to connect while we’re on limited bandwidth. Video stream usually use high bandwidth, at least 384kbps for SD quality (not HD) and you can imagine if 15 peoples stream YouTube video at the same time while we only have 5MB bandwidth. On busy hours, we got more than 40 public user using our mikrotik hotspot (our highest record 93 users), and most of them are teenagers who connect with their Tablets and MobilePhones.
Just like the earlier posts (Limit number connection, Block per profile), this method use Layer 7 protocol of miktorik firewall and also trapping user ip address. So first we need to add YouTube address into Layer 7 Protocol list. Let’s start.
Add the following to Layer 7 Regexp:
Name it as YouTube-Stream
We’re going to apply this rule only to IP Address on Src. Address List. This address list was generated automatically every time a user login with mikrotik hotspot (we called trapping user ip into address list).
This will mark packet from connection marked by previous mangle rule so we can use this marked packet on Queue Tree.
This will limit stream at 384kbps, max Burst at 512kbps for 15 sec and threshold 128kbps.
Click apply to save the rule and see the result.
You can also set limit to another video stream website such as dailymotion, metacafe and mccont. All we need is to knowing what address used on streaming url. For example dailymotion use cdn.dailymotion.com on streaming address. Next add those address into youtube-stream regex on layer 7 protocol. The complete regexp will be:
Find another streaming address and add them into layer 7 list. Remember, main website url address doesn’t always mean the same address for streaming url. If you put the main website into layer 7 list, you’ll also limiting access speed to the main website.