Tuesday, 10 February 2009

Asterisk: A Bare-Bones VoIP Example p:4

Testing: Here We Go!

The user on extension 2000 should be able to dial 2001 and the other line will ring. As you watch the console, you should see a flurry of messages showing up as you dial, and after you hang up. If you go immediately to the "Busy" message, it's probably because your phone client hasn't registered with the Asterisk server -- make sure it's sending server registry statements, as these are the "heartbeats" that Asterisk uses to ensure that a remote client is available for inbound calls. If you have your registry interval set to more than 15 seconds, you'll need to wait at least that long for the SIP client to register (once Asterisk is started) before calls can be sent to that phone.

Try leaving voicemail for extension 2000. From extension 2000, dial 2999 and you should hear a prompt for the password -- you won't need to type in the extension for which you are trying to retrieve mail, as it is automatically entered with the addition of the ${CALLERIDNUM} variable as an argument to the VoiceMailMain line -- this types in the correct extension automatically. Extension 2999 has a password of 4321, so type in "4321#" -- the # sign is equivalent to "enter." Then follow the prompts to retrieve the mail. You can also change the greetings on the line -- experiment a bit with the different options within voicemail.

Hopefully this all worked for you. Often, getting the first implementation up and running is a process of trial-and-error, and the added complexity of the SIP clients can make this an exhaustive reduction in variables. Feel free to ask the asterisk-users mailing list any specific questions you might have after reviewing the archives -- both resources are very useful to the beginner.


SIP is a bit tricky to start out with. I would strongly suggest that your Asterisk server and both phones are on the same network segment when you begin your testing; having one or more devices processed through a firewall or NAT will cause you quite a few ulcers, and will almost certainly not work during your testing.

Make sure your SIP phones are sending correct REGISTER statements to the server -- without valid registration, the Asterisk process will not know where to send a call destined for that extension. Try sip show peers to see if the IP address of your phone shows up and is valid.

If SIP registration seems to be the problem, you can try removing the secret= lines and specifying an IP address of the phone in the host= line. This will lock the phones onto specific addresses and remove any registration issues you might be having.

I have found the tethereal tool (part of the ethereal network sniffer toolset) to be immensely valuable. tethereal -n ip and port 5060 will debug SIP packets in a human-readable form, and should show you what is happening on the wire when testing.

Another important debugging technique is to run asterisk in "full debug mode." This is done with asterisk -vvvvvgcd and puts all possible debugging information on your console. Also make sure that your SIP client is using the G.711 codec (either alaw or ulaw) as that is a codec that is known to work with Asterisk.

Additional Features

To list Asterisk's full feature set would take quite a while, as it is just as much a toolkit as a set of applications. Some things I've implemented for myself and other customers include:
  • Telemarketer block: Forces callers without caller ID to enter valid info, or hangs up.
  • Zapateller: Used with telemarketer block -- plays three-tone "disconnected number" for callers with no caller ID, which auto-removes from many phone spam networks.
  • Dual ring: Phones at the office and at home ring at the same time, during certain hours.
  • PBX long distance gateway: PRI interface to Asterisk box, then low-priced ITSP to get better LD rates using existing PBX.
  • IVR interface: Use as an inbound call center pre-processor.
  • International toll avoidance: One in the HQ in each continent allows for centrex-style dialing over the Internet.
  • Voicemail: Stand-alone voicemail server interfaces with existing PBX -- low-cost solution to otherwise expensive upgrade.
  • Monitoring system: Intelligent dial-out platform that can verbalize network problems and take actions based on IVR.
  • NAT traversal: Asterisk can work with SIP clients behind NATs with no additional software (see nat=1 in sip.conf).

Digium makes a low-cost ($100) analog FXO (Foreign Exchange Office -- meaning, it accepts a wire that has dialtone on it) PCI card that can be used to connect your home or office phone line into Asterisk. Add to this a Cisco ATA-186 (~$150) for two lines of FXS (handsets) use, and you can have a mini-PBX in your house with extremely powerful features for about $250, plus the cost of a reasonably decent old PC that you may have laying around. I've had acceptable experiences running with a 400mhz PIII with two lines. I've found that putting one of these systems together with an FXO card is a fast way to convince others that OSS VoIP platforms are ready to be examined as a serious possibility for the office environment, since one can attach the machine directly to the existing PBX (assuming you can get an analog line off of your PBX system).

More complex Asterisk configurations and some other SIP-related examples can be found on my web site.

Other Projects and Resources


There are several SIP implementations that are OSS, but they are primarily what are known as "call proxies" instead of more full-featured PBX applications. This means that they function only to connect two endpoints together, and are basically just large, fast, directory servers. Examples of SIP Proxies are ser and Vocal. There are also other open source PBX projects like Bayonne and OpenPBX, which have slightly different feature sets than Asterisk.

Long Distance/Free Services

There are also now retail vendors of SIP long distance service, which are called Internet Telephony Service Providers (ITSPs.) Vendors such as iconnecthere (formerly Deltathree) have rates in the $.01-per-minute category anywhere in the U.S., and I expect that some searching will find similar vendors in Europe and Asia. There are also no-cost solutions like Free World Dialup that are limited to calling users via IP only, but you can mix/match dialplans so you can reach all destinations from the same phone, if that phone is routed through Asterisk. There are other SIP long distance providers, but to my knowledge all of the others (Vonage, Packet8) require you to use their equipment, thus making use with Asterisk impossible.

SIP Hardware

Cisco ATA-186 (About $150 new) Supplies two FXS ports (standard phones plug into FXS ports)
Cisco 7960/7940 (About $300 used) Deskset with XML-programmable six-line LCD
Digium ($100-$500 new) Variety of PCI cards for direct telephony connections to Asterisk servers
Pingtel (About $550 new) Deskset with LCD
SNOM 200 (About $290 new) Deskset with LCD
Grandstream (About $85 new) Deskset with small LCD

SIP Software/Hardware

SIP Product List: Lists of hardphones, softphones, and other servers

IPTel.org: Lists of hardphones, softphones, and other servers

John Todd is the CTO of TalkPlus, Inc. which is a next-generation mobile identity management and enhanced call services provider.


moustafa said...

wonderful blog

comment on mine and try the traffic system if u plz


Nonaa said...

i invite you to visit my blog
TV Window best wishes :)