IP04 and Asterisk VOIP Training

Introducing Asterisk

  • Asterisk is a telephone switch program that runs on Linux PCs

  • Free software (no license cost)

  • Connect analog and Internet phone calls

  • Can be configured by command line and text configuration files

  • GUIs and distros (e.g. FreePBX) also available

  • Asterisk Box consists of Linux plus Asterisk software plus PCI cards for analog ports

Introducing the IP04

  • Small Linux computer designed for Asterisk. Cost ranges from USD$300-450 retail, less for volume.

  • 4 analog ports built in, can connect to analog phone or analog PSTN phone line.

  • 500MHz Blackfin processor, same CPU power as 1GHz Pentium. 256 Mbyte of flash memory. No moving parts, very small.

  • Has Ethernet port to talk to LAN and Internet for VOIP.

  • Low power 3-5W, 10% of power of PC. Power from solar, car battery charged by AC mains once a day. Low power means cheap power.

  • Configure just like a x86 Linux PC, e.g. telnet, command line, conf files. GUI also available but not as powerful and easy to get problems that are hard to fix. Best to understand basic command line and conf file skills first.

  • Can run many Linux programs, such as small web server, shell script, ssh, text editor, perl, small database.

  • Can't run some large applications like Apache, MySQL, or Desktop.

IP04 is Open Hardware

  • The IP04 design is Free as in Libre. You can copy the circuit and make your own IP04s. Here is the IP04 circuit. Also all software such as Linux operating system and Asterisk software is free. So you can configure the IP04 exactly as your want.

  • Open Hardware is good for developing countries. You can make IP04 in your own country, and also repair locally. You can modify IP04 to suit your country. For example include more ports or add solar charger or Wifi to motherboard.

  • If you quantity of IP04 is not so large, it may be better to buy from other companies. For large volume local manufacture may be a good idea.

  • Making IP04 in your country will create local electronics industry, and profits stay in your country. Low labour costs make IP04 assembly cheap in your country.

  • Can be hand assembled with $200 tools in 1 day by person with soldering skills. Or assembled by machines (more expensive) in a few minutes. To repair an IP04 you need electronic technician skills like TV repair. Linux software skills are needed to flash and install software.

  • IP04 technology was developed by a community of hardware and software developers. Several companies are now making IP04 products. Atcom is Chinese company who make most IP04s - good friends of the Free Telephony Project.

