OpenWrt Forum Archive

Topic: Asterisk on OpenWRT

The content of this topic has been archived between 31 Mar 2018 and 1 Apr 2018. Unfortunately there are posts – most likely complete pages – missing.

Cletus wrote:

Enzo,

Intermittent but frequent segfaults when a remote DUNDi peer performs a query or lookup to the OpenWRT-Asterisk box.

For example:
dundi query <EID>@<dundi-context>
or
dundi lookup 12145551212@<dundi-context>

occasionaly I will get a response, but for the most part it just segfaults. 

This is on OpenWRT RC3 using Asterisk from Brian Capouch repository.  Specifically
http://12.176.248.4/ipkg/asterisk-cvs_1.0.36_mipsel.ipk

cletus

I couldn't say: at the moment mine (that I got from http://tracker.openwrt.org/packages/show.php?id=3849 ) is loaded but doesn't do anything because I haven't configured it.  However, is appears to be alive:

OpenWrt*CLI> dundi show trans
Remote                 Src   Dst   Tx  Rx  Ack
64.215.96.114   : 4520 07391 00000 001 000 000
OpenWrt*CLI> dundi lookup 12145551212
DUNDi lookup returned no results.
DUNDi lookup completed in 8 ms
OpenWrt*CLI>

Enzo

Enzo,
Yeah, the module (pbx_dundi.so) starts fine and will sync with other DUNDi peers defined in dundi.conf, but asterisk segfaults if one of the peers performs a DUNDi query to it.

frink*CLI> dundi show peers 
EID                  Host                Model      AvgTime  Status         
00:12:1f:34:da:23    11.111.101.12   (S) Symmetric  Unavail  OK (35 ms)     
00:23:27:c5:5f:16    22.22.222.122   (S) Symmetric  Unavail  Unmonitored    
2 dundi peers [1 online, 0 offline, 1 unmonitored]

I tried it on a couple of x86 boxes this afternoon and am not seeing the problem..

I someone of you great developers is trying to port asterisk 1.2?

EDIT: I wrote a long message asking for advices. I'm deleting it beacouse I noticed only now that it was in the developer forum.

Cheers

(Last edited by Wallace78 on 18 Dec 2005, 11:38)

I have a strange problem that I don't know how to debug.

My small little cuties are RC4+Freifunk+DiffServ+Asterisk (I'm building a complete package to share it; I'm shy of my rude code...just willing to beautify it); everything works fine excepted one thing.
Asterisk at boot starts but outbound proxies are not registered.
If I remove the startup script and I start it manually, it works fine; also, if I restart it after boot, it works fine.
When half-working, users can register and can call each other; only peers can't be registered and If I issue a "sip show registry" in the CLI, I get Unregistered state for every proxy.
In the CLI appear messages about peers registration timing out.

Same behaviour for 1.0.7 in experimental repository and 1.0.9 in Nico's test repository (I'm using last one beacouse of some SIP bugs that 1.0.7 used to have); I couldn't test the latest from the french guy (1.0.36...) beacouse I couldn't find the proper libssl for it...

Other weirdness is the "restart" command in the CLI: it completeley hangs asterisk! CLI doesn't disconnect but the server doesen't answer to any command any more; If I exit the CLI, then I cannot reconnect and even a stop doesn't work (I've to kill it and restart again).

All these bugs are fully replicable. Any clue?

Regards

Wallace

EDIT: I also tried to add some sleeps around the scripts, but nothing changed. I even don't know where to look at to dig in the hole and find the bug.

EDIT2: Delaying for more than 60 secs it start properly at boot. It seems that the problem appear if asterisk starts (and try to register on internet proxies) before the "mesh handshaking time" (propagating default route) has finished...

(Last edited by Wallace78 on 18 Dec 2005, 23:18)

Hi Wallace,

I have a possible work-around on the registry problem, although it is also a bit messy.  I have problems with IAX registrations and sudden death of Asterisk when call-waiting occurrs.  I restart asterisk with the following script called by cron- which runs every 5 minutes.  It leaves behind a file in the /tmp dir which shows me when stuff has died, or wasn't registered properly.  Change the "IAX show registry" below, to sip show registry, or whatever works at the command line. 

#!/bin/ash
mypeername="peername"  #peer you want to maintain registraiton to
for peername in $mypeername
do
otpt=`/usr/sbin/asterisk -rx 'iax2 show registry' |/bin/grep $mypeername |/bin/grep Registered`
sleep 3
if [ -n "$otpt" ]; then
#echo $otpt | mail -s "Asterisk peer: \"`echo -n $peername `\" isnt registered." "email@yourdomain.com"
     echo  $otpt >/tmp/asteriskstatus
