newspaint

Documenting Problems That Were Difficult To Find The Answer To

Category Archives: Uncategorized

Prioritising VoIP on OpenWRT/OpenLEDE

Following the advice at the Network Traffic Control (QOS) page on the OpenWRT wiki I installed the tc package:

opkg install tc
opkg install kmod-sched-core

I wanted to set up 4 queues:

  ---[traffic to Australian Phone Company]---
                                             \
  ---[tiny packets <64 bytes]-----------------> router ---[ADSL]--- ISP
                                             /
  ---[small packets <256 bytes]-------------/
                                           /
  ---[everything else]---------------------

I needed a root qdisc with no limitations on it, and a top-level class with a maximum bandwidth of the upload speed to my ISP (around 1,400 kilobits per second).

Beneath this I set up 4 classes with differing priorities and each with a guaranteed minimum bandwidth of 100 kilobits per second each.

#!/bin/sh

DEV=pppoe-adsl
BWMAX=1400kbit

# ensure 32-bit classifier is available
insmod cls_u32
# ensure HTB scheduler is available
insmod sch_htb

echo "Clearing existing root qdisc on $DEV"
tc qdisc del dev $DEV root

echo "Adding root qdisc on $DEV"
tc qdisc add dev $DEV root       handle 1:    htb default 99

echo "Adding top class on $DEV with rate $BWMAX"
tc class add dev $DEV parent 1:  classid 1:1  htb rate $BWMAX ceil $BWMAX burst 6k


# Classes
echo "Creating VoIP class"
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 100kbit ceil $BWMAX burst 6k prio 1

echo "Creating tiny packet class <64 bytes"
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 100kbit ceil $BWMAX burst 6k prio 1

echo "Creating small packet class <256 bytes"
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 100kbit ceil $BWMAX burst 6k prio 3

echo "Creating default class"
tc class add dev $DEV parent 1:1 classid 1:99 htb rate 100kbit ceil $BWMAX burst 6k prio 6


# Filters
echo "Creating VoIP filter to Australian Phone Company only (highest priority traffic)"
tc filter add dev $DEV parent 1: protocol ip prio 2 u32 match ip dst 103.12.10.97/32 flowid 1:10

echo "Creating tiny packet filter <64 bytes (for acknowledgements)"
echo "  allows bottom 6 bits to be anything (2^6 = 64) but all higher bits must be zero"
tc filter add dev $DEV parent 1: protocol ip prio 3 u32 match u16 0x0000 0xffc0 at 2 flowid 1:20

echo "Creating small packet filter <256 bytes (for traffic more likely to be real-time)"
echo "  allows bottom 8 bits to be anything (2^8 = 256) but all higher bits must be zero"
tc filter add dev $DEV parent 1: protocol ip prio 4 u32 match u16 0x0000 0xff00 at 2 flowid 1:30

Viewing the state of the system was straight-forward.

Seeing how many bytes and packets made it through the root qdisc:

# tc -s qdisc show dev $DEV
qdisc htb 1: root refcnt 2 r2q 10 default 99 direct_packets_stat 0 direct_qlen 3
 Sent 20016888 bytes 166952 pkt (dropped 175, overlimits 1496 requeues 0) 
 backlog 0b 0p requeues 0

I could also view the classes to see how many packets had made their way through each one:

# tc -s class show dev $DEV
class htb 1:1 root rate 1400Kbit ceil 1400Kbit burst 6Kb cburst 1599b 
 Sent 20154394 bytes 167785 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 6096 borrowed: 0 giants: 0
 tokens: 544990 ctokens: 139271

class htb 1:10 parent 1:1 prio 1 rate 100Kbit ceil 1400Kbit burst 6Kb cburst 1599b 
 Sent 218765 bytes 394 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 394 borrowed: 0 giants: 0
 tokens: 6248750 ctokens: 40610

class htb 1:20 parent 1:1 prio 1 rate 100Kbit ceil 1400Kbit burst 6Kb cburst 1599b 
 Sent 5800369 bytes 112832 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 109430 borrowed: 3402 giants: 0
 tokens: 7630000 ctokens: 139271

