Chinese translation of the book "Asterisk: The Future of Telephony":
Asterisk, 电话未来之路
http://www.trixbox.com.cn/attachments/Asterisk.pdf
Tuesday, November 20, 2007
Chinese Translation of Asterisk Book
Saturday, October 6, 2007
"rtc: lost some interrupts at 1024Hz." Messages after Installation of Zaptel
I got a lot of "rtc: lost some interrupts at 1024Hz." messages after installed zaptel-1.4.5.1 and the ztdummy module was enabled. It seems that the RTC periodic_IRQ can not be enabled.
"cat /proc/driver/rtc" shows:
rtc_time : 02:55:42
rtc_date : 2007-10-06
rtc_epoch : 1900
alarm : 00:26:49
DST_enable : no
BCD : yes
24hr : yes
square_wave : no
alarm_IRQ : no
update_IRQ : no
periodic_IRQ : no <= this should be yes for a normal system
periodic_freq : 1024
batt_status : okay
The Linux is Debian GNU/Linux 4.0r1 and kernel version is 2.6.18-5-686.
The problem seems to be related to ACPI (Advanced Configuration and Power Interface). Finally, I fix this by turning off ACPI and using the older APM (Advanced Power Management) for power off control.
Disable ACPI:
Edit "/boot/grub/menu.lst" and add "acpi=off" in kernel boot statement.
title Debian GNU/Linux, kernel 2.6.18-5-686
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-5-686 root=/dev/sda1 ro acpi=off
initrd /boot/initrd.img-2.6.18-5-686
savedefault
Enable APM for power off control:
Add "apm power_off=1" to the end of "/etc/modules".
Friday, September 28, 2007
Install Debian by USB Thumb Drive
The following script can make an USB Thumb Drive as a Debian installation disk. Insert the USB Thumb Drive into the PC before running the script. This script assumes the USB Thumb Drive is /dev/sda which may be different on your system.
Please note: Everything on the USB Thumb Drive will be erased after running this script.
#!/bin/bash
wget -c http://cdimage.debian.org/debian-cd/4.0_r1/i386/iso-cd/debian-40r1-i386-businesscard.iso
wget -c http://ftp.nl.debian.org/debian/dists/etch/main/installer-i386/current/images/hd-media/boot.img.gz
echo "Copy boot image..."
zcat boot.img.gz > /dev/sda
echo "Copy businesscard.iso..."
mount /dev/sda /mnt
cp debian-40r1-i386-businesscard.iso /mnt/businesscard.iso
umount /mnt
echo "Make disk bootable..."
syslinux /dev/sda
Tuesday, September 25, 2007
Saturday, September 8, 2007
Install Apache2 on Debian
The Debian source at http://ftp.hk.debian.org seems missing some files for Apache2. Therefore, I change the Debian source to http://http.us.debian.org. Edit the file /etc/apt/sources.list:
#
# deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20
deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 2007
deb http://http.us.debian.org/debian/ etch main
deb-src http://http.us.debian.org/debian/ etch main
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
Run apt-get update every time you change the sources.list.
# apt-get update
Install Apache2:
# apt-get install apache2
Test the installation:
Point the browser to http://192.168.0.66/apache2-default/ and the following returns:
It works!
Reference:http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html
Friday, September 7, 2007
Asterisk Call Files
Call files are like a shell script for Asterisk. A user or application writes a call file into /var/spool/asterisk/outgoing/ where Asterisk processes it immediately.
http://www.the-asterisk-book.com/unstable/call-file.html
On-line Book - Practical Asterisk 1.4 (unstable)

The "Practical Asterisk 1.4 (unstable)" is a work in progress English translation of the original German book of Stefan Wintermeyer. This early version is placed online to find bugs and feedback.
http://www.the-asterisk-book.com/unstable/
Wednesday, August 29, 2007
Why is there no free RAM?
The following are quoted from: http://www.eygle.com/digest/2007/07/linux_memory_management_or_why.html
Traditional Unix tools like 'top' often report a surprisingly small amount of free memory after a system has been running for a while. For instance, after about 3 hours of uptime, the machine I'm writing this on reports under 60 MB of free memory, even though I have 512 MB of RAM on the system. Where does it all go?
The biggest place it's being used is in the disk cache, which is currently over 290 MB. This is reported by top as "cached". Cached memory is essentially free, in that it can be replaced quickly if a running (or newly starting) program needs the memory.
The reason Linux uses so much memory for disk cache is because the RAM is wasted if it isn't used. Keeping the cache means that if something needs the same data again, there's a good chance it will still be in the cache in memory. Fetching the information from there is around 1,000 times quicker than getting it from the hard disk. If it's not found in the cache, the hard disk needs to be read anyway, but in that case nothing has been lost in time.
To see a better estimation of how much memory is really free for applications to use, run the command:
free -m
The -m option stands for megabytes, and the output will look something like this:
total used free shared buffers cached
Mem: 503 451 52 0 14 293
-/+ buffers/cache: 143 360
Swap: 1027 0 1027
The -/+ buffers/cache line shows how much memory is used and free from the perspective of the applications. Generally speaking, if little swap is being used, memory usage isn't impacting performance at all.
Notice that I have 512 MB of memory in my machine, but only 503 is listed as available by free. This is mainly because the kernel can't be swapped out, so the memory it occupies could never be freed. There may also be regions of memory reserved for/by the hardware for other purposes as well, depending on the system architecture.
Thursday, August 23, 2007
Script to Update Zaptel
- Type the following and save as file name "update-zaptel.sh":
cd /usr/src
wget http://ftp.digium.com/pub/zaptel/zaptel-$1.tar.gz
tar xvzf zaptel-$1.tar.gz
cd /usr/src/zaptel-$1
make clean
./configure
make
make install - Allow execution right of update-zaptel.sh:
# chmod +x update-zaptel.sh - Update Zaptel to 1.4.5.1:
# ./update-zaptel.sh 1.4.5.1
Wednesday, August 22, 2007
Script to Update Asterisk
- Type the following and save as file name "update-asterisk.sh":
cd /usr/src
wget http://ftp.digium.com/pub/asterisk/asterisk-$1.tar.gz
tar xvzf asterisk-$1.tar.gz
cd /usr/src/asterisk-$1
make clean
./configure
make
make install - Allow execution right of update-asterisk.sh:
# chmod +x update-asterisk.sh - Update Asterisk to 1.4.11:
# ./update-asterisk.sh 1.4.11
Monday, August 20, 2007
How to show Zaptel version?
At command prompt type:
#modinfo zaptel
filename: /lib/modules/2.6.18-4-486/misc/zaptel.ko
author: Mark Spencer
description: Zapata Telephony Interface
license: GPL
version: 1.4.5
vermagic: 2.6.18-4-486 mod_unload 486 REGPARM gcc-4.1
depends: crc-ccitt
srcversion: 9A9A2F52F51B319787CFC26
parm: deftaps:int
parm: debug:int
Upgrade to Zaptel 1.4.5
Get the current Zaptel source:
# cd /usr/src
# wget http://ftp.digium.com/pub/zaptel/zaptel-1.4.5.tar.gz
Unpack the archives:
# tar xvzf zaptel-1.4.5.tar.gz
Build the Zaptel:
# cd /usr/src/zaptel-1.4.5
# make clean
#./configure
# make
# make install
Sunday, August 19, 2007
Upgrade to Asterisk 1.4.10.1
Get the current Asterisk source:
# cd /usr/src
# wget http://ftp.digium.com/pub/asterisk/asterisk-1.4.10.1.tar.gz
Unpack the archives:
# tar xvzf asterisk-1.4.10.1.tar.gz
Build the Asterisk:
# cd /usr/src/asterisk-1.4.10.1
# make clean
#./configure
# make
# make upgrade
Monday, August 13, 2007
Use Netem to Set Packet Loss
Set the loss to 30% at beginning (the first command):
# tc qdisc add dev eth0 root netem loss 30%
Change the loss to 10%:
# tc qdisc change dev eth0 root netem loss 10%
Restore to normal (the last command):
# tc qdisc del dev eth0 root
Saturday, August 11, 2007
Asterisk Extension Matching Mechanism
The following informations at VoIP Wiki summarize Asterisk extension matching mechanism:
Extension Names and Patterns
http://www.voip-info.org/wiki/index.php?page=Asterisk+Dialplan+Patterns
Asterisk Extension Matching
http://www.voip-info.org/wiki/index.php?page=Asterisk+Extension+Matching
Sort Order of Extension Patterns
http://www.voip-info.org/wiki/index.php?page=Asterisk+config+extensions.conf+sorting
Tuesday, August 7, 2007
IAX2: Inter-Asterisk eXchange Version 2
IAX2 on Wikipedia
http://en.wikipedia.org/wiki/IAX
IAX2 Internet-Draft
http://www3.tools.ietf.org/html/draft-guy-iax-03 (Version 03)
http://www3.tools.ietf.org/html/draft-guy-iax-02 (Version 02)
http://www3.tools.ietf.org/html/draft-guy-iax-01 (Version 01)
http://www3.tools.ietf.org/html/draft-guy-iax-00 (Version 00)
http://www.cornfed.com/iax.pdf (Draft)
Monday, August 6, 2007
Netem - Linux Network Emulation
Netem provides network emulation functions for testing protocols by emulating properties of wide area networks, such as delay jitter, loss, duplication and re-ordering. Netem is already enabled in the kernel of various current Linux distributions.
References:
Netem - LinuxNet
http://linux-net.osdl.org/index.php/Netem
Thursday, August 2, 2007
Free Books on Asterisk

