Saturday, February 2, 2013

Setting up SILK Codec with Asterisk 10/11

Wikipedia on SILK: http://en.wikipedia.org/wiki/SILK
This guide takes you through the setup of SILK codec with Asterisk 11. It also can be used to setup Asterisk 10.
While it should work for other environments, this particular guide was written for
1) Debian
2) Working Asterisk 11 (try this article if you want a how-to)
Why use Skype’s SILK?
Here’s the quick how-to (Parts of this guide was taken from Asterisk Wiki here )
  1. Download the  benchmark tool based on your processor architecture. In my case I am using 64 bit so I downloaded the x86_64. Browse to http://downloads.digium.com/pub/telephony/codec_silk/benchsilk/ for options. Copy the URL and do the wget like below
    # cd /usr/src
    # wget
    http://downloads.digium.com/pub/telephony/codec_silk/benchsilk/x86-64/benchsilk-1.0.0-x86_64
    # chmod +x bench*
    # ./benchsilk-1.0.0-x86_64
  2. After this you will see the recommendation made from the benchmarking tool. Since I was running a VM for writing this, my winner was “generic”, so I headed to this http://downloads.digium.com/pub/telephony/codec_silk/ link, selected my Asterisk version, and selected the processor architecture, which was x86_64, then copied the generic codec url to do wget with
    # wget http://downloads.digium.com/pub/telephony/codec_silk/asterisk-11.0/x86-64/codec_silk-11.0_1.0.0-generic_64.tar.gz
    # tar –zxvf codec_silk*
    # cd codec_silk-11.0_1.0.0-generic_64     (or whatever version of yours directory name)
    # cp codec* /usr/lib/asterisk/modules/
  3. Now put up some configs for codecs.conf
    # nano /etc/asterisk/codecs.conf         (create the file if don’t exist). Paste below all variations this codec
    [silk8]
    type=silk
    samprate=8000
    fec=true
    packetloss_percentage=10
    maxbitrate=20000
    dtx=false

    [silk12]
    type=silk
    samprate=12000
    fec=true
    packetloss_percentage=10
    maxbitrate=25000
    dtx=false

    [silk16]
    type=silk
    samprate=16000
    fec=true
    packetloss_percentage=10
    maxbitrate=30000
    dtx=false

    [silk24]
    type=silk
    samprate=24000
    fec=true
    packetloss_percentage=10
    maxbitrate=40000
    dtx=false
  4. Save and exit
  5. Load the codec
    # asterisk -rx "module load codec_silk.so"
    You should see it return as “Loaded….”
  6. Now, check the translations and codecs
    # asterisk –rx “core show translation”
    # asterisk –rx “core show codecs”
  7. Sometimes, you might need to start and stop asterisk for it to show up in the codec translation table (and for it to work)
  8. On both command executions, you should see in those outputs the words SILK8, SILK12, SILK16, SILK24
  9. Be sure to “allow” this codec for each of your extensions, or sip general settings
    And for each extension, be sure to setup like this
    disallow=all
    allow=silk8 ;;;
    or whatever silk band you fancy, I use the narrowband as its important to use smallest bandwidth
  10. Connect using phones that support SILK, set those phones to only use SILK in its list of codecs based on the frequency you’ve “allowed”, in the case above, 8Khz. Typically, 8Khz band will only use 5-20kbps :)
  11. Checkout this document on the payload. The codecs.conf gives you the ability to tweak for poor network conditions too like on Wifi roamers….
Phones that support SILK in my tests:
  1. CSIPSimple for Android Mobile
  2. Basically anything using the PJSIP stack (which has become my favorite softphone….), e.g. http://microsip.org.ua/
Lots other phone vendors also do support SILK but it will probably come slower: Anyway, the PJSIP MicroSIP, I was making calls clean and flawlessly over Wifi
image

2 comments:

Anonymous said...

Followed your article, thanks for that.
However I am getting:
No compatible codecs, not accepting this offer!

JayWS said...

Put up the output of the following commands;
asterisk –rx “core show translation”
asterisk –rx “core show codecs”

U may have to restart asterisk as the translation table sometimes doesn't get updated.

Also post your sip debug logs in case..