This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:router:mikrotik_qos [2014/08/20 08:34] gcooper |
networking:router:mikrotik_qos [2019/03/14 07:57] (current) gcooper |
||
---|---|---|---|
Line 3: | Line 3: | ||
See also **[[https:// | See also **[[https:// | ||
- | **Enterprise QoS – A consistent QoS strategy**: http://ethancbanks.com/2013/09/16/ | + | https://www.mikrotik-routeros.com/2014/05/the-mother-of-all-qos-trees-v6-0/ |
**Background**: | **Background**: | ||
+ | |||
+ | **Background**: | ||
+ | |||
+ | **Marking Connections**: | ||
+ | |||
+ | **Bridged**: | ||
**Snom Wiki**: http:// | **Snom Wiki**: http:// | ||
**Service Provider**: http:// | **Service Provider**: http:// | ||
+ | |||
+ | **Script**: http:// | ||
+ | |||
+ | **Enterprise QoS – A consistent QoS strategy**: http:// | ||
http:// | http:// | ||
Line 17: | Line 27: | ||
===== Generic QoS Comments ===== | ===== Generic QoS Comments ===== | ||
- | There is layer 2 and layer 3 QoS. | + | **There is layer 2 and layer 3 QoS.** |
- | Layer 2 is practically VLAN, where you give the packets in that VLAN a higher priority than packets in the default VLAN. The Ethernet switch is here the device that you need to control. If you do it right, you can have a ISDN-like quality level in your LAN, even if there is very heavy traffic in the LAN. You can set that up manually, but better is to use LLDP which is a kind of DHCP for the VLAN. | + | **Layer 2** is in practice VLANs, where you give the packets in that VLAN a higher priority than packets in the default VLAN. The Ethernet switch is here the device that you need to control. If you do it right, you can have an ISDN-like quality level in your LAN, even if there is very heavy traffic in the LAN. You can set that up manually, but better is to use LLDP which is a kind of DHCP for the VLAN. |
- | Layer 3 is using some bits in the IP header to tell the router with what priority the packet needs to be routed. The point here is that you need to have the router under your control. Those QoS bits are practically never used when you send a packet over the public Internet. But you can use then for example if you have a large corporate network where you control the routers. | + | **Layer 3** is using some bits in the IP header to tell the router with what priority the packet needs to be routed. The point here is that you need to have the router under your control. Those QoS bits are practically never used when you send a packet over the public Internet. But you can use them, for example, if you have a large corporate network where you control the routers. |
- | From the PBX perspective, | + | From the **PBX perspective**, the PBX stays out of the discussion. You need to make sure that the PBX has an interface that has the VLAN set up correctly. The PBX tags (like the phones) |
===== DSCP and ToS Conversion ===== | ===== DSCP and ToS Conversion ===== | ||
Line 31: | Line 41: | ||
^ ^Voice Bearer | ^ ^Voice Bearer | ||
|DSCP |46 (EF) |24 (CS3) |34 (AF41) | |DSCP |46 (EF) |24 (CS3) |34 (AF41) | ||
- | |COS |5 | + | |COS |5 |
==== More Complete Chart ==== | ==== More Complete Chart ==== | ||
{{ : | {{ : | ||
+ | |||
+ | ===== Throttle Traffic ===== | ||
+ | |||
+ | You can use Simple Queues to throttle all traffic to or from an IP address. | ||
+ | |||
+ | * Throttle Printer Traffic | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===== Lite Script ===== | ||
+ | |||
+ | FIXME Untested | ||
+ | |||
+ | :!: This script may be appropriate in a CPE router with an IP PBX behind it. | ||
+ | |||
+ | http:// | ||
+ | |||
+ | * This is a very simple script with just two levels of priority | ||
+ | * It prioritizes VoIP and that's it | ||
+ | * Internet service in this example is 5M down and 1M up | ||
+ | * Max-limit is the maximum amount that marked traffic may reach | ||
+ | * This is necessary for the algorithms to function and must not be 0 | ||
+ | * Choose a value 80%-90% of your tested speed to prevent the ISP's equipment from [[http:// | ||
+ | * Replace '' | ||
+ | |||
+ | < | ||
+ | # Qos Script Lite v1.0 | ||
+ | # September 7, 2013 | ||
+ | # Compatible with RouterOS 6.3 | ||
+ | # Rename ether-WAN and ether-LAN to match your environment | ||
+ | |||
+ | # Mark all UDP traffic for an IP-PBX. | ||
+ | /ip firewall mangle | ||
+ | add chain=forward action=mark-connection protocol=udp | ||
+ | add chain=forward action=mark-packet | ||
+ | add chain=forward action=mark-connection protocol=udp | ||
+ | add chain=forward action=mark-packet | ||
+ | |||
+ | # Mark everything else. | ||
+ | add chain=forward action=mark-connection connection-mark=no-mark | ||
+ | add chain=forward action=mark-packet | ||
+ | |||
+ | # Create two queue trees set to 90% of ISP Internet service. | ||
+ | /queue tree | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | |||
+ | # Add our marked connections as children of queue so priority works. | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | </ | ||
+ | |||
+ | ===== More Flexible Script ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | FIXME Untested | ||
+ | |||
+ | < | ||
+ | # Date: November 11, 2013 | ||
+ | # Version: 1.2 | ||
+ | # Tested with RouterOS 6.6 | ||
+ | # Rename ether-WAN and ether-LAN to match your environment | ||
+ | |||
+ | |||
+ | |||
+ | ############################################################################### | ||
+ | # Mangle | ||
+ | # | ||
+ | # Using prerouting/ | ||
+ | # | ||
+ | /ip firewall mangle | ||
+ | ############################################################################### | ||
+ | |||
+ | # DNS requests. Mark in two places because DNS is sent out by the router (itself) too. | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | add chain=postrouting action=mark-connection protocol=udp | ||
+ | add chain=postrouting action=mark-packet | ||
+ | |||
+ | # Mark all VoIP traffic. We've set all our equiptment to use SIP 5060,5061 and RTP 10000-20000. | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | |||
+ | # Mark all UDP traffic. Mark different UDP streams if you want more granularity. | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | |||
+ | # Ping replies. Mark in two places because ICMP is sent out by the router (itself) too. | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | add chain=postrouting action=mark-connection protocol=icmp | ||
+ | add chain=postrouting action=mark-packet | ||
+ | |||
+ | # ACK traffic. Based on viewtopic.php? | ||
+ | add chain=postrouting action=mark-packet passthrough=no protocol=tcp tcp-flags=ack packet-size=0-123 new-packet-mark=" | ||
+ | add chain=prerouting | ||
+ | |||
+ | # Mark all new HTTP(s) connections with " | ||
+ | # If the current mark of " | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | add chain=prerouting | ||
+ | |||
+ | # Mark everything else that has no mark applied. | ||
+ | add chain=prerouting action=mark-connection | ||
+ | add chain=prerouting action=mark-packet | ||
+ | |||
+ | |||
+ | |||
+ | ############################################################################### | ||
+ | # HTB Queue Tree a unidirectional queue | ||
+ | # | ||
+ | # Based on 90% of 1Mup/5Mdown Internet service. | ||
+ | # | ||
+ | # Notes: | ||
+ | # priority means 'drop packets' | ||
+ | # When limit-at=0 | ||
+ | # When limit-at=123 priority starts when limit-at is reached. | ||
+ | # | ||
+ | # The priority option applies to children not parents. Parent is for setting | ||
+ | # overall limits. Therefore use limit-at and max-limit on the children if | ||
+ | # you want more granularity. | ||
+ | # | ||
+ | # max-limit must always be set or priority will not happen. | ||
+ | # | ||
+ | # Tips for TCP (not VoIP) SOHO network: | ||
+ | # limit-at | ||
+ | # max-limit = Total bandwidth / min hosts | ||
+ | # | ||
+ | /queue tree | ||
+ | ############################################################################### | ||
+ | |||
+ | # The secret to ensuring VoIP quality (or any UDP traffic) is to put it into | ||
+ | # a queue that will never be full and thus never prioritize (drop) packets. | ||
+ | add name=" | ||
+ | add name=" | ||
+ | |||
+ | # Next, create a queue for high priority traffic. | ||
+ | add name=" | ||
+ | add name=" | ||
+ | |||
+ | # Finally, create a queues for traffic that normally exceeds levels. | ||
+ | add name=" | ||
+ | add name=" | ||
+ | |||
+ | # A | ||
+ | add name=" | ||
+ | add name=" | ||
+ | # B | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | # C | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | add name=" | ||
+ | </ |