{"id":16,"date":"2006-12-20T18:54:52","date_gmt":"2006-12-20T05:54:52","guid":{"rendered":"http:\/\/www.meta.net.nz\/~daniel\/blog\/?p=16"},"modified":"2006-12-20T19:07:03","modified_gmt":"2006-12-20T06:07:03","slug":"linux-qos-and-monitoring","status":"publish","type":"post","link":"https:\/\/www.meta.net.nz\/~daniel\/blog\/2006\/12\/20\/linux-qos-and-monitoring\/","title":{"rendered":"Linux QOS and monitoring"},"content":{"rendered":"<p>I implemented QOS for inter-office phone calls for a client today using <em>tc<\/em> and diffserv. The phones and phone systems were configured by the supplier to set &#8220;Diffserv 46&#8221;, as their technician called it, which is also known as the <strong>EF PHB<\/strong>, or <strong>Exped<\/strong><strong>ited Forwarding Per-Hop Behaviour<\/strong><em>.<\/em> This was made slightly trickier by having to re apply the DSCP on outbound packets due to tunnel traversal. In the end I decided it was easier to use <em>iptables<\/em> to do this, rather than trying to get <em>tc<\/em> to do it via <em>dsmark<\/em>:<\/p>\n<p>[code] \/sbin\/iptables -t mangle -A OUTPUT -d a.b.c.d -j DSCP &#8211;set-dscp-class EF<br \/>\n[\/code]<br \/>\nActually applying the shaping is relatively straight forward using <em>dsmark<\/em> and <em>tcindex<\/em>:[code]<br \/>\n#!\/bin\/sh<br \/>\n# Create root DiffServ qdisc, attach to proper network interface<br \/>\n# This also uses any existing DSCP flags within the packet as the tcindex<br \/>\ntc qdisc add dev eth2 handle 1:0 root dsmark indices 64 set_tc_index<br \/>\ntc filter add dev eth2 parent 1:0 protocol ip prio 1 tcindex mask 0xfc shift 2<br \/>\n#<br \/>\n# Create class-based queuing discipline to hold the two classes<br \/>\ntc qdisc add dev eth2 parent 1:0 handle 2:0 cbq bandwidth 10Mbit cell 8 avpkt 1000 mpu 64<br \/>\n#<br \/>\n#Create EF class, create queuing discpline for EF, create filters<br \/>\ntc class add dev eth2 parent 2:0 classid 2:1 cbq bandwidth 10Mbit rate 5Mbit avpkt 40000 prio 1 bounded isolated allot 1514 weight 1 maxburst 30<br \/>\ntc qdisc add dev eth2 parent 2:1 tbf rate 5Mbit burst 2Mbit limit 5Mbit<br \/>\ntc filter add dev eth2 parent 2:0 protocol ip prio 1 handle 0x2e tcindex classid 2:1 pass_on<br \/>\n#<br \/>\n# Create BE class, create queuing discipline for BE, create filters<br \/>\ntc class add dev eth2 parent 2:0 classid 2:2 cbq bandwidth 10Mbit rate 3Mbit avpkt 1000 prio 7 allot 1514 weight 1 maxburst 21 borrow split 2:0 defmap 0xffff<br \/>\ntc qdisc add dev eth2 parent 2:2 red limit 50Kbit min 10Kbit max 30Kbit burst 20 avpkt 1000 bandwidth 3Mbit probability 0.4<br \/>\ntc filter add dev eth2 parent 2:0 protocol ip prio 2 handle 0 tcindex mask 0 classid 2:2 pass_on<br \/>\n[\/code]<\/p>\n<p>I then decided I needed a way to monitor whether this was actually working. A quick google search unveiled  <a href=\"http:\/\/www.docum.org\/docum.org\/monitor\/\">http:\/\/www.docum.org\/docum.org\/monitor\/<\/a>, which had a couple of different <em>tc<\/em> monitors. The author states he is no longer working on them, but they work well enough, and the <em>iproute2+tc<\/em> suite hasn&#8217;t exactly changed much lately anyway<br \/>\n[code]<br \/>\n.\/monitor_tc_top_bis.pl<br \/>\n18:52:18 up 30 min,  3 users,  load average: 0.10, 0.08, 0.08<br \/>\nInterval       Monitor     Monitor          Total<br \/>\nDev   Classid        Priority Speed            Bytes          Speed                     Bytes     Comment<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\neth2 2:                    N\/A           64.18Kbps   2.47MB      36.69Kbps         N\/A<br \/>\neth2 2:1                 1          6.03Kbps      86.27KB   1.25Kbps           N\/A<br \/>\neth2 2:2                 7                 64.18Kbps   2.47MB    36.69Kbps          N\/A<br \/>\n[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I implemented QOS for inter-office phone calls for a client today using tc and diffserv. The phones and phone systems were configured by the supplier to set &#8220;Diffserv 46&#8221;, as their technician called it, which is also known as the EF PHB, or Expedited Forwarding Per-Hop Behaviour. This was made slightly trickier by having to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/posts\/16"}],"collection":[{"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":1,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.meta.net.nz\/~daniel\/blog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}