Friday, June 18, 2010


My client is using asterisk 1.4.22 with a 1-port digium card connecting to PSTN.  His PSTN provider recently upgraded the NGN and then all outgoing calls are sent with incorrect callerid.
It turns out that the NGN requires TON and NPI different from the default asterisk installation.
What the NGN needs are:
A-number (caller)
TON : unknown
NPI : unknown
B-number (callee)
TON : unknown
NPI : ISDN Telephony
There are two values in /etc/asterisk/zapata.conf related to TON and NPI.  They are:
pridialplan affects the callee's numbering plan while prilocaldialplan affects the caller.
The default asterisk installation sets them to local/national.  In our client's environment, we have to make them as:
More information regarding possible values can be found in
Note that we have to restart asterisk in order to make such changes effective.  Just reloading is not enough.
With the 'unknown' setting, the NGN now presents a correct callerid to the receiver.

Tuesday, June 15, 2010

Fine tune Hylafax server -- is the server too busy?

We can tell Hylafax to work faster by increase the value of MaxConcurrentPreps  in /var/spool/hylafax/etc/config.  Hylafax then processes more jobs at the same time.
The concurrent number of active modems will be seen increasing soon after MaxConcurrentPreps is updated.
But how do we know we reach the threshold of system capacity?
One way to tell is using unix 'top'.  The cpu load shows  queue length to cpu in past 1, 5, 10 minutes.
If we have a single cpu system, then a queue length of 1 almost means that cpu is 100% utilized.  In a multi-core or multi-processor environment, the threshold queue length is the number of cores or processors.  For example, if we have 2 quadcore, then the threshold cpu load is 8. 
Moreover, we can roughly treat core and processor the same when inspecting cpu load.  In that sense, 2-quadcore and 8-processors both reach their threshold when 'top' shows cpu load of 8.
To further verify the number of cores or processors, we can type 'top' and then press '1'.  A list of cpu with their respective usage figures would be shown.  If the cpu queue length is not overwhelming at all, one should notice certain idle% in the usage figures.
Also note that there is no point to further increase MaxConcurrentPreps when the modem pool is saturated.   The command 'faxstat' reports status of each modem.  When almost all modems are in 'sending' state,  speeding hylafax delivery simply results in longer send queue in /var/spool/hylafax/sendq.  From experiment, it is better to keep sendq to a reaonsable length, for example, the number of the modems, in order to maintain a stable hylafax scheduler. 
Talk to me now via ZoiPPE! My ZoiPPE number is 85230003 

Sunday, June 13, 2010

Some tips to fine tune hylafax faxserver

We have a heavy-duty fax server for broadcasting.  It is built using below components:
Asterisk  1.4.31 rc1
Hylafax 5.4.1
iaxmodem 1.7
DELL E5530 XEONX2 8G RAM, 500G harddisk in RAID1
90 iaxmodems are configured so that our full speed is around 3xE1.  We do not install hardware fax card on the same machine. Instead, we route the fax outbound calls to PSTN via SIP gateway, which literally has capacity over 100E1.
Given the hardware and bandwidth, we must perform the steps below to tap the capacity of our machine.
1. Set RingsBeforeAnswer to 0
In each modem-specific configuration file (/var/spool/hylafax/etc/ttyIAXxx.conf), update RingsBeforeAnswer to 0 (RingsBeforeAnswer: 0).  You don't need to restart faxq because it will re-read the config before each send.
Note that RingsBeforeAnswer:0 is the preferred way in SEND-ONLY environment because it gives more precise modem state information to faxgetty and faxq.
2. Set MaxConcurrentPreps to 2 
This parameter applies to faxq configuration only (/var/spool/hylafax/etc/config).  Its default value is 1, just to make sure that your unix box is not overwhelmed by bulk sending.  It should be, however, adjusted according to modem usage and workload observation. 
The unix command 'top' is a good indication of how busy your system is when using something other than default.  The cpu load of 3 to 4 is still safe in most environments.   In our case, setting MaxConcurrentPreps to 2 will just increase the cpu load to 4.
One could shortly see the impact of MaxConcurrentPreps on modem usage by running 'faxstat'.  The number of modems in 'Send' state is almost twice of using default value.
3. Use class1 modem
It is a good idea to configure class1 modems.  From our experience, it gives stable fax result.
Our recent fax job is over 100,000 faxes and completed in 4 days. 
Talk to me now via ZoiPPE! My ZoiPPE number is 85230003 

Wednesday, June 02, 2010

Digium card drops call intermittently

Recently, one of my client reported that he could not receive or call out intermittently. The client has an Asterisk 1.4.22 running on a DELL R710 server with a Digium 1-port E1 card installed. The Asterisk serves around 20 staff extensions and 30 agent extensions distributed by ringall queue strategy.

During the incident, inter-extensions call are functional, suggesting that Asterisk is working.

We also executed zttool to verify the Zaptel channel status. The screen showed no alarm.

In asterisk CLI, 'zap show channels' also did not indicate failed channels.

To verify further, we updated log level to 'debug' in /etc/asterisk/logger.conf. With debugging enabled by CLI command 'logger reload', it turned out that there were frequent, but short errors on the zap channels, most of them being 'Unknown error 500'.

Such type of errors usually indicates link problem between Asterisk and the PSTN.

Tuesday, June 01, 2010

A good way to extract DNIS from extension

In, when agent clicks-n-dial a customer, the customer-id and contact number are concatenated together and passed to dial plan, e.g, #<variable-length-cust-id>#<dnis>.  The two #s are used to enclose a generic customer id and the overall pattern is matched by '_#X.'.
Next, we need to separate the customerid and actual phone number.  The customerid, timestamp and dnis together go to our reporting logic while the dnis part is routed through pstn gateway.
The asterisk function CUT() (note : that CUT is UPPERCASE) is used to extract the customerid and dnis as below.
;; dnis format : #custid#dnis
;; the dnis is supposed to be the 3rd field
exten => _#X.,n,Set(cust_dnis=${CUT(EXTEN|#|3)})
exten => _#X.,n,dial(SIP/pstn_gateway/${cust_dnis})
Talk to me now via ZoiPPE! My ZoiPPE number is 85230003