Overriding Outbound Dial Command Options

I’ve previously noted that you can apply time limits to calls going out of your Asterisk box:

http://www.whizzy.org/2011/02/more-asterisk-hints/

using the L(nnn,mmm,yyy) options for DIAL_TRUNK_OPTIONS. But, what if you don’t want to limit the length of calls for a specific trunk?

Well, FreePBX has a context called [macro-dialout-trunk-predial-hook] which lets you jump in at the very last moment and override any settings you like, which is perfect for this sort of thing.

I got the idea from here:

http://www.freepbx.org/book/export/html/5893

I’ve added this to extensions_custom.conf:

[macro-dialout-trunk-predial-hook]
 exten => s,1,NoOp(Trunk ${OUT_${DIAL_TRUNK}} selected)
 exten => s,n,Gotoif($["${OUT_${DIAL_TRUNK}}" != "SIP/TRUNK_NAME"]?skip)
 exten => s,n,NoOp(Setting DIAL_TRUNK_OPTIONS to Ww)
 exten => s,n,Set(DIAL_TRUNK_OPTIONS="Ww")
 exten => s,n(skip),MacroExit()

Which tests the name of the trunk which is to be used and explicitly sets DIAL_TRUNK_OPTIONS if it matches, otherwise nothing happens. This is a very powerful feature and my extremely crude hack doesn’t do it justice. I wanted to make a note of this before I forgot.

A better way might be to look at the dial prefix? I’ll investigate that option, but for now that will have to do.

NOOP scheduler – not worth it for SSD

I’ve got a new Thinkpad X220i with a 128GB SSD.

Reading around the internet I found a lot of stuff about squeezing a bit more throughput from your drive.

I did a couple of benchmarks in Ubuntu 11.04:

  • Adding noatime,discard to /etc/fstab

Result:  No change.  Not better or worse, but in theory the “discard” will help in the long term

Decision:  Switch this on.

  • Setting the scheduler to noop in /etc/rc.local

Result: Average read rate increased by 2MB/s but Average access time went from 0.2ms to 0.3 ms.  In itself that’s not a real problem, but the graphs show a different picture.

Without NOOP

Note the scale on the right hand side.

 

 

With NOOP

The access speed is all over the place.

Decision:  Switch this off

 

I’d be interested in hearing if your experience differs, but it seems to me that “Doing nothing” is a valid choice.  Ubuntu, out of the box, doesn’t really require any fettling in order to get the best from your SSD.

 

 

TCP sessions causing lag

I like to play Call Of Duty online on this year’s some of the best gaming monitors. I find it’s a really good way to get angry and frustrated at inanimate objects. I also run a Bit Torrent client on my network.

I don’t suck at MW2 and I’m not too bad at Black Ops either, but on the PS3 Black Ops has been very unstable to the point of hanging the console.

Anyway, what really gets me cross is Lag. You can tell a match is going to be laggy the second the game opens. It feels as if you’re running through treacle. “GET A MOVE ON” I scream. And then it starts; you get shot while behind brick walls, your shots fail to connect even though “IT WAS CLEARLY A HEADSHOT WHY WONT YOU JUST DIE?”. And so on. You know what I’m talking about.

Originally I had a written a script to ping the PS3 and when it came online and tell Transmission to pause all the Torrents. When the PS3 went offline again it would start them. I thought this would be enough, but it isn’t. Even with Transmission paused and the bandwidth limited to zero kBps it still maintains a connection to other peers.

While this isn’t a significant amount of traffic over the WAN – it really does cause lag. Presumably having something like 1000 NAT sessions in the memory of my router is a bit of a stretch, so now I simply kill Transmission when the PS3 comes online. It takes a few minutes for the sessions to get pruned but it’s made a noticeable difference to the quality of my matches.

Of course, you’re still at the mercy of the internet connection of whoever hosts the match – but that’s beyond your control.

Trimming Freesat Channels In MythTV

There are loads and loads of free-to-air channels available on the Astra 28 constellation, the vast majority of which I do not watch.

So to make things a bit easier for me after a full re-scan, I’ve put together a list of the channels I don’t watch and with a tiny bit of SQL I can trim them from my channel list.

To make things a bit easier for you here is a SQL dump of my “unwatched channels” list:

unwatched_channels.sql

And here is the SQL to trim these from your channel list:

update channel set visible=0,useonairguide=0 where name in (select name from unwatched_channels)

You’ll probably want to edit that list yourself to remove and add the channels as you prefer. Generally speaking, my list trims:

  • Regional variations
  • Specialist interest
  • Shopping
  • Games and other text based services

I’ll update this list occasionally, this page will always have my most up to date information.

  • UPDATE: 6 Sept 11.  Refreshed channel list
  • UPDATE: 8 Oct 11. Refreshed channel list
  • UPDATE: 14 Dec 2011.  Refreshed channel list
  • UPDATE: 4 Aug 2012.  Refreshed channel list
  • UPDATE: 29 Dec 2013.  New list of channel IDs available here: unwatched_by_chanid.  Add a new table and import that CSV file.  Then do a “update channel set visible=0 where chanid in (select chanid from <your new table>”

More Asterisk hints

Wow – a day of fixing loads of niggling little Asterisk problems!

  • Max duration

My calling plan gives me unlimited free calls as long as those calls are under an hour in duration. Pretty standard BT stuff. If you do make a call over an hour you don’t just get charged for that bit of the call over the hour, oh no, you get charged for the whole call.
Anyway – we have the technology to defeat them!

In FreePBX under General Settings change your Asterisk Outbound Dial command options to include:

L(3360000,3240000,10000)

which will drop the call after 3360000ms (56 minutes) and should alert you at 3240000ms.

  • Courtesy Tone

The above works very well and drops the calls, but without a bit of extra magic you don’t get the warning in your ear – it just drops the call. To enable the warning tones etc edit this:

/etc/asterisk/features_general_custom.conf

and add

courtesytone=beep

substituting “beep” for what ever noise you want to hear.

  • Call Recording

By also adding:

Ww

to the Dial command options in #1 you can press *1 when you’re in a call to start recording.  It plays the courtesy tone to both parties though.

g729 in Asterisk

I run Asterisk 1.8 at home for my own amusement.  I’ve just got a SIP trunk running again to SIPGate which had stopped running for some reason.  I’d set the DID for the SIPGate number to check for faxes and then, if it’s not a fax, go to my MOH application, but for some reason it didn’t work.

I also couldn’t access voicemail from the SIPGate trunk either, but I could get it to work with a phone connected to an ATA.

I had a look in the logs:

channel.c: Unable to find a codec translation path from 0x100 (g729) to 0x40 (slin)

Since slin is, I think, the Asterisk native format this is quite bad.  My assumption is that SIPGate sends through G.729 encoded audio regardless of whether you want it to or not (as configured in your allow/disallow lines for the SIP trunk PEER).

G729 from SIPGate works to the ATA because the ATA supports G729 and G729 to G729 pass-through works without any extra requirements from Asterisk.

So – in order to get SIPGate to Asterisk apps working again I installed the G729 codec binaries from here:

http://asterisk.hosting.lv/

and restarted Asterisk.  Now a:

         core show translations

shows I can convert between G729 and loads of other codecs.