class htb 1:30 parent 1:1 prio 3 rate 100Kbit ceil 1400Kbit burst 6Kb cburst 1599b 
 Sent 4727569 bytes 40204 pkt (dropped 16, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 38041 borrowed: 2163 giants: 0
 tokens: 7586250 ctokens: 136146

class htb 1:99 parent 1:1 prio 6 rate 100Kbit ceil 1400Kbit burst 6Kb cburst 1599b 
 Sent 9407691 bytes 14355 pkt (dropped 159, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 13824 borrowed: 531 giants: 0
 tokens: 6747500 ctokens: 76235

Actually class 1:99 is displayed first.

How to Redirect Stderr From Executable in PowerShell 2.0 Without Line Breaks at Console Width

So you think PowerShell is flexible and useful and you go to redirect output from an external command to a file. You’ll parse this file later. But when you do you are horrified to find line breaks inserted in the middle of lines in the file… at the width of the console in which your PowerShell session was running.

The problem is that PowerShell is so smart that it unhelpfully inserts line breaks in all output at the current console width.

There are a few suggested answers to this including adding a -Width parameter to Out-File, but this doesn’t solve the issue for stderr redirects.

The solution was found in this post. Simply put, run your external command through cmd.exe and redirect from there!

To ensure the redirect operator is passed to cmd.exe escape the angle bracket with a backtick.

cmd.exe /C wget.exe -O - http://www.google.com/ 2`>stderr.log

Installing OpenRA on Xubuntu 14.04

I had to run the following command after downloading the OpenRA deb file:

sudo apt-get install libsdl2-2.0-0 mono-runtime mono-runtime-sgen liblua5.1-0 mono-runtime-common mono-gac mono-4.0-gac libmono-corlib4.5-cil libmono-security4.0-cil cli-common libmono-system4.0-cil libmono-system-core4.0-cil libmono-system-drawing4.0-cil libmono-system-data4.0-cil libmono-system-numerics4.0-cil libmono-system-runtime-serialization4.0-cil libmono-system-xml-linq4.0-cil libmono-posix4.0-cil libmono-data-tds4.0-cil libmono-system-configuration4.0-cil libmono-system-enterpriseservices4.0-cil libmono-system-transactions4.0-cil libmono-system-xml4.0-cil libgdiplus libmono-system-security4.0-cil libmono-i18n4.0-all

Thunar and Ristretto on Xubuntu 14.04 Do Not Render Thumbnails

I was puzzled and searching all over the Internet for an explanation why the file explorer (Thunar) and the image viewer (Ristretto) were not displaying thumbnails for JPEG files. I know they had rendered them before. I tried all sorts of things, deleting local cache (~/.thumbnails/* and ~/.cache/thumbnails/*), ensuring various packages had been installed.

Finally I stumbled across this forum post which gave the necessary clue:

A package called tumbler is needed for thunar to automatically generate thumbnails.

I checked to see that I had tumbler:

~$ dpkg -l |grep tumbler
ii  libtumbler-1-0  0.1.30-1ubuntu1  amd64  library for tumbler, a D-Bus thumbnailing service
ii  tumbler         0.1.30-1ubuntu1  amd64  D-Bus thumbnailing service
ii  tumbler-common  0.1.30-1ubuntu1  all    D-Bus thumbnailing service (common files)

Then I checked to see if a tumbler process was running, and proceeded to kill it:

~$ ps fax |grep tumbler
21322 ?        SNl    0:01          \_ /usr/lib/x86_64-linux-gnu/tumbler-1/tumblerd
~$ kill 21322
~$ ps fax |grep tumbler
~$

or…

~$ killall tumblerd

Now when I opened a thunar file explorer the thumbnails were being rendered, and also rendered in ristretto, too.

Monopoly Deal Sort Order

From a new pack the cards are (bottom face down to top face down):

* (Brown) Old Kent Road
* (Brown) Whitechapel Road
* (Light Blue) Euston Road
* (Light Blue) Pentonville Road
* (Light Blue) The Angel, Islington
* (Purple) Northumberland Avenue
* (Purple) Pall Mall
* (Purple) Whitehall
* (Orange) Bow Street
* (Orange) Marlborough Street
* (Orange) Vine Street
* (Red) Fleet Street
* (Red) Strand
* (Red) Trafalgar Square
* (Yellow) Coventry Street
* (Yellow) Piccadilly
* (Yellow) Leicester Square
* (Green) Bond Street
* (Green) Oxford Street
* (Green) Regent Street
* (Rich Blue) Mayfair
* (Rich Blue) Park Lane
* (Black) Fenchurch St. Station
* (Black) Kings Cross Station
* (Black) Liverpool St. Station
* (Black) Marylebone Station
* (Pale Green) Electric Company
* (Pale Green) Water Works
* (Brown/Light Blue) Property Wild Card
* (Light Blue/Black) Property Wild Card
* (Purple/Orange) Property Wild Card
* (Purple/Orange) Property Wild Card
* (Red/Yellow) Property Wild Card
* (Red/Yellow) Property Wild Card
* (Green/Rich Blue) Property Wild Card
* (Green/Black) Property Wild Card
* (Black/Pale Green) Property Wild Card
* (Rainbow) Property Wild Card
* (Rainbow) Property Wild Card
* Deal Breaker
* Deal Breaker
* Forced Deal
* Forced Deal
* Forced Deal
* Sly Deal
* Sly Deal
* Sly Deal
* Just Say No
* Just Say No
* Just Say No
* Debt Collector
* Debt Collector
* Debt Collector
* It's My Birthday
* It's My Birthday
* It's My Birthday
* Double Rent
* Double Rent
* House
* House
* House
* Hotel
* Hotel
* Pass Go (x10)
* (Brown/Light Blue) Rent
* (Brown/Light Blue) Rent
* (Purple/Orange) Rent
* (Purple/Orange) Rent
* (Red/Yellow) Rent
* (Red/Yellow) Rent
* (Green/Rich Blue) Rent
* (Green/Rich Blue) Rent
* (Black/Pale Green) Rent
* (Black/Pale Green) Rent
* (Rainbow) Rent
* (Rainbow) Rent
* (Rainbow) Rent
* Bank 1M (x6)
* Bank 2M (x5)
* Bank 3M (x3)
* Bank 4M (x3)
* Bank 5M (x2)
* Bank 10M