Peter Dordal, Loyola University CS Dept

In the classroom we have:

We start with a Hello, world demo (every computer class has to have this). We dial in to the Asterisk system, using the Cisco phone which is configured to dial any of my Asterisk extensions.

We can also forward 815-828-xxxx to any one of these, and dial in from the PSTN (eg using the AT&T phone

Demo of call from the Cisco phone to the AT&T phone, and vice-versa. We need to give the Cisco phone a number, eg 773-409-xxxx. The AT&T phone has a number, too: 312-915-xxxx.

Where do we tie the 409-xxxx number to the actual phone? How does the system know to route the call to this phone?

What do you think would happen if two devices tried to log in with the same userid?

The first time I did this demo I managed to forget to hang up after a speakerphone call from the classroom to my 815-828-xxxx SIP line (while I was trying to demonstrate voicemail-to-email). I was connected for 9625 seconds (2.5 hours), costing me $1.93.

Start (converted to CST)
2012-01-17 18:35:36

Sigh. luser error.

I did subsequently add the following to my sip.conf:

How can we estimate RTT? (I got ~180 ms in my office). One way is the "tapping method": try to tap the phone at a rate where each tap coincides with the echo of the previous tap. Then check the time needed for 10-20 taps, and divide.

Now call the SIP phone from my cellphone. What is the RTT?

Call extension 2000 from the cisco phone, while watching the Asterisk "console". What happens?

Now call 2001.

I wanted to change from CALLERID(num) to P-Asserted-Identity. But if the latter is empty, nothing happens, and it is empty if I call from my own phone. So let's change it to the 773-409-4359 number.

An Asterisk extension is like a script, triggered by a matching dial pattern. It might be a literal extension, but it can be other names too. The Dial command tries to connect that number to a channel, defined in sip.conf.

If the Dial command times out, we generally want to pass the call on to voice mail, but not if the Dial command completes a call!

Dialing out with .call files

Here is a copy of the file:

Channel: SIP/flowroute/1773409xxxx
Callerid: 1815828xxxx
Application: Playback
Data: cantdo

This is to copy a "call file" into the Asterisk outbound spool directory /var/spool/asterisk/outbound, at which point Asterisk will place the call. File permissions have to be just so, so I use the script "makecall" to copy the .call file.

For Asterisk 13 [2015], I had to manually start with
    module load
from the Asterisk console (reached via asterisk -r)


Several software packages provide telephone emulation. One is Ekiga.

Configuring Ekiga

The ekiga softphone can be a bit peculiar to configure. On the Edit -> Accounts dialog, the following should be entered:

You can probably leave the port number (5060) alone. If you wish to set it, you will need regedit (windows) or gconf-editor (linux).

If you dial a number, say 2001, the url shown in the box below the dialpad is often sip:2001. It needs to be, however, in order to work.

The Asterisk open-source telephony project was started by Jim Dixon (hardware) and Mark Spencer. Dixon was a telecom engineer who worked with ATT 3b20's, and noticed that PC hardware was, in theory anyway, catching up (or surpassing it). Around 1999, for an early Pentium system, he developed a card with FXS and FXO ports. Because this promised to revolutionize telephony, he named the cards for Emiliano Zapata, the Mexican revolutionary.

At one point I assembled a phone switch built around linux and asterisk and an analog TDM410 card; the card had 3 FXS ports, 1 FXO port, and hardware echo cancellation.

Asterisk can be used for many things (for example, it makes a darned fine answering machine), but one of the most basic is as a private phone switch, known in the telecom world as a Private Branch eXchange, or PBX.

Basically, a phone switch (Asterix or proprietary ATT or something else) consists of:
We'll ignore call set-up for the moment. While you are making a call, your voice data is collected one or two bytes at a time by the card with the FXS port. The CPU is interrupted regularly, and the card driver turns that voice sample over to the telephony software. The software figures out which call it's part of, and puts the sample into the outbound-voice queue of the appropriate outbound port.

One call can thus involve up to 8,000 interrupts / second. For CPUs, this is not a very big number, although some older motherboard designs made interrupts very expensive. The Zapata cards buffer the data 1ms at a time (8 bytes), so they interrupt the CPU once per ms (probably independent of the number of calls). With efficient interrupting (and perhaps some buffering), a standard single-cpu PC can easily support 24 lines.

An alternative to FXS ports on cards is a channel bank: a hardware device with 24 FXS/FXO ports on one side and a T1 line on the other. T1 lines are, in the telecom world, bundles of 24 DS0 lines. You then connect the PBX to the T1 (using a T1 card).

Asterisk voicemail

To get your messages, dial your extension and press "*". Then dial your password, normally the same as your extension.

Note that asterisk can be configured to email you your messages (in addition to leaving them in your mailbox).

Demo of voicemail/email

Loyola has had some interest in this feature since the mid-1990's, but with the Audix system it was too expensive. (Also, we asked once, and were told, "nobody ever asked us for that before!")

To set up an asterisk PBX that does not connect to the larger world phone system, you can assign extensions arbitrarily. But in the real world you have to get numbers from your provider.

If you are buying a separate line to the telco office for each of your phones ("line" in the sense of both the physical line and the accounting), then you don't need a PBX.

If you're setting up your own PBX, you need
Question: how many trunk lines do we need? If at any moment we have more people wanting to call out than we have lines, some of them will get the no-trunk-available signal (traditionally the "fast busy" or reorder signal). The number of trunk lines should exceed the peak-hour average number of outbound calls, but exceed by how much? The margin of safety needed gets smaller (at least as a percentage) as your organization gets larger.

Suppose we have a small number of trunk lines from the telco that come into our PBX FXO ports, and many more internal phones connected to our PBX FXS ports. Outbound calls are straightforward: the telco doesn't really need to know who's placing the call (except that we may want to cooperate with Caller ID by providing "CID" information). But what about inbound calls? To which internal phone should it be routed? Typically, we get a block of phone numbers from the telco, and use those (or straightforward mods of those) for our internal phone extensions. Then, when an inbound call arrives, our PBX uses Direct Inward Dial, or DID, information attached to the beginning of the call (often in analog form) in order to identify the desired extension. The PBX then connects the call to that extension.

PBX terminology


In most PBXes, Asterisk or not, everything is an extension:
Early on in the configuration process you typically need to set the number of digits in extensions, eg 3 or 4 or 5 (Asterisk is more flexible in this regard).

Extensions are usually allocated in RANGES, eg 2000-2999. Some extensions (the "administrative" ones) might simply not be dialable at all by ordinary extensions. Asterisk achieves this by allowing you to put different extensions in different contexts. A context begins with a context name in [ ]. An extension in one context cannot dial an extension in another context unless some provision is made to allow it. In fact, the same extension may appear in a different context, and represent an entirely different phone.

In Asterisk, we will usually define all phone features for an extension. Then, to connect the extension to an actual line, eg from flowroute, we use:

    exten => 17734094359,1,Goto(default,3031,1)

This means that external number 17734094359 is connected to extension 3031 in the context "default", which in turn connects to the cisco phone usually in my office.

The internal extensions may or may not exactly agree with the low-order digits of the lines provided by your telecom provider.

Call Paths

A call path is a set of responses over time if a call is not answered; eg sending to voicemail at T=20 seconds. Here is our notation for this normal call path:
          extension (ring 3x)
     ⟶ voicemail

(Actually, ringing 3 times is traditionally 18 seconds, though with ringtones counting the number of rings is sort of irrelevant.)

Here is a more elaborate alternative:
         manager extension (ring 3x)
    ⟶ assistant manager (ring 3x)
    ⟶ call group in sales (ring 3x)
    ⟶ outcall to somebody's cell
    ⟶ voicemail


This means forwarding a call to an outside number. There are several common problems with this:
  1. Your organization now has to pay the cost of the outbound (long distance, international, etc). The person who placed the call has no idea this charge will be incurred, and so may not use discretion.
  2. This means one call from the PSTN to the outcalled extension ties up two trunk lines: one for the incoming call, and one for the outcall.
  3. People sometimes try hacking the outcall system to allow free long-distance calls. If someone can break in and change the outcalled number, they can change it to the number of their sister in Australia, and then call the local extension forwarded to the outcall number to be connected to her.

Auto Attendants

These are lines with simple programs on them to answer your call and ask you to enter various digits to do things. Typically each AA will "live" on a special administrative extension (perhaps not one normally dialable), and be "connected" to a regular extension on an as-needed basis.

The AA messages can be set to change at different times of day; that is, you can have a different message after hours.

Some AA systems take all their messages from voicemail systems; this allows easy recording.

Some AA systems do mean things like telling you to dial 0 for operator, and then forward you back to the top level of the AA system.

Trunk lines

These are what you buy a bunch of from your telecom provider. Each of them has its own number, eg 4106852808. Trunk lines are sometimes known as Direct Inward Dials or DIDs.

Some trunk lines might go to individual desks.

Trunk group: groups of trunk lines, applicable only to traditional trunks. They are not applicable to VoIP. If someone dials in on a trunk line, what happens may depend on what trunk group the line belongs to. For example, suppose we forward Trunk Group 1 (TG1) to the administrative extension 8000, not normally dialable (perhaps it is an auto attendant). TG2 might forward to 8002.

Hunt groups

Hunt groups are like trunk groups, for internal calls. It involves creating a call path that tries several phones..
Make x9000 a hunt group, HG1.

1st: ring 3001 (ring 3x)
2nd: ring 3002 (ring 3x)
3rd: ring 3003 (...)
We keep trying different phones, SERIALLY

Often hunt groups simply ring the first available (non-busy) phone.

Weighted Hunt Group

Decide what to do based on who has not received any calls, or who has received the fewest calls so far that day (the latter is the most common). This distributes the workload more evenly over your operators (or distributes the opportunities more evenly over your salespeople).

Call Groups

In a Hunt Group, different phones are tried in sequence. In a call group, different phones are tried in parallel. A call group is what you get if you register several SIP phones with the same username, although many PBXs also provide a higher-level option for that.

Call groups seem to be used less often, perhaps because their utility is not understood.

Good call group example: peter's cell, peter's office, peter's office at home

Another good call group: everyone who is on call at the moment

A combination of a hunt group and a call group: the hunt group is main_sales_extension ⟶ x8003.
x8003 is then a call group to all sales phones. This way, if someone doesn't answer the main extension, everyone's phone will ring.

Call Parking

The idea here is to allow a call to be put on hold by extension A, and then picked up by extension B. Often call parking is used in conjunction with paging: sending out an announcement "would someone please pick up the call I parked at extension 7000?"

To park a call, you transfer it to an extension in a parking lot. Often there is a generic "park" button, and the phone tells you the extension at which the call was parked.

Anyone else can pick up the call by dialing that extension.

One use of parking is for an employee to answer a call, park it, go down the hall to look up a file, and then pick up and finish the call from the second location.

Conference Calling

In asterisk's extensions.conf and meetme.conf, I have defined extension 4000 to be for conferences. To make that number accessible to outside users, let's first connect the 409-4359 number to it:

    exten => 17734094359,1,Goto(default,4000,1)

Now we can call in to this and join the conference.

Outgoing Trunk Groups

These are sort of obsolete, but for the record here goes:

TG1 might be only for local calls
TG2 might be for local + long-distance

Dial 1 first to get TG2 (a caller may get reorder if no line in TG2 is available)

There may be other digits required, or which get special treatment.

The traditional justification for such things was that only some lines would have long-distance service attached to them, which was a cost savings at one time.

10-digit NXX-XXX-XXXX : get TG1 or TG2
9876-1NXX-XXX-XXXX: special code for managers

Starting in Maryland, and now spread to many other locations, all calls, even local ones, dialed through public utilities must use (at least) 10 digits: NXX-XXX-XXXX. There's no more dialing 555-1234.

We can also ban outbound calls, for all extensions or for extensions of the form 21XX, or whatever.