Updated: 2005-03-24
Created: 2005-03-22
Licensing and disclaimer of warranty
IAX2 SIP, and ENUM are somewhat related standards for telecommunications over an internet (or the Internet) and between that and a PSTN, either public or private.
Telecommunications happens between endpoints, which are usually software or hardware devices, happens as sessions, each of which has a metadata and data side to it, and open, transfer and close phase, and sessions among endpoints are often, but not necessarily, mediated by switches, which perform a role similar to that of routers in networking or proxies in HTTP sessions.
Opening a sessions is often referred to as a call, because typically one endpoint calls the other, either directly or via one or more switches.
Sessions may be opened between two or more endpoints directly, in which case there is a direction connection between the endpoints, or via one or more switches, which relay the session to each other over more than one connection. The mechanisms that support connections are called transports, and usually these are either some IP based protocol, or an internal or external phone system, interfaced usually via a network card or a POTS/ISDN card.
Endpoints and switches must have at least one address (for example, a wall socket number for a phone), that allows them to be connected to, and the called endpoint usually also has one or more names; names usually are simple strings or numbers, or more commonly they have a hierarchical structures, usually as URI strings or ITU E.164 numbers.
If a session is opened via a switch, the switch may then continue to act as an intermediary, or only for the session itself but not for the data communicated over the session, or neither, handing further maintenance of the session and the transfer of data directly to the endpoints.
There are several conditions for a sessions to be established:
As a rule endpoint addresses are not used directly to start sessions but resolved from endpoint names when connections need to be established. Switches usually resolve endpoint names before connecting sessions to them. A switch usually has a list of the names and addresses of some endpoints, and a list of switches each of which has its own list of known endpoints; as a rule name to address resolution is then hierarchical based on the hierarchical structure of most names.
IAX2 and SIP are protocols used in opening a session, and ENUM is a convention that allows using the IP DNS to turn PSTN style location information like ITU E.164 telephone numbers into the address of an endpoint or a switch, that is usually an IP address.
A multiprotocol switch is one that mediates sessions over multiple protocols, and a transparent multiprotocol switch is one that can use different protocols for caller and callee connections converting them as necessary.
The following notes will discuss in some detail the structure configuration and operation of Asterisk, a transparent multiprotocol switch program, which supports both the IAX2 and SIP protocols, and the PSTN sessions, in any combination on the caller and callee side.
Asterisk is a transparent multiprotocol switch, and therefore it can help endpoints open sessions even if they don't have common connection protocols.
This means that a PSTN endpoint can call a SIP endpoint or a IAX2 endpoint or PSTN one via Asterisk, with the caller using GSM data compression and the callee expecting H.723 data compression, or any other combination.
Sessions mediated by Asterisk are usually opened after an endpoint calls an Asterisk instance and presents a request to mediate a session to a named endpoint. In Asterisk configurations endpoint names are called extensions.
Asterisk does not have any builtin rules or restrictions on the
syntax of an extension or its lexicon, but usually extensions
have the same syntax as ITU E.164 numbers, and the same
lexicon, which is the 10 digits plus octothorpe
(#
), asterisk (*
) and the letters
A
, B
, C
and
D
(the letters are never used, so ignore them).
Extensions however cal also be arbitrary strings, and these are often used to name endpoints that are meant to be called only over IP, as most IP based protocols allow strings as endpoint names. A typical use is for online void chat rooms.
An Asterisk dialplan is contained in a file called
usually extensions.conf
and consists of a set of
contexts each of which contains a sequence of
rules specifying precisely how to satisfy a request
to open a session to a particular extension or group of
extensions.
A call to an extension is usually satisfied by either:
As a rule the dialplan will group the extensions of external
endpoints by their leading digits, and relay calls to such groups
to some other switch; for example extensions beginning with the
international prefix (e.g. 00
) may be relayed to a
IAX2 to PSTN switch at some service provider, those beginning with
the national prefix (e.g. 0
) may be switched to a
a SIP service provider's switch, and those without to a PSTN
interface card. The extensions for internal endpoints will
usually lead Asterisk to connect the call directly to the
endpoint, using IAX2, SIP or some PBX hardware.
Each type of endpoint is handled by a module for that channel.
An important aspect of Asterisk is that it is not just multiprotocol and transparent at that, but that it is also perfectly symmetrical among its channels, in that by itself it does not restrict which endpoints it can switch between.
However, as a rule, the user of an Asterisk instance will want to partitions endpoints in at least two classes, internal and external, and configure it so as allow internal endpoints to call other internal endpoints, or external points, an external endpoints to call internal endpoints, but not to allow external endpoints to call other external endpoints via the Asterisk instance. The reason for this is that for Asterisk to connect sessions to external endpoints usually involves some cost.
Endpoints belong to channels, and each channel's module has its
own configuration, contained for example in a file called
iax.conf
for IAX2 endpoints and
sip.conf
for SIP endpoints.
These configurations consist of a set of endpoint definitions (which can be other switches); each definition usually contains some form of endpoint identification, an extension that is its name, and the name of a context in the dialplan to be used to switch calls incoming from that endpoint.
As a rule, only internal endpoints and switches will be listed in a channel configuration: when a call is received by Asterisk, the target extension will be classified in the dialplan as either the label for an internal endpoint, and then it will be forwarded to that endpoint, or for an external one, and then the dialplan will indicate an external switch to which the call can be relayed.
After a session has been opened the session data can then flow among the endpoints, passing either via the switches involved in its opening or directly among the endpoints, if this is possible and allowed.
Apart from converting session data if required, Asterisk usually does not participate in a session once fully connected, except to collect statistics, and in an important special case, where the Asterisk instance is the endpoint itself.
An Asterisk instance can be an endpoint as the caller or the callee, but it is far more common for it to be the callee.
As the callee endpoint, Asterisk can provide a number of services to the caller endpoint, for example:
Configuring Asterisk involves creating the contents ofa few (or many) files, usually at least:
extensions.conf
contains the dialplan, where a
number of contexts are used to handle differently different
groups of extensions.iax.conf
contains the list of known IAX2
endpoints, either phones (almost always internal) or switches
(almost always external); currently most IAX2 endpoints will
be switches, and in particular Asterisk switches run by some
service provider as gateways to some PSTN.sip.conf
contains the list of known SIP
endpoints, similar to the list of IAX2 endpoints. Currently
most such endpoints will be hardware or software phones rather
than switches. There are of course SIP switches run by service
providers as gateways, but given that SIP is not as nice a
protocol as IAX2, it is more efficient, especially if one has
many sessions, to use a IAX2 gateway.Often Asterisk is used in these situations:
The configuration notes in this document are mostly about the small scale setups, with the following core assumptions:
Some other configuration will also be discussed in passing:
Several things need to be prepared:
premiumnumbers.
We shall discuss below first the the setting up of a dial plan, then soft phone and gateway endpoints configuration.
An Asterisk dialplan defines how a request to switch a session from an endpoint to another endpoint is handled.
This is done primarily by looking at the extension to be called, and classifying it into various classes, where all the extensions of the same class are switched similarly.
Sometimes the switching also depends on the characteristics of the caller (among the characteristics may be the extension, but usually the most important will be either the authenticated user name or the address), primarily to determine whether the caller is internal or external; as a rule external callers should not be able to have their sessions switched to external extensions, but only to internal ones.
Usually a dialplan contains these elements: