text
stringlengths
0
152
etc.)
• A password
If it’s getting complicated, you’ve probably gone too deep. Keep it simple. If the prod‐
uct doesn’t have good documentation, then it might not be the right product for you.
For most SIP phones you can find instructions on the web for how to register them to
Asterisk.
If you register a second device (you have four of them now!), you can make test calls
between them.
Spend a bit of time on this and make sure you understand it all. It’s all critical to
everything that follows.
Under the Hood: Your First Call
In order to get you thinking about what is happening under the hood, we’re going to
briefly cover some of what is actually happening with the SIP protocol when two sets
on the same Asterisk system call each other.
74
|
Chapter 5: User Device Configuration
Asterisk as a B2BUA
Bear in mind that there are actually two calls going on here: one
from the originating set to Asterisk, and another from Asterisk to
the destination set. SIP is a peer-to-peer protocol, and from the
perspective of the protocol there are two calls happening. The SIP
protocol is not aware that Asterisk is bridging the calls; each set
understands its connection to Asterisk, with no real knowledge of
the set on the other side. It is for this reason that Asterisk is often
referred to as a B2BUA (Back to Back User Agent). This is also why
it is so easy to bridge different protocols together using Asterisk.
For the call you just made, the dialogs shown in Figure 5-3 will have taken place.
For more details on how SIP messaging works, please refer to the SIP RFC.
Figure 5-3. SIP dialogs
Conclusion
In this chapter you learned best practices for device naming by abstracting the con‐
cepts of users, extension numbers, and devices, and how to define the device configu‐
ration and authentication parameters in the channel configuration files. Next, we’ll
delve into the magic of Asterisk that is the dialplan, and see how simple things can
create great results.
Conclusion
|
75
CHAPTER 6
Dialplan Basics
Everything should be made as simple as possible, but not simpler.
—Albert Einstein
The dialplan is the heart of your Asterisk system. It defines how calls flow into and
out of the system. The dialplan is written in a scripting language, which specifies
instructions that Asterisk follows in response to calls arriving from channels. In con‐
trast to traditional phone systems, Asterisk’s dialplan is fully customizable.
Experienced software developers find Asterisk dialplan code archaic, and often prefer
to control call flow using Asterisk APIs such as AMI and ARI (which we will discuss
in later chapters). Regardless of your plans in this regard, learning how Asterisk
behaves is far easier if you understand dialplan first. It is perhaps also worth noting
that Asterisk dialplan is performance-tuned, and is therefore the fastest way to exe‐
cute call flow in terms of responsiveness and minimal load on the system. Dialplan is
fast.
This chapter introduces the essential concepts of the dialplan, which will form the
basis of any dialplan you write. Do not skip too much of this chapter, since the exam‐
ples build on each other, and it is so fundamentally important to Asterisk. Please also
note that this chapter is by no means an exhaustive survey of all the possible things
dialplans can do; our aim is to cover just the essentials. We’ll cover more advanced
dialplan topics in later chapters. You are encouraged to experiment.
Dialplan Syntax
The Asterisk dialplan is specified in the configuration file named extensions.conf,
located in the /etc/asterisk directory.
77
The dialplan structure is built on four hierarchical components: Contexts, Exten‐
sions, Priorities, and Applications (see Figure 6-1).
Figure 6-1. Dialplan hierarchy
Let’s dive right in.
Sample Configuration Files
A basic extensions.conf file was created as part of the install process earlier in this
book. We are going to build on that file in this chapter.