Inside the IP04

  • 500MHz Blackfin CPU with 256 Mbyte flash memory

  • FXO Module (red) for PSTN phone lines

  • FXS Module (green) for connecting to telephones

  • Ethernet for LAN and Internet

  • Serial RS232 Connector

  • LEDs for ports, power, network.

  • Phone connectors

  • MMC (doesn't work due to driver)

Basic Linux Networking

The IP04 does not have a screen, so you need to connect via Ethernet cable and network.

IP04 has a default IP address on 192.168.1.30. To connect to the IP04 you need to configure the PC to be on 192.168.1.0/24 network

  • connect IP04 to same LAN as PC (or IP04 directly to PC Ethernet, loopback or normal cable OK)

  • login as super user to set IP of PC

  • set IP of PC with ifconfig

  • check IP with ifconfig

  • ping IP04 to check network connection to IP04

  • telnet into IP04

[david@bunny ~]$ sudo su -
Password:
root@bunny:~# ifconfig eth0 192.168.1.100
root@bunny:~# ifconfig
root@bunny:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:C5:BB:B1:29
          inet addr:192.168.1.100  Bcast:192.168.1.255

root@bunny:~# ping 192.168.1.30
root@bunny:~# telnet 192.168.1.30

Basic vi Editor Commands

Practice:

root:~> vi /tmp/test.txt

Practice moving between command mode (ESC) and insert mode (i).

Command key
insert mode i
command mode ESC
delete x
delete line dd
search /text
go to end of file G
save :w
exit :q
save and exit :wq
Note If you really hate vi install one of the other editors like vim, nano, or ee (e.g. ipkg install ee).

Lesson: First Calls

This requires an IP04 with two analog phones and FXS ports 3 and 4.

  • Plug an analog phone to Port 3 and Port 4.

  • Pick up the phone plugged into Port 3 and dial 4. The other phone should ring, answer the call!

This requires just one analog phone and will work on IP01 or IP04.

  • Pick up analog phone and dial 2020

  • Speak into the phone when you hear the beep

  • Asterisk will record 6 seconds of audio and play it back

Lesson: Basic Dialplan

The goal of this lesson is to introduce and experiment with a basic Asterisk dial plan. You need an IP04 or IP01 with an analog telephone connected to a FXS port.

  • telnet to IP04, start asterisk CLI, and look at default dialplan:

    root@bunny:~# telnet 192.168.1.30
    root:~> asterisk -r
    CLI> show dialplan default
    Note Asterisk CLI commands have TAB completion, so you can type sh-TAB di-TAB def-TAB
  • Each extension in dialplan tells Asterisk what to do when that number is dialled

  • When 4 is dialled this entry tells Asterisk to make call to Zap/4 (analog port 4)

      '_4' =>           1. Dial(ZAP/4)
  • When 3 is dialled this entry tells Asterisk to make call to Zap/3 (analog port 3)

      '_3' =>           1. Dial(ZAP/3)
  • When 2008 is dialled Asterisk first plays the file demo-instruct, then the Goto command which repeats step 1. So a dialplan entry can be a small program.

      '2008' =>         1. Background(demo-instruct)
                        2. Goto(2008|1)
  • The /etc/asterisk/extensions.conf file contains the dialplan. When you edit extensions.conf reload the dialplan like this:

    CLI> dialplan reload

Add a Dialplan entry

  1. Use vi to edit /etc/asterisk/extensions.conf

    root:~> vi /etc/asterisk/extensions.conf
  2. Page down to start of [defaults] section, press i for insert and add:

    [default]
    ; test echo when 2018 dialled
    exten => 2018,1,Answer
    exten => 2018,2,Playback(hello-world)
    exten => 2018,3,Hangup

    This tells Asterisk to play the hello-world voice file when 2018 is dialled.

  3. Save with ESC:w

    Note In vi you can use /[def to search for default section of extensions.conf
  4. Start another telnet window to IP04, then:

    root:~> asterisk -r
    CLI> dialplan reload
    CLI> show dialplan default

    Check that 2018 appears in the dialplan you have loaded.

  5. Now dial 2018 on the analog phone and you should hear Hello World.

There are many more ways to write an Asterisk dialplan.

Lesson: IAX Call

IAX is a protocol for connecting two Asterisk boxes together over a network. IAX can connect through an Internet firewall which is often useful.

For this Lesson two IP0x boxes are required. Both should have an analog port and analog phone connected. Lets say we have:

Box name Box type IP Port Zaptel number Dialplan Extension
A IP04 192.168.1.30 4 Zap/4 4
B IP01 192.168.1.31 1 Zap/1 1
Note If you are not sure of the diaplan extension use show dialplan default at the Asterisk CLI.
  • In a telnet session on A try to ping B

    [david@bunny ~] telnet 192.168.1.30
    root:~> ping 192.168.1.31

    Make sure A can ping B OK.

  • Now we will edit the dialplan of A, using vi to edit /etc/asterisk/extensions.conf

    root:~> vi /etc/asterisk/extensions.conf
  • Page down to start of [defaults] section, press i for insert and add:

    [default]
    exten => 2050,1,Dial(IAX2/guest@192.168.1.31/1@default)
  • Use ESC:w to save.

  • This says dialling 2050 on A (192.168.1.30) will make a call to extension 1 on B (192.168.1.31).

  • Reload and check the dialplan:

    CLI> dialplan reload
    CLI> show dialplan default

    Make sure extension 2050 looks OK.

  • Now try dialling 2050 on A - the analog phone on B should ring!

  • If there are any problems observe the CLI for error messages.

You could use IAX2 to connect two IP0X devices over a LAN, or wireless network, or the Internet.

Lesson: SIP Phone

The goal of this lesson is to connect a SIP phone to Asterisk and make a call. This lesson can use the IP04, IP01, or a PC with Asterisk.

For this example we use an Atcom AT-530 SIP phone, other SIP devices are similar - modify /etc/asterisk/sip.conf and configure the SIP device on it's web interface.

  • telnet to IP04 (or get command line shell on PC)

  • using vi to end of /etc/asterisk/sip.conf add:

    Note In vi pressing G will take you to end of file, useful for sip.conf
    [at530]
    type=friend
    context=default
    host=dynamic
    user=at530
    secret=at530
    canreinvite=no
    callerid=at530
    disallow=all
    allow=ulaw
  • Save file and quit vi with :wq

  • Now we will configure the Atcom AT530 IP phone configuration for Asterisk on the IP04:

  • Connect the WAN port of the AT530 to your LAN, it will boot and obtain an IP via dhcp.

  • Find the IP of the phone by pressing the Sysinfo button a few times.

  • With your web browser login to this IP using the username/password admin/admin.

  • Optional: set a static IP using the WAN menu (I like static IPs for SIP phones).

  • On the SIP Config menu set Register Username to at530, Register Password to at530, and the Phone Number to at530.

  • Check the Enable Register box.

  • Then click on apply.

  • To check if registration is successful on the IP04 CLI try:

    root:~> asterisk -r
    CLI> set debug 5
    CLI> sip reload
  • After about 30 seconds the phone should register. To check registration try:

    ip04*CLI> sip show peers
    Name/username              Host            Dyn Nat ACL Port     Status
    at530/at530                192.168.1.179    D          5060     Unmonitored
  • You can add an extensions.conf entry for the phone:

    [default]
    exten => 2060,1,Dial(SIP/at530)
  • Then type dialplan reload at the CLI

  • Now dial a number (like 2008, 2018, or 2050) on the SIP phone and press Send on the SIP phone to make the call.

Lesson: BAPS Package System

Packages of software can be downloaded from Internet, or local web server, or from PC. The package system is called BAPS.

  1. Essential BAPS commands are:

    root~> ipkg update
    root~> ipkg list
    root~> ipkg list_installed
    root~> ipkg install PackageName
    root~> ipkg remove PackageName
  2. Try to install then remove the LEDs package. Check the list of installed packages before and after:

    root~> ipkg update
    root~> ipkg list
    root~> ipkg list_installed
    root~> ipkg install leds
    root~> ipkg list_installed

    You can now see the LEDS package has been installed.

  3. The leds package lets you turn the IP04 LEDS off and on. You can get documentation for packages in /usr/doc. Try:

    root~> ls /usr/doc
    root~> cat /usr/doc/leds.txt
  4. Now lets try to turn the SD and SYS LEDS on and off:

        $ modprobe leds
        $ echo 1 > /proc/sd_led
        $ echo 1 > /proc/sys_led
        $ echo 0 > /proc/sd_led
        $ echo 0 > /proc/sys_led
  5. This could be useful for status, for eaxmpel LED could blink if Internet link is available.

  6. Packages can be removed:

    root~> ipkg remove leds
    root~> ipkg list_installed
  7. BAPS packages are downloaded from the URL in /etc/ipkg.conf, you can change this to be a web server anywhere on your network:

    root~> cat /etc/ipkg.conf
    src snapshots http://rowetel.com/ucasterisk/ipkg
    dest root /

Please see the BAPS page for more information

Lesson: FXO Port Calls

Lesson: SIP trunks

Debugging Problems

Cannot Connect to IP04

  • Check Ethernet cable

  • Check IP configuration of PC with ifconfig

  • Check LAN connection to IP04 using ping

How to Find IP address of IP04

  • Use RS232 Serial console (link:ip04.html#started step 14), then type ifconfig.

  • Use nmap on your PC to search a range of IPs. This will search for all IPs from 192.168.1.0 to 192.168.1.255 and report which hosts are up:

      root~# nmap -v -sP 192.168.1.0/24 | grep up

Phone Call Problems

  • telnet to IP04

  • start Asterisk CLI

  • set high debug level: set verbose 5

  • make phone call again and look for error messages using the Asterisk CLI:

      root~# asterisk -r
      CLI> set debug 5

SIP Phone Call Problems

  • try to ping IP of SIP device

  • At CLI check SIP device is registered:

      root~# asterisk -r
      CLI> sip show peers
  • reboot power of SIP device

  • also try set debug 5 and make phone call as above

Analog Ports

If you analog ports do not work it may be a hardware problem, a driver problem, or an Asterisk problem.

  • To check the driver and hardware use dmesg on the IP04 and look for:

    port: 1 port_type: O
    port: 2 port_type: -
    port: 3 port_type: S
    port: 4 port_type: S

    This shows the driver detected the hardware, port 1 FXO, no module in Port 2, and Port 3 and Port 3 FXS.

  • Another check is to measure the voltage on FXS ports - it should be 48V. It can be measured on the outer two pins of the top of the FXS module.

  • Try a simple extension like:

    exten => 2020,1,Answer
    exten => 2020,2,Record(/tmp/asterisk-recording:ulaw||6)
    exten => 2020,3,Playback(/tmp/asterisk-recording)
    exten => 2020,4,Hangup

    When 2020 is dialled, 6 seconds of audio is recorded then played back. This is useful for testing record and playback audio quality.

Reset IP04 to default

Some times if the configuration of the IP04 is very bad you may want to reset to the default (IP04 How To step 18).

Other Ideas

  • A GUI is available for the IP04. Here are instructions for installing and using the GUI. The GUI has a few bugs and is not as flexible as the configuration files. If you get stuck use ipkg remove and ipkg install to remove and install again.

  • IP04 can be set for static IP (IP04 How To Step 5 & 6) or dynamic IP (IP04 How To Step 7). Static is more useful so other IP devices can easily find the IP04.

  • IP alias allows IP04 to have more than one IP address. This is useful to give IP04 a known IP for debugging. You can add an IP alias like this:

    ifconfig eth0:1 10.30.3.2 netmask 255.255.255.0 up

    Which will add another IP of 10.30.3.2 as well as the original IP on eth0.

  • Serial RS232 Console: This is useful if IP04 Ethernet or IP is not working. See IP04 How To step 14.

Internal Links

External Links

Terms

Term Description
ATA Analog telephone Adaptor - makes analog telephone a SIP device
BAPS Blackfin Asterisk Package System
FXS Port connect to analog phone
FXO Port connect to analog PSTN telephone line
SIP Phone (IP phone) digital phone that connects to Ethernet and network