Asterisk: The Future of Telephony
Download the whole book
On-line version:
http://asterisk.name/
Asterisk Configuration Guide
(ready for version 1.4)
Download the first three chapters
Wednesday, August 1, 2007
Connect Two Asterisk Servers Using IAX2
Two Asterisk servers are connected by IAX2 trunking. All dialing numbers started with "3" will be forwarded to the other server with the first digit stripped.
Server A's IP is "192.168.0.33"
Server B's IP is "192.168.0.66"
Server A - iax.conf
[server-b]
type=peer
host=192.168.0.66
username=server-a
secret=server-a-pass
disallow=all
allow=ulaw
[server-b]
type=user
secret=server-b-pass
disallow=all
allow=ulaw
context=internal
Server A - extensions.conf
exten => _3.,n,Dial(IAX2/server-b/${EXTEN:1})
Server B - iax.conf
[server-a]
type=peer
host=192.168.0.33
username=server-b
secret=server-b-pass
disallow=all
allow=ulaw
[server-a]
type=user
secret=server-a-pass
disallow=all
allow=ulaw
context=internal
Server B - extensions.conf
exten => _3.,n,Dial(IAX2/server-a/${EXTEN:1})
References:
http://www.syednetworks.com/connection-between-two-asterisk-servers-using-iax#more-87
Setup Asterisk 1.4 Configuration Files from Asterisk 1.2
Copy the following configuration files from Asterisk 1.2 to 1.4:
/etc/asterisk/iax.conf
/etc/asterisk/sip.conf
/etc/asterisk/extensions.conf
/etc/asterisk/musiconhold.conf
/etc/asterisk/features.conf
Copy music and custom tones files from Asterisk 1.2 to 1.4:
/var/lib/asterisk/moh-native/*
/var/lib/asterisk/sounds/custom/*
Replace applicaiton "DigitTimeout(5)" by "Set(TIMEOUT(digit)=5)" in extensions.conf.
Install Asterisk
Get the current Asterisk and Zaptel Drivers source:
# cd /usr/src
# wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
# wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
Unpack the archives:
# tar xvzf asterisk-1.4-current.tar.gz && tar xvzf zaptel-1.4-current.tar.gz
Build the Zaptel drivers (change the directory name to reflect the current version):
# cd /usr/src/zaptel-1.4.4
# ./configure &&amp;amp;amp; make && make install
Load the ztdummy kernel module:
# modprobe ztdummy
Build the Asterisk (change the directory name to reflect the current version):
# cd /usr/src/asterisk-1.4.9
# ./configure &&amp;amp;amp; make && make install
Install sample configuration files:
# make samples
Make Asterisk start up automatically at boot time:
# make config
# echo "ztdummy" >> /etc/modules
References:
Installing Asterisk 1.4.x on Debian Linux 4.0 (Etch)
http://www.the-asterisk-book.com/unstable/installation-1.4-debian-4.0.html
Install Debian Packages for Building of Asterisk
A few more packages are required for building of Asterisk. Do the following:
# apt-get -y install build-essential libncurses5-dev libcurl3-dev libvorbis-dev libspeex-dev unixodbc unixodbc-dev libiksemel-dev linux-headers-`uname -r`
References:
Installing Asterisk 1.4.x on Debian Linux 4.0 (Etch)
http://www.the-asterisk-book.com/unstable/installation-1.4-debian-4.0.html
Configuring Debian to Use Static IP
Default setup of Debain is getting IP via DHCP. In order to use static IP 192.168.0.66, do the following.
Edit the file "/etc/network/interfaces" and replace "iface eth0 inet dhcp" with the following (section 10.6.1.1):
iface eth0 inet static
address 192.168.0.66
netmask 255.255.255.0
gateway 192.168.0.1
Commands details (section 10.6.1):
# ifdown eth0
# jstar /etc/network/interfaces
# ifup eth0
References:
Debain Reference Chapter 10 - Network Configuration
http://www.debian.org/doc/manuals/reference/ch-gateway.en.html
Install Debian GNU/Linux 4.0
Download the "netinst" ISO image "debian-40r0-i386-netinst.iso" which is about 180MB.
http://cdimage.debian.org/debian-cd/4.0_r0/i386/iso-cd/
Burn the ISO image into CD and boot from a PC with AMD Sempron 2500+ CPU.
Use all default settings except set country to Hong Kong.
Choose only the "Standard system" to install and the whole process complete in 18 minutes.
Update the Debian package listing:
# apt-get update
Upgrade all current installed Debian packages:
# apt-get -y upgrade
Reboot the system:
# reboot
Install SSH server:
# apt-get install ssh
Install Joe editor:
# apt-get install joe
References:
Debian Installation Guide for i386
http://www.debian.org/releases/stable/i386/