#     echo -n ' Peer '
#     echo -n $mypeername
#     echo ' is registered!'
else
     /bin/date >>/tmp/asteriskdown
#     echo "$mypeername is NOT registered"
#     echo "KILLING ASTERISK"
        /usr/bin/killall -9 asterisk
#       echo "Sleeping 5 Seconds"
        sleep 5
#       echo "restarting asterisk"
        /etc/init.d/S60asterisk start
fi
#echo -n $peername
#echo ' done'

done

note: you can take out comments as appropriate for testing this from the command line before installing it...

I would be very interested if you have a smaller build of asterisk with no voicemail and extra features in your own ipk file with call-waiting working.  Have you tested call waiting yet?

Tom

PS: the problem itself sounds like a bug in the sip channel...

(Last edited by nicheware on 20 Dec 2005, 06:16)

nicheware wrote:

I have a possible work-around on the registry problem, although it is also a bit messy.

Thanks Tom! The work-around is fine, but surely is not the definitive solution beacouse it restart asterisk if only one proxy is not registered.
What does it happen if, for example, the proxy doesn't register for a voip service failure lasting a few hours? The pbx would restart every X minutes making any telephone call bumping every X minutes...
I just added this check every 10 minutes (togheter with the update of the external IP that already does); but I want to investigate further...

nicheware wrote:

I would be very interested if you have a smaller build of asterisk with no voicemail and extra features in your own ipk file with call-waiting working.  Have you tested call waiting yet?

I'm packaging everything inside the dir custom files dir of the ImageBuilder (RC4); I didn't build any package yet; only firmware binary images.
And I'm mixing everything up in that dir, binaries and configs: modded freifunk (1.0.7) packages' files, qos based on diffserv (ingress+htb+red+gred+sfq) and finally Asterisk.
About Asterisk, starting from 1.0.9 in Nico's repository, I just did a "show modules" from CLI, deleted all the modules not loaded by default and taken the needed ones; to have minimal working installation. That's all.
I'm working on the dial plan now, to add the needed app_*.so modules; I also removed app_sayunixtime and app_milliwatt (are they needed???). Do you want an ipkg with this minimal installation?

nicheware wrote:

PS: the problem itself sounds like a bug in the sip channel...

I'm not sure of it; do have you the same problem on iax or you use the script for other reasons?
Beacouse if you have the problem, it is not a sip channel bug; if not, it could be!
It seems that, if the first registration goes bad, it never register again and start complaining in the CLI for registration time outs...

ciao

Michele

Michele,

You can modify the script to do a reload instead of a full kill of asterisk... replace that part with:

dummy=`/usr/sbin/asterisk -rx 'sip reload' ` #<take out whitespace before backquote
or

dummy=`/usr/sbin/asterisk -rx 'reload'`

That would be a bit less drastic than starting asterisk entirely. 

EDIT: Other questions...

Wallace78 wrote:

I'm working on the dial plan now, to add the needed app_*.so modules; I also removed app_sayunixtime and app_milliwatt (are they needed???).
Do you want an ipkg with this minimal installation?

Depending on what codecs you want to use, if you want voicemail, and stripping out other features it is possible to get an asterisk build running with only the following modules loaded by force in modules.conf...  here is one of mine:

[modules]
autoload=no

load=res_features.so ; Call Parking Resource
load=chan_iax2.so ; Inter Asterisk eXchange (Ver 2)
load=chan_local.so ; Local Proxy Channel
load=chan_sip.so ; Session Initiation Protocol (SIP)
load=codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translat
load=codec_ulaw.so ; Mu-law Coder/Decoder
load=format_gsm.so ; Raw GSM data
load=format_pcm.so ; Raw uLaw 8khz Audio support (PCM)
load=format_wav.so ; Microsoft WAV format (8000hz Signed Line
load=format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM)
load=app_dial.so ; Dialing Application
load=app_echo.so ; Simple Echo Application
load=app_macro.so ; Extension Macros
load=app_milliwatt.so ; Digital Milliwatt (mu-law) Test Applicat
load=app_playback.so ; Trivial Playback Application
load=app_sayunixtime.so ; Say time
load=app_transfer.so ; Transfer
load=app_verbose.so ; Send verbose output
load=pbx_config.so ; Text Extension Configuration
[global]

I believe some of those may be unneeded for your installation.  Milliwat I believe is required if you're using the ULAW codec- not sure on that.  I use it across the lan, but then send everying IAX to the outside world.

Wallace78 wrote:

