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

  1. 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
  2. Allow execution right of update-zaptel.sh:
    # chmod +x update-zaptel.sh
  3. Update Zaptel to 1.4.5.1:
    # ./update-zaptel.sh 1.4.5.1

Wednesday, August 22, 2007

Script to Update Asterisk

  1. 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
  2. Allow execution right of update-asterisk.sh:
    # chmod +x update-asterisk.sh
  3. 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

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.

Remove the Blogger Nav Bar

http://simple-tricks.blogspot.com/2007/07/blogger-tip-remove-nav-bar.html

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 && 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 && 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 jo
e

References:
Debian Installation Guide for i386
http://www.debian.org/releases/stable/i386/