{"id":768,"date":"2022-06-05T10:42:16","date_gmt":"2022-06-05T10:42:16","guid":{"rendered":"https:\/\/blog.stmellion.org\/?page_id=768"},"modified":"2022-06-05T12:19:17","modified_gmt":"2022-06-05T12:19:17","slug":"mikrotik-routerboard","status":"publish","type":"post","link":"https:\/\/blog.stmellion.org\/?p=768","title":{"rendered":"Mikrotik Routerboard"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Bandwidth Management<\/h2>\n\n\n\n<p>My need for bandwidth management (aka Traffic Shaping) is a result of my desire to live in the countryside. Low population means little incentive for commercial companies to install fibre. No fibre means slow broadband over a piece of overhead wire installed in the 1970s.<\/p>\n\n\n\n<p>I found various articles about traffic shaping on Mikrotik routers but few of them seemed to describe my scenario, although I\u2019m fairly confident that my scenario is common to the majority of people who want to manage their bandwidth!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The scenario<\/h3>\n\n\n\n<p>I have a Routerboard with multiple Ethernet ports. The ports all run at 1Gb\/s except the one facing my Openreach modem that runs at 100Mb\/s. That\u2019s more than adequate as my Internet connection peaks at around 25Mb\/s. I want traffic between interfaces to be unregulated, except for traffic coming from the Internet. I also don\u2019t want to restrict (cap) the bandwidth from the Internet to any particular interface or protocol. I just want to give priority to some traffic at busy times.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Packet Tagging<\/h3>\n\n\n\n<p>The overall bandwidth management exercise can be broken down into two sections: Packet Tagging and Queue Management. Packet Tagging is concerned with identifying the traffic. Lets start by putting a rule in place to measure the traffic coming off the Internet interface. From now on I\u2019m going to call this interface <strong>AAISP<\/strong> because that\u2019s the name I use for it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/ip firewall mangle\nadd chain=forward action=passthrough in-interface=AAISP<\/code><\/pre>\n\n\n\n<p>The above rule does nothing to the incoming packets. It simply enables some stats gathering of traffic coming in from the AAISP interface (the Internet). The stats can be viewed with a <em>print stats<\/em> command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print stats\nFlags: X - disabled, I - invalid, D - dynamic \n #    CHAIN                                             ACTION                            BYTES         PACKETS\n      forward                                           passthrough              35 567 80<\/code><\/pre>\n\n\n\n<p>As we create rules to tag traffic, the above metric is useful to determine if the total inbound traffic roughly matches the sum of the rules.<\/p>\n\n\n\n<p>Next, we&#8217;ll create two proper tagging rules.  This example will tag packets as <em>ether2<\/em> if they are destined for the ether2 interface and likewise for <em>ether3<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-code has-extra-small-font-size\"><code>add chain=forward action=mark-packet new-packet-mark=ether2 passthrough=yes in-interface=AAISP out-interface=ether2\nadd chain=forward action=mark-packet new-packet-mark=ether3 passthrough=yes in-interface=AAISP out-interface=ether3<\/code><\/pre>\n\n\n\n<p>This tagging method is really powerful.  While this example tags all traffic to a specific interface, we could just as easily tag it by protocol or source address.<\/p>\n\n\n\n<p>Issue another <em>print stats<\/em> command and you&#8217;ll see metrics relating to ether2 and ether3.  It&#8217;s a good idea to add a comment to each metric so you can identify its purpose.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Queue Management<\/h3>\n\n\n\n<p>Now our inbound packets are tagged, we can apply priorities to the tags.<\/p>\n\n\n\n<pre class=\"wp-block-code has-extra-small-font-size\"><code>\/queue tree\nadd name=ether2 parent=global packet-mark=ether2 priority=2\nadd name=ether3 parent=global packet-mark=ether3 priority=4<\/code><\/pre>\n\n\n\n<p>We&#8217;ve now granted higher priority to traffic going from AAISP to ether2 compared to traffic going from AAISP to ether3.  Priorities are in the range 1-8 with 1 being the highest.  Stats can be viewed using the <em>print stats<\/em> command.<\/p>\n\n\n\n<pre class=\"wp-block-code has-extra-small-font-size\"><code>print stats\nFlags: X - disabled, I - invalid \n 0   name=\"ether2\" parent=global packet-mark=ether2 rate=17928 packet-rate=5 queued-bytes=0 queued-packets=0 bytes=520252348 packets=482842 dropped=0 \n 1   name=\"ether3\" parent=global packet-mark=ether3 rate=0 packet-rate=0 queued-bytes=0 queued-packets=0 bytes=16021459119 packets=11916305 dropped=463600<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Bandwidth Management My need for bandwidth management (aka Traffic Shaping) is a result of my desire to live in the countryside. Low population means little incentive for commercial companies to install fibre. No fibre means slow broadband over a piece of overhead wire installed in the 1970s. I found various articles about traffic shaping on&hellip; <a class=\"more-link\" href=\"https:\/\/blog.stmellion.org\/?p=768\">Continue reading <span class=\"screen-reader-text\">Mikrotik Routerboard<\/span><\/a><\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-768","post","type-post","status-publish","format-standard","hentry","category-general","entry"],"_links":{"self":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts\/768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=768"}],"version-history":[{"count":4,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts\/768\/revisions"}],"predecessor-version":[{"id":772,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=\/wp\/v2\/posts\/768\/revisions\/772"}],"wp:attachment":[{"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.stmellion.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}