I'm not sure of it; do have you the same problem on iax or you use the script for other reasons?
Beacouse if you have the problem, it is not a sip channel bug; if not, it could be!
It seems that, if the first registration goes bad, it never register again and start complaining in the CLI for registration time outs...

I have clients that hang when a call waiting beep comes in.  Most clients stay registered but due to occasional IP address changes on the clients sometimes they become dissassociated with their iax registry.  I've experienced the same issue you're having at the cli prompt with restart gracefully or restart now not working - thus the killall approach in the original script.  Sometimes there have been threads hanging there when I tried to start asterisk after a crash.  It's simply not a stable application yet.  I've tried it on approximately a dozen routers now - 6 WRT54G and 6 Motorola WR850G.  Same problems on all of them.

I've been using asterisk for more than 3 years now, but, mostly on full X86 machines running usually as dedicated firewalls for my customers.  Adding these WRT boxes to my network would put me in a nice position to be able to offer a VOIP solution that utilizes existing infrastructure and adds the wireless feature.  I handle voicemail for about 30 users extensions on a dedicated machine in the US anyway- so my main goal is to get as tiny and stable as possible build with the bugs worked out.  People here are working in the wrong direction in my opinion- greatly complicating things with asterisk.  It needs to be minimal- with the features hosted on a machine with more horsepower, floating point, and storage on a hard drive.  Whay rewrite voicemail messages in three formats onto either volatile memory or flash?  (most people don't know about the three formats - even if you select only one the message is still written in three files)    I'm using ULAW on my phones and sending GSM out over IAX- so I've removed a lot of files having to do with unused codecs. 

Tom

(Last edited by nicheware on 20 Dec 2005, 06:08)

nicheware wrote:

People here are working in the wrong direction in my opinion- greatly complicating things with asterisk.  It needs to be minimal- with the features hosted on a machine with more horsepower, floating point, and storage on a hard drive.  Whay rewrite voicemail messages in three formats onto either volatile memory or flash?  (most people don't know about the three formats - even if you select only one the message is still written in three files)    I'm using ULAW on my phones and sending GSM out over IAX- so I've removed a lot of files having to do with unused codecs.

I couldn't agree with you more.  The core of Asterisk on WRT needs to be stable first.  With the exception of using an ASUS 500dlx and an USB hard disk, voice mail really doesn't belong on an small flash/memory WRT.  Use NFS or SMB to put voice mail on a hard disk based storage. 

You can reduce the number of formats Asterisk writes with the format option in voicemail.conf.  I keep all my voice mail stored in gsm only since all outside connections are gsm over IAX2.  I can't say about Asterisk v. 1.0.7 as in White Russian RC4, but in 1.2.1 on my production boxes only gsm is getting written to the HD. 

The other big concern are the files that Asterisk writes to very frequently.  ast.db in particular.  Keeping that on the flash system is bound to cause problems with the flash after a relatively short life in production.  A cron job to copy this file from the ram disk to flash on a semi-regular basis (maybe once or twice a day) is definitely something to consider.   

I have Asterisk running in production on one WRT54GS now for several months with White Russian RC2.  All it is doing is routing calls from a sip phone (ulaw) to IAX2 (gsm).  This has been very stable.  But I'm not using many features of Asterisk at all on this router.  The big benefit of this installation is the added jitterbuffer and gsm compression that the SIP phone connecting to an Internet based asterisk box would not accomplish.  Sound quality with Asterisk on the WRT was greatly improved over connecting the SIP phone directly to the Asterisk box on the net.

Another insteresting implementation of Asterisk on a relatively in-expensive device.  Is on the gumstix:

http://the-edge.blogspot.com/2005/10/wo … ricon.html

http://www.gumstix.org

http://www.gumstix.com

Chip

(Last edited by lschweiss on 21 Dec 2005, 17:01)

lschweiss wrote:

The other big concern are the files that Asterisk writes to very frequently.  ast.db in particular.  Keeping that on the flash system is bound to cause problems with the flash after a relatively short life in production.  A cron job to copy this file from the ram disk to flash on a semi-regular basis (maybe once or twice a day) is definitely something to consider.

You may try my startup script, which replaces the default /etc/init.d/asterisk (symlinked by /etc/init.d/S60asterisk ).  Besides relocating astdb to RAM, and back to flash at "stop" time, it runs asterisk as non-root for additional security. I'm attaching its latest version, as older incarnations suffered from bugs:

#!/bin/sh

#DEFAULT=/etc/default/asterisk
#OPTIONS=""
OPTIONS="-U asterisk -G asterisk"
#[ -f $DEFAULT ] && . $DEFAULT
#[ "$ENABLE_ASTERISK" = "yes" ] || exit 0

echolog() {
  echo "$@"
  logger -p user.info "$@"
}

# do a "chown -R" only if some file in the dir is owned by root
cond_chown_r() { # user file-or-dir
  MATCHLIST=$(ls -ld $2 | grep 'root')
  MATCHLIST=$MATCHLIST$(ls -lR $2 | grep 'root')
  if [ ! -z "$MATCHLIST" ] ; then
    chown -R $1 $2
    echo chown -R $1 $2
  fi
}

# replace symlinks to /rom/... with actual copies
deromize() {
  if [ -L $1 ] ; then
    POINTEDFILE="$(ls -l /etc/group |  cut -d '>' -f 2-)"
    rm $1
    cp $POINTEDFILE $1
  fi
}



start() {

  PIDLIST=$(pidof asterisk)
  if [ ! -z "$PIDLIST" -a "$PIDLIST" != "$$" ] ; then
   echolog "Asterisk is already running!"
   return 1
  fi

  [ -d /var/run ] || mkdir -p /var/run
  [ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
  [ -d /var/log/asterisk/cdr-csv ] || mkdir -p /var/log/asterisk/cdr-csv
  [ -f /var/log/asterisk/cdr-csv/Master.csv ] || touch /var/log/asterisk/cdr-csv/Master.csv
  [ -d /var/log/asterisk/cdr-custom ] || mkdir -p /var/log/asterisk/cdr-custom
  [ -f /var/log/asterisk/cdr-custom/Master.csv ] || touch /var/log/asterisk/cdr-custom/Master.csv
  [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
  [ -d /var/spool/asterisk/voicemail ] || mkdir -p /var/spool/asterisk/voicemail

  deromize /etc/group
  # create the group "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/group)" ] ; then
    MATCHING="$(grep ':5060:' /etc/group)"
    if [ -z "$MATCHING" ] ; then
      echo "asterisk:x:5060:" >> /etc/group
    else
      echo "** error in ${0} - GID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi

  deromize /etc/passwd
  # create the user "asterisk", unless already there
  if [ -z "$(grep '^asterisk:' /etc/passwd)" ] ; then
    MATCHING="$(grep ':5060:' /etc/passwd)"
    if [ -z "$MATCHING" ] ; then
      echo "asterisk:*:5060:5060:asterisk:/tmp:/bin/ash" >> /etc/passwd
    else
      echo "** error in ${0} - UID 5060 already in use by others:"
      echo $MATCHING
      exit 1
    fi
  fi
  # change ownership of all relevant directories
  chmod 711 /var/spool
  cond_chown_r asterisk.asterisk /var/log/asterisk/cdr-csv
  cond_chown_r asterisk.asterisk /var/log/asterisk
  cond_chown_r asterisk.asterisk /var/spool/asterisk
  cond_chown_r asterisk.asterisk /etc/asterisk
  cond_chown_r asterisk.asterisk /usr/lib/asterisk
  #obsolete: use OPTIONS="-U asterisk -G asterisk"
  # cond_chown_r asterisk.asterisk /usr/sbin/asterisk
  #
  # the following hack will stay until autodial.ctl and
  # asterisk.ctl will be moved to a directory writable
  # by Asterisk (such as /var/spool/asterisk)
  chgrp asterisk /var/run
  chmod 775 /var/run
  [ -e /var/run/autodial.ctl ] || chown asterisk.asterisk /var/run/autodial.ctl
  [ -e /var/run/asterisk.ctl ] || chown asterisk.asterisk /var/run/asterisk.ctl
  #
  # make the binary suid, so it won't run as root
  #obsolete: use OPTIONS="-U asterisk -G asterisk"
  #chmod +s /usr/sbin/asterisk

  while [ -z "$(route | grep '0\.0\.0\.0')" ] ; do
    echolog "waiting for default route to exist..."
    sleep 2
  done

  # if astdb n /usr/.... is not a symlink...
  if [ ! -L /usr/lib/asterisk/astdb ] ; then
    # if it exists and it's a file, move it to /var/....
    if [ -f /usr/lib/asterisk/astdb ] ; then
      mv /usr/lib/asterisk/astdb /var/spool/asterisk/astdb
    fi
    # ...and anyway, put here a symlink to /var/....
    ln -s /var/spool/asterisk/astdb /usr/lib/asterisk/astdb
  fi

  /usr/sbin/asterisk $OPTIONS
  logger -p user.info "Asterisk started..."

}

stop() {

  PIDLIST=$(pidof asterisk)
  if [ -z "$PIDLIST" -o "$PIDLIST" = "$$" ] ; then
   echolog "Asterisk is already stopped!"
   return 1
  fi

  [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1

  ICNT=0
  for ICNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
    # for max 15 s, see if some process is still alive
    PIDLIST=$(pidof asterisk)
    if [ -z "$PIDLIST" -o "$PIDLIST" = "$$" ] ; then
      break
    fi
    sleep 1
  done
  # if still alive after more than 5 s, use "kill -9"
  if [ ! -z "$PIDLIST" -a "$PIDLIST" != "$$" ] ; then
    echolog "killing stubborn processes $PIDLIST"
    for GONER in $PIDLIST; do kill -9 $GONER; done
  fi
  # save astdb to a flash-mapped directory
  if [ -L /usr/lib/asterisk/astdb ] ; then
    rm /usr/lib/asterisk/astdb
  fi
  if [ -f /var/spool/asterisk/astdb ] ; then
    mv -f /var/spool/asterisk/astdb /usr/lib/asterisk/astdb
  fi
  logger -p user.info "Asterisk stopped..."

}


case $1 in
 start)
  start
  ;;
 stop)
  stop
  ;;
 restart)
  stop
  start
  ;;
 *)
  echo "usage: $0 (start|stop|restart)"
  exit 1
esac

exit $?

Enzo

(Last edited by enzo on 26 Jun 2006, 08:12)

enzo wrote:

You may try my startup script, which replaces the default /etc/init.d/asterisk (symlinked by /etc/init.d/S60asterisk ).  Besides relocating astdb to RAM, and back to flash at "stop" time, it runs asterisk as non-root for additional security. I'm attaching its latest version, as older incarnations suffered from bugs:
Enzo

I took your good script and integrated into mine (astdb trick; delayed startup, etc); I use a SIP-only stripped down 1.0.7 asterisk installation; configuration files are created at boot time in /var/etc/asterisk so that I can get configuration (extensions, SIP phone lines, etc) from nvram (that is then updated by web interface) and build custom conf...
In this environment I made a link once:

ln -s /usr/lib/asterisk/astdb /var/etc/asterisk/astdb

...so that there's no need to copy astdb and put it back in place.

I'm building a wireless mesh network with voice capabilities in my small town; as soon as I reach my ver. 1.0.0, I'll release my code... as while I am writing, the scripts/code are soo messy that I'm even having troubles to remember what I did... that's hemp fault...

ciao

Wallace

Wallace78 wrote:

In this environment I made a link once:

ln -s /usr/lib/asterisk/astdb /var/etc/asterisk/astdb

...so that there's no need to copy astdb and put it back in place.

But in that case if you power off the device the content of astdb is lost. Normally that's no big deal, because by default Asterisk puts there only registration information, but sometimes other apps could save there important data (e.g., call forwarding extensions) intended to be persistent.

Wallace78 wrote:

I'm building a wireless mesh network with voice capabilities in my small town; as soon as I reach my ver. 1.0.0, I'll release my code... as while I am writing, the scripts/code are soo messy that I'm even having troubles to remember what I did... that's hemp fault...

Have you tried Freifunk, or some other similar system ported to OpenWRT?

Happy New Year,

Enzo

Hi,

I just finished 2 little PDF-How-Tos ( a 3rd will follow soon):
The first is about setting the caller-id based on a flat-file database (basically a simple shell AGI-script), the second is about a little SOAP-cgi-script to initiate calls. They are linked from the site
http://www.voiscout.de/howto.html (although the site is in German, the How-Tos are in English).

The 3rd How-To will be about transforming the cdr-file into a .ics-calendar file. This is the format of the Mozilla calendar and Apples iCal. So you can subscribe to your calls ....

Please let me know, how to improve these how-tos.

doerner: You should enter this in the wiki at voip-info.org as click-to-dial solution...

enzo wrote:

But in that case if you power off the device the content of astdb is lost. Normally that's no big deal, because by default Asterisk puts there only registration information, but sometimes other apps could save there important data (e.g., call forwarding extensions) intended to be persistent.

At the moment the dialplan consist in replicating the mesh IP numbering plan for "P2P telephony" (from node to node) and outbound proxy registration (voip phone lines); it is very simple and uses only dial and playback applications... so... I still didn't find any problem in loosing astdb. Moreover WRTs have an average of 7 days uptime, so the astdb file doesn't get lost very often... surely it is not a big deal, but works for me smile
A new entry in our group it is going to develop the voip further; I simply hadn't time to work on it properly.

enzo wrote:

Have you tried Freifunk, or some other similar system ported to OpenWRT?

I tried Freifunk but it used to have two problems: a) performance problems (packet loss,low troughput); b) it couldn't run software from current OpenWrt distribution.
So I got binaries (olsrd, its modules, rdate, etc), webif and startup scripts from Freifunk ipkgs; then placed them on RC4 and debugged them. Then added a DiffServ domain for QoS purposes, Asterisk (nat traversal "private cable network<-->mesh"), Siproxd on edge routers (nat traversal "mesh<-->internet") and a few pages to configure/check QoS and VOIP confs/infos.
The result is a rock solid mesh counting 11 nodes (and more) with 1280/640 kbit/s on every link with voice capabilities. And everything in the mesh works as intended to be; the only problem is on the internet side as we don't have enough internet bandwidth (upstream is 256kbit/s) so telephone calls outside the mesh aren't always 100% clear. Moreover to make VOIP work, I had to setup a very low ceil on qdiscs limiting bw to 1280/640; but I'm thinking about a dynamic ceil based on iptraf hourly tests... let's see...

At the moment I'm planning to do it from scratch to get rid of Freifunk webif and use the OpenWrt one... the Freifunk web interface is very nice and has a lot of smart features, but I think it is better to merge its features to the OpenWrt one, now that one exists.

I'm also thinking on going from ad-hoc to WDS mode; a sort of "dynamic WDS". I already did it a few months ago but the other guys were unhappy of performances (about 8mbit/s on every link; but at that time we used to have a bridged WDS that had 18-20mbit/s on every link... before "hidden node" appeared).
This beacouse of two main problems we have now: a) not enough bandwidth, b) no encryption (only mac filters with iptables to avoid unknown users).

ciao

Wallace

New AGI-less replacement for LCDial.sh!

As I have recently posted to http://www.voip-info.org/wiki/index.php … I%20script , the "Least Cost Dial" AGI script LCDial.sh has now a replacement that only uses dialplan features (no AGI anymore). Needless to say, it's much faster... LCDC, the "Least Cost Dialplan Compiler", is a shell script that produces a fragment of dialplan that can be #include'd in extensions.conf and used by invoking a macro rather than AGI(LCDial.sh....). IPKG package and code/doc for a quick inspection are available from link on the wiki page mentioned above.

Enzo

Hi. I have an ASUS WL-HDD 2.5 running OpenWRT WhiteRussian RC4 and asterisk 1.0.7 (from the latest stable package) for some time now. After a lot of fuss (http://forum.openwrt.org/viewtopic.php?pid=23566) I got the ASUS to talk to a USB ISDN adapter, so I am now happily routing calls from ISDN to my 2 Linksys PAP2-NA's (4 SIP lines). I'd like to share my findings here and ask for some advice from the asterisk gurus...

First of all, I use a very small modules.conf:

  [modules]
  autoload = no
  load => res_features.so ; Call Parking Resource
  load => res_musiconhold.so ; Music On Hold Resource
  load => chan_sip.so ; Session Initiation Protocol (SIP)
  load => chan_modem.so
  load => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder
  load => codec_alaw.so ; A-law Coder/Decoder
  load => codec_ulaw.so ; Mu-law Coder/Decoder
  load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM)
  load => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support
  load => format_sln.so ; Raw Signed Linear Audio support (SLN)
  load => app_dial.so ; Dialing Application
  load => app_echo.so ; Simple Echo Application
  load => app_macro.so ; Extension Macros
  load => app_playback.so ; Trivial Playback Application
  load => app_transfer.so ; Transfer
  load => pbx_config.so ; Text Extension Configuration
  [global]                                               
  chan_modem.so=yes

In order to use chan_modem I had to disable any dtmf detection. If asterisk does the dtmf detection the system is rendered unusable and if i4l does the dtmf detection I hear tones when someone speaks too loud on the phone. So, I just set dtmfmode=none in modem.conf.

The WL-HDD has a hard disk, so I installed everything related to asterisk there. Also, because I want the system to stay quiet at nights, I made a package with hdparm and shut down the disk after it's idle for 5 minutes. The only thing that remains in memory is /var/spool/asterisk. For some wierd reason even if I link a subfolder of /var/spool/asterisk (like /var/spool/asterisk/voicemail) to a folder on the disk, asterisk will not let the disk to spin down - the disk will immediately restart. So, at least for now, I just don't use voicemail.

To implement MOH, I converted my mp3's to raw and use a "rawplayer" binary:

#!/bin/sh

while [ 1 ]; do
        for name in $@; do
                cat $name || exit;
        done
done

My first dissapointment is that the system can not handle the loading of res_indications.so. I need that module, because when I transfer a line the caller can not hear the extension ringing. There is silence until the new callee picks up the phone. Is there any other way to implement this? If I load the module, the caller can hear the line ring, but the sound quality is awful - unacceptable.

What's more important is that after some hours of usage, I have no outgoing sound on incoming calls. When somebody calls, asterisk rings the phones ok, I can pickup the line and listen, but they can not hear me... Restarting asterisk does not seem to help, so I believe that maybe this has to do with the USB ISDN driver. Restarting the system solves the problem. Could this be related to asterisk?

I wish I could run linux 2.6 on this thing and use the mISDN driver... smile

Antony

antony wrote:

[...]
In order to use chan_modem I had to disable any dtmf detection. If asterisk does the dtmf detection the system is rendered unusable and if i4l does the dtmf detection I hear tones when someone speaks too loud on the phone. So, I just set dtmfmode=none in modem.conf.

I suspect that this has the same cause as the inability to use "dtmfmode=inband" in sip.conf, and that both depend of insufficient CPU horsepower to run the DSP code in dsp.c . When I enable "dtmfmode=inband" in sip.conf, the speech becomes sl-o-ow a-and stu-u-tte-ri-ing....

antony wrote:

The WL-HDD has a hard disk, so I installed everything related to asterisk there. Also, because I want the system to stay quiet at nights, I made a package with hdparm and shut down the disk after it's idle for 5 minutes. The only thing that remains in memory is /var/spool/asterisk. For some wierd reason even if I link a subfolder of /var/spool/asterisk (like /var/spool/asterisk/voicemail) to a folder on the disk, asterisk will not let the disk to spin down - the disk will immediately restart. So, at least for now, I just don't use voicemail.

Perhaps Asterisk consults the directory periodically. This for sure happens with /var/spool/asterisk/outgoing/ (to see if there are new callfiles).

Have you considered using a USB flashdisk in place of the HDD? A while ago I thought about buying a WL-HDD and attach an USB hub to get both comfortable disk space and Bluetooth I/O, but I was unsure if it would have worked.

antony wrote:

[...]
My first dissapointment is that the system can not handle the loading of res_indications.so. I need that module, because when I transfer a line the caller can not hear the extension ringing. There is silence until the new callee picks up the phone. Is there any other way to implement this? If I load the module, the caller can hear the line ring, but the sound quality is awful - unacceptable.

Low and stuttering, right? Perhaps, again an issue of weakness in DSP code.

antony wrote:

What's more important is that after some hours of usage, I have no outgoing sound on incoming calls. When somebody calls, asterisk rings the phones ok, I can pickup the line and listen, but they can not hear me... Restarting asterisk does not seem to help, so I believe that maybe this has to do with the USB ISDN driver. Restarting the system solves the problem. Could this be related to asterisk?

I've never noticed this in my non-ISDN setup (only SIP + IAX). Could it perhaps due to some NAT issues?

Enzo

enzo wrote:

I suspect that this has the same cause as the inability to use "dtmfmode=inband" in sip.conf, and that both depend of insufficient CPU horsepower to run the DSP code in dsp.c . When I enable "dtmfmode=inband" in sip.conf, the speech becomes sl-o-ow a-and stu-u-tte-ri-ing....

That's exactly the case with chan_modem too. You couldn't have described it better... Poor CPU horsepower leads to stuttering sound.

enzo wrote:

Perhaps Asterisk consults the directory periodically. This for sure happens with /var/spool/asterisk/outgoing/ (to see if there are new callfiles).

The wierd thing is that the problem persists even when *only* /var/spool/asterisk/voicemail is on the disk (/var/spool/asterisk is in /tmp - RAM) and with the voicemail modules not loaded! I guess I should do an strace on that and try to find out what really happens.

enzo wrote:

Have you considered using a USB flashdisk in place of the HDD? A while ago I thought about buying a WL-HDD and attach an USB hub to get both comfortable disk space and Bluetooth I/O, but I was unsure if it would have worked.

My initial setup was an ASUS WL-500g with a USB hub, a USB flash stick and the USB ISDN modem. I bought the WL-HDD so I could have it all in one nice little package (I also had an old 2.5" disk laying around).

enzo wrote:

I've never noticed this in my non-ISDN setup (only SIP + IAX). Could it perhaps due to some NAT issues?

I don't use NAT anywhere. I just have two phone lines coming in from chan_modem and 4 SIP lines on 2 ATA's. I'm using ISDN to receive and place calls directly - not as a means to connect to the Internet and route calls to another provider. Imagine this as a stand-alone asterisk setup.

I guess the bottom-line here is that the devices currently supported by OpenWRT just haven't enough horsepower to support the needs of a complete asterisk server. There is a need for more CPU cycles per second, in order to run dtmf detection code and be able to load the indications module, and better expansion options (like a PCI slot smile), in order to connect a proper modem. Another important thing is also Linux 2.6 support, as ISDN software has radically changed for new kernel versions and the latest asterisk revisions do not even support older ISDN code. I just hope new devices will come (there are already some 300MHz versions out there) and OpenWRT developers will keep up the good work.

antony wrote:

I guess the bottom-line here is that the devices currently supported by OpenWRT just haven't enough horsepower to support the needs of a complete asterisk server. There is a need for more CPU cycles per second, in order to run dtmf detection code and be able to load the indications module,

From what I coould see with the various codecs ("show translation"), the CPU is not too bad, but the lack of hardware FPU and the consequent software emulation of floating-point operations absolutely kills the performances. Modems like GSM 06.10 perform quite well, but Speex, iLBC or even the relatively lightweight LPC-10 are totally unusable. So, perhaps the trick could be re-writing lpc.c to use only fixed point operations. Not a trivial undertaking... Often, codecs have freeware floating-point implementations and paid fixed-point ones: that's the case with iLBC, and also with my own little OpenLPC, of which Hawk Software at one point developed a commercial, interoperable fixed-point version.

antony wrote:

and better expansion options (like a PCI slot smile), in order to connect a proper modem. Another important thing is also Linux 2.6 support, as ISDN software has radically changed for new kernel versions and the latest asterisk revisions do not even support older ISDN code. I just hope new devices will come (there are already some 300MHz versions out there) and OpenWRT developers will keep up the good work.

Well, incremental steps in that direction could be represented by Gumstix boards (http://www.gumstix.com/products.html ), Soekris boards (http://www.soekris.com/products.htm ) and fan-less EPIA boards (http://www.google.com.hk/search?q=epia+fanless ), for all of which there are versions of Astlinux. Unfortunately, Astlinux' support for ISDN at present is not very good, due to the fact that both its lead developer and most of its users are based outside Europe, where ISDN is not that popular.

Cheers --

Enzo

enzo wrote:

Unfortunately, Astlinux' support for ISDN at present is not very good, due to the fact that both its lead developer and most of its users are based outside Europe, where ISDN is not that popular.

openwrt HEAD contains support for ar7 based devices (TI mipsel cpu) like AVM Fritz!Box.  - Asterisk 1.2.1 can be run on Fritz!Box 7050 or 7170; both have 32 MB RAM and two builtin isdn adapters (one in nt mode and one in te mode). Openwrt is not yet ready for the fritzbox, but asterix can be run in a chrooted environment. What you get is isdn with working dtmf detection (in the closed source avm kernel module); isdn is linked to asterisk by chan_capi-cm.

The results are at spblinux.de/fbox/openwrt. (You have to add capi4kutils and chan_capi-cm to openwrt; and some patches have to be added to openwrt).

I am posting here because some readers of this list might be interested in embedded asterisk with isdn; (german readers can find more information at ip-phone-forum.de.

spblinux

spblinux wrote:

[...]
openwrt HEAD contains support for ar7 based devices (TI mipsel cpu) like AVM Fritz!Box.  - Asterisk 1.2.1 can be run on Fritz!Box 7050 or 7170; both have 32 MB RAM and two builtin isdn adapters (one in nt mode and one in te mode). Openwrt is not yet ready for the fritzbox, but asterix can be run in a chrooted environment. What you get is isdn with working dtmf detection (in the closed source avm kernel module); isdn is linked to asterisk by chan_capi-cm.

The results are at spblinux.de/fbox/openwrt. (You have to add capi4kutils and chan_capi-cm to openwrt; and some patches have to be added to openwrt).

I am posting here because some readers of this list might be interested in embedded asterisk with isdn; (german readers can find more information at ip-phone-forum.de.

spblinux

Thanks. For non-German readers, http://translate.google.com/translate?u … t%3D101903 provides an English translation (sort of :-) )

Enzo

Will this startup-script work if I have asterisk installed on a sd-card mounted on /mnt/sd ?

rakiii wrote:

Will this startup-script work if I have asterisk installed on a sd-card mounted on /mnt/sd ?

I  suppose it will, as long as files on that partition can be read, written, executed etc. just like any other file...
Anyway, jut give it a try: it shouldn't take much work.

Enzo

enzo wrote:
rakiii wrote:

Will this startup-script work if I have asterisk installed on a sd-card mounted on /mnt/sd ?

I  suppose it will, as long as files on that partition can be read, written, executed etc. just like any other file...
Anyway, jut give it a try: it shouldn't take much work.

Enzo

Do I have do edit all directories in the script so they point to /mnt/sd..... ?

The discussion might have continued from here.