What Are The Drone Anti-jamming Systems Technology?
Asterisk Complete Training
1. E-Learning
Complete Deck of Slides of the
Complete Asterisk Training
You can enroll at:
http://bit.ly/2E6U7fP
2. E-Learning
Books, eBooks and Other Trainings
From the same Author
Online Trainings
Complete Asterisk Training Coupon http://bit.ly/2E6U7fP
Understanding and Troubleshooting SIP http://bit.ly/2WZKkzy
VoIP Design Training Coupon http://bit.ly/2tlLFmG
VoIP Hacking Training Coupon http://bit.ly/2GL5MCT
Quick Start to OpenSIPS Coupon http://bit.ly/2Bt72XJ
Books
Complete Asterisk Training Paperback and Kindle Book https://amzn.to/2tm7TFb
Complete Asterisk Training eBook PDF http://bit.ly/2UUebHG
Building Telephony Systems with OpenSIPS http://bit.ly/2SsUt9a
4. E-Learning
• By the end of this training you should be able to:
– Understand what is Asterisk and where it can be applied
– Choose the appropriate hardware and software for your
project
– Install Asterisk
– Build a simple PBX with SIP phones and SIP trunks
– Call between phones to a SIP trunk and from a SIP trunk
– Configure an IVR and Auto-Attendant to receive calls
– Configure a Conference Room
– Configure a VoiceMail Server
– Understand how to integrate applications with Asterisk
Objectives of the training
5. E-Learning
• Most chapters have Labs
• You will need Virtual Box installed in your
notebook or laptop
• At the end of the training you should have a
simple system ready to run
Practical Training
7. E-Learning
• By the end of this chapter you should be
able to:
– Describe what Asterisk is
– Understand the Asterisk ecosystem
– Select a hardware/software for your project
– Understand the Asterisk arquitecture
– Point common usage scenarios
– Find documentation and information
Objectives
8. E-Learning
What is it?
Asterisk is a PBX implemented as an open source software. It was
originally created by Mark Spencer in 1999. As any other PBX it
allows you to connect phones and make calls. With the passage of
time Asterisk has becoma a major telephony platform for applications
such as Dialers, Call Centers, Interactive Voice, Response,
SoftSwitches. The imagination is the limit.
13. E-Learning
Which hardware to use?
Phone
Company
IP Phones
Analog Telephone Adapters
ISDN and Analog Lines
SIP
Provider
Internet
Telephony
Service
Provider
Softphones
27. E-Learning
Asterisk as an application
server
TELCO
E1/Analog
E1/Analog
Asterisk PBX
IVR
Conference
VoiceMail
28. E-Learning
Asterisk as a Contact Center
1-800
Agent1 Agent2 AgentN
DAC
Ringall,RoundRobin,Rrmemory,
LeastRecent,Priority
Call Queue
29. E-Learning
Asterisk vs. Conventional
system
IP Phones
Softswitch
PSTN Gateway
VoiceMail
Music On Hold
Analog Telephone
Adapter
CISCO IP PHONE
7905SERIES
1 2
A B C
3
D E F
4 5
J K L
6
M N OGH I
7 8
T U V
9
W X Y ZP Q R S
* 0 #
4
7
P QRS
*
CISCO IPPHONE
7905SERIE S
1 2
A B C
3
DE F
4 5
J KL
6
M N OG HI
7 8
TU V
9
W X YZP QR S
* 0 #
4
7
PQRS
*
CISCO IPPHONE
7905SERIE S
1 2
A B C
3
DE F
4 5
J KL
6
M N OG HI
7 8
TU V
9
W X YZP QR S
* 0 #
4
7
PQRS
*
Telco or PBX
Telco or PBX
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
IP Phones
Softswitch
Gateway for
Public
Networks
Unified
Messaging
System
Gateway for
Analog
Telephony
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
CISCO IP PHONE
7905SERIES
1 2
A B C
3
DE F
4 5
J K L
6
M N OG H I
7 8
T U V
9
W XY ZP QR S
* 0 #
4
7
P QRS
*
30. E-Learning
Where to find documentation
• wiki.asterisk.org
• www.asterisk.org
• www.voip-info.org
31. E-Learning
• AGI – Asterisk Gateway Interface
• AMI – Asterisk Managment Interface
• ARI – Asterisk Rest Interface
Integration with other systems
34. E-Learning
• By the end of this chapter you should be
able to:
– Dimension the required hardware
– Install
– Start and Stop
– Connect to the console
– Start Asterisk in the Linux boot
Objectives
36. E-Learning
• Empiric Process
• Use SIPP to test exceptions
• General Rules (80/20)
– 80% or more of the Asterisk users have less than 30
simultaneous calls and no more than 240 users. Any modern
server could take this load.
– If you belong to the other 20%, test using SIPP. Use a large
security coefficient. So if the test got 3000 simultaneous
calls, use a SC=4 and dimension for no more than 750.
Dimensioning
37. E-Learning
• Simultaneous calls
• Registered devices
• Transcoding
– Pay attention to high complexity codecs 1G729 = 13 MIPS, 1 narrowband
OPUS=30 Mflops.
• Call Attempts per second (CAPS)
– Load with more tha 100 CAPS can be problematic
Impairment factors
38. E-Learning
• CDRs in a database
– Each CDR generates I/Os for data and indexes
– SATA HD supports only 75 IOPS
• Recording. Recording is intensive in terms of
disk I/O
– Try to keep below 200 in a SAS 15K RPM disk
• Applications
– Conference Rooms, Queues and IVRs affect the
performance in an unpredictable way. It is not
possible to predict the performance of a unknow
application before it has been developed
Hardware notes
40. E-Learning
• From te authors experience
– Use a good network switch and good interface
cards.
– Use Echo Cancelling by hardware (cards)
– Use a Transcoding card if you plan to transcode
a large amount of calls
Tips
42. E-Learning
Echo test with media
• Command line
• sipp -s 1000 10.8.1.46:5060 -sf sipp_pcap.xml
-i 10.8.1.46 -d 90000
43. E-Learning
Echo Test with media calls per
second
37
35
33
32 32
29
30
31
32
33
34
35
36
37
38
Asterisk 11 Asterisk 13 Asterisk 15
chan_sip chan_pjsip
44. E-Learning
Echo Test with media simultaneous
calls
3338
3076
2820
2700 2700
0
500
1000
1500
2000
2500
3000
3500
4000
Asterisk 11 Asterisk 13 Asterisk 15
chan_sip chan_pjsip
45. E-Learning
• Asterisk requires the following packages
– Asterisk
• Optionals
– dahdi-linux – drivers das placas
– dahdi-tools – utilitários para as placas
– libpri – usado para placas ISDN
Installation Packages
46. E-Learning
• From the source code
– Flexible
– Optmized
• From packages
– No official maintainers
– Usually not the latest version
– Simple and quick
• Distro
– FreePBX
– AsteriskNOW
How to install?
47. E-Learning
• The variety is huge
• Trend
– Use SIP trunking , forget cards
• If you don't have access to a SIP trunk
– Digium, Sangoma, OpenVOX, Aligera...
– Alternative cheap hardware (only If you have a hacker soul )
• CHAN_DONGLE https://github.com/bg111/asterisk-chan-dongle
• X100P (1 FXO)
Telephony Cards
49. E-Learning
• In this chapter you've learned how to
– Dimansion the hardware required for Asterisk
– Install Asterisk
– Start and Stop Linux
– Start Asterisk at the boot
– Connect to the console
Summary
51. E-Learning
• Part I – SIP extensions
• Part II – SIP trunks
• Part III – Dialplan
• Part IV – Adding features
Sections
52. E-Learning
By the end of this section you should be able to:
• Build a PBX with the following characteristics
– Support IP phones based on SIP
– Connect to a VoIP operator using a SIP trunk
– Dial between extensions
– Dial to external destination using 9 as a prefix
– Missed calls sent to the voicemail
– Conference room in the extension 5
– Incoming calls directed to an Operator or AutoAttendant
Objectives
53. E-Learning
Grammar Object Creation Conf. File Example
Simple group All in the same line extensions.conf exten=>4000,1,Dial(SIP/4000)
Inheritance Options defined before
object declaration
chan_dahdi.conf [channels]
context=default
signalling=fxs_ks
group=1
channel => 1
Complex entities Each entity receives a
context
sip.conf,
iax.conf
[cisco]
type=friend
secret=mysecret
host=10.1.30.50
context=from-internal
[xlite]
type=friend
secret=xlite
host=dynamic
Context=from-internal
Asterisk Grammar
62. E-Learning
• Becoming mainstream on Telcos
• Digital, high volume only limited to bandwidth
• No investment on legacy hardware
• Savings on rack space and eletricity
SIP trunks
63. E-Learning
• Providers's IP address
• Name and Password
• Some allow IP authentication
• Authentication per transaction
– Register
– Calls
• Return Address
– Which extension to ring when receiving an
incoming call
SIP trunk parameters
76. E-Learning
Pattern
Examples
_ (Underscore) Pattern start character
. (point) Wildcard one or more digits
! (exclamation) Wildcard one or more digits immediatey (ISDN)
[123-7] Any values in brackets (1,2,3a7)
X Any digit from 0-9
Z Any digit from 1-9
N Any digit from 2-9
77. E-Learning
Asterisk Standard Extensions
i : Invalid
s : Start
h : Hangup
t : Timeout
T : AbsoluteTimeout
o : Operator
a : used when “*” is pressed in the
voicemail menu
fax : used for fax detection
Talk : used for backgroundDetect()
Standard extensions
78. E-Learning
• Global
set(Global(variable)=content)
• Channel
${EXTEN} Called extension
${CONTEXT} Current context
${CALLERID} Current callerID
${PRIORITY} Current Priority
• Application
${DIALEDTIME}
${ANSWEREDTIME}
${DIALSTATUS}
CHANUNAVAIL
CONGESTION
NOANSWER
BUSY
Variables
81. E-Learning
Applications
Applications to build a simple dial plan
answer() – Answers a channel
dial() – Dial another channel
hangup() – Hangup a channel
playback() – Play na audio file
goto() – Jump to the next priority,
extension or context
82. E-Learning
The application Dial()
;Dialing a channel
Dial(type/identifier,timeout,options, URL)
;Dialing to multiple channels
Dial(Technology/resource[&Tech2/resource2...][|timeout][|opt
ions][|URL]):
exten=>_6XXX,1,Dial(SIP/${EXTEN},60,Tt)
83. E-Learning
Building a PBX, contexts
Context Description
from-siptrunk Calls coming from the siptrunk
from-internal All extensions SIP and IAX
84. E-Learning
Building the PBX
Dialing between extensions
[from-internal]
exten=>6000,1,dial(SIP/pap21A,20)
exten=>6001,1,dial(SIP/xlite1,20)
Dialing to the PSTN prefixing 9
[from-internal]
;Dialing to the PSTN via SIP trunk
exten=>_9.,1,dial(SIP/siptrunk/${EXTEN:1},20)
CLI>dialplan reload
85. E-Learning
Incoming Call from the SIP trunk
[globals]
OPERATOR=>SIP/6000
[from-siptrunk]
exten=>9999,1,dial(${OPERATOR},20)
Why 9999?
Remember:
register => login:pass@domain:port/9999
In the register command you define the
extension called for incoming calls
88. E-Learning
• By the end of this chapter you will be able to:
– Record prompts directly from your phone
– Build an autoattendant
– Build a simple IVR
– Send missed calls to a voicemail
– Send calls to an audioconference room
Objectives
89. E-Learning
Recording Messages in a file
[from-internal]
exten => _4.,1,Record(${EXTEN:1}:gsm)
exten => _4.,n,wait(1)
exten => _4.,n,Playback(${EXTEN:1})
exten => _4.,n,Hangup()
Dialing 4100 will record 100.gsm
Dialing 4menu will record menu.gsm
Dialing 4greeting will record greeting.gsm
93. E-Learning
Voicemailmain()
exten=>9000,1,VoiceMailMain()
Level#1
0 Mailbox options
1 Read Voicemail messages
2 Change folders
* Help
# Exit
1 Record your unavailable message
2 Record your busy message
3 Record your name
4 Record your temporary message
5 Change your password
* return to the main menu
3 Advanced Options
4 Play previous message
5 Repeat current message
6 Play next message
7 Delete current message
8 Forward message to another mailbox
9 Save message in folder
0 inbox
1 old
2 work
3 family
4 friends
5 cust1
6 cust2
1 Accept
2 Review
3 Re-record
0 Reach
operator
1 Reply
2 Call Back
3 Envelope
4 Outgoing
call
VoiceMailMain()
Menus
94. E-Learning
Conference
ConfBridge
Conference bridge application.
[Description]
Enters the user into a specified conference bridge. The user can
exit the
conference by hangup or DTMF menu option.
This application sets the following channel variable upon
completion:
${CONFBRIDGE_RESULT}:
FAILED:The channel encountered an error and could not enter
the conference.
HANGUP:The channel exited the conference by hanging up.
KICKED:The channel was kicked from the conference.
ENDMARKED:The channel left the conference as a result of the
last marked
user leaving.
DTMF:The channel pressed a DTMF sequence to exit the
conference.
TIMEOUT:The channel reached its configured timeout.
[Syntax]
ConfBridge(conference[,bridge_profile[,user_profile[,menu]]])
exten=5,1,Confbridge(main)
95. E-Learning
Summary
Ending this section you are now able to:
• Understand and build configuration files
• Build a simple PBX
• Install and configure a SIP trunk
• Build a simple dial plan
• Dial between extensions and external destinations
• Receive calls in the operator
• Build a simple autoattendant system
98. E-Learning
Objectives
• By the end of this chapter you should be able
to use:
– Call Transfer
– Call Pickup
– Three-way conference
– Call Parking
– Call Recording
– Music On Hold
– Follow me
99. E-Learning
Asterisk
Music on hold
Call transfer
Call parking
Call pickup
Call recording
Dialplan
Follow-me
Blacklist
In the phone
Call hold
Call transfer
Three-way conference
Message waiting indicator
Where resources are implemented
100. E-Learning
Call Transfer
Blind transfer
You need to enable in the dial() applicationwith the
options “tT”;
Press “#” during the call;
Dial the extension to transfer to
Hangup the call
If the call does not go thru, it will ring back
Attended Transfer
Enabled on features.conf (disabled by default);
Dial “*2” to start the transfer;
Dial the destination extension
Talk to the person on the destination
Hangup the call
The system transfers the call
101. E-Learning
Call Parking
701 702 703 704
705 706 707 708
709 710 711 712
713 714 715 716
717 718 719 720
700
Parking Lot
1. Transfer the call to the
extension 700.
2. The call is parked in the
first free slot. The slot is
announced to you.
3. Call the extension
where the call was parked
and you resume the call.
103. E-Learning
Call Recording
• Call MixMonitor before the Dial command.
• In line recording – automixmon
– Don't forget the X option in the Dial() command
MixMonitor(<file>.<ext>[|<options>[|<command>]])
Records The audio on the current channel to the specified
file.
Valid Options:
b – Only save audio to the file while the channel is
bridged. *does not include conferences*
a – Append to the file instead of overwriting it.
v(<x>) – Adjust the heard volume by a factor of <x> -4/4.
V(<x>) – Adjust the spoken volume by a factor of <x> -4/4.
W(<x>) – Adjust the overall volume by a factor of <x> -4/4.
104. E-Learning
• Music on hold is organized in classes
Music on Hold
[default] -> name of the class
mode=files -> files (files,custom,mp3)
directory=moh ->directory where to found the recording in Asterisk format
Applications
MusicOnHold(class,[duration]) -> Play music on hold
Set(CHANNEL(musicclass)=…)-> Set the class for other applications such
as Dial, Queue...
105. E-Learning
• Application to forward a call
FollowMe
[6000]
context => from-internal
number => 9130523456789,30
number => 9130523456788,30
/etc/asterisk/followme.conf
[from-internal]
exten=6000,1,dial(SIP/Zoiper)
exten=6000,n,followme(6000)
/etc/asterisk/extensions.conf
106. E-Learning
• In this lecture you have learned how:
– To transfer calls using the Transfer Button
– To transfer calls using *2 in the PBX
– To do attended and unattended transfers
– To pick-up a call
– To park calls
– To create a 3way conference
Summary
108. E-Learning
• There are some SIP skills that can be useful.
• In this section we will present some of the skills
– To use PJSIP with Asterisk 15 (chan_sip will be
deprecated in the near future)
– chan_sip in depth
Peer matching
Channel naming conventions
– NAT traversal
Connecting phones behind NAT
ALG workarounds
Install Asterisk in the cloud behind NAT
Section overview
109. E-Learning
• Four chapters borrowed from the training
(Understanding and TroubleShooting SIP)
– Introduction to SIP
– SIP addresses and headers
– Media and Codec Selection
• chan_pjsip
• chan_sip
• NAT traversal
– Running clients behind NAT
– Workarounds for SIP ALG
– Running Asterisk in the Cloud behind NAT
Section development
111. E-Learning
• New features
– Multiple registrations
– Multiple transports
– API friendly, easier to develop and extend
• Problems with chan_sip
– Monolythic
– No oficial support, only community
– Can be officially deprecated in the next version
• Problems with chan_pjsip
– low in adoption
– Configuration is more complex
Why?
113. E-Learning
• What is important here?
– Context inclusion
– Dialplan processing order
– Time contexts and GotoIfTime
– General section variable autofallthrough
– In depth look at applications
– Persisting data with AstDB
– Limiting simultaneous calls
– Applications extensions language
Section Overview
115. E-Learning
Dial plan processing order
1. An exact match using dialed number and callerID
2. An exact match using only dialed number
3. A pattern that matches the dialed number
4. A context included in the switch statement
5. An included context
Dialplan processing order
118. E-Learning
• What is important here?
– Why generate CDRs
– Hot to generating CDRs
– How to add extra fields
– How to control, reset and avoid CDRs
– How to send CDRS to a database
Section Overview
119. E-Learning
• Creation
– Channel is created
– Leaves a bridge and is not hungup
– Forked from a prior record
– Enters a multi-party bridge
• Finalized
– Dial completes with status different than ANSWER
– If either party leaves the bridge
– if either channel hangs up
– if CDR is forked
When CDRS are generated
120. E-Learning
CDR Format
Field Type Description Access
accountcode String (20) An account code r/w
src String (80) The Caller ID Number r
dst String (80) The destination extension r
dcontext String (80) The destination context r
clid String (80) The Caller ID with text r
channel String (80) The name of the Party A channel r
dstchannel String (80) The name of the Party B channel r
lastapp String (80) The last application the Party A executed r
lastdata String (80) The application data for the last application r
start Date/time The time the CDR was created r
answer Date/time The time when Party A was answered r
end Date/time The time when the CDR was finished. r
duration Integer The time in seconds from start until end r
billsec Integer The time in seconds from answer until end r
disposition Enum The final known disposition r
amaflags Enum A flag specified on the Party r/w
uniqueid String (32) A unique identifier for the Party A channel r
124. E-Learning
• What is important here?
– What to do when Asterisk does not start
– What to do when a Module does not run
– NoOP() and Verbose()
– Where to find logs and how to rotate them
– How to enable verbose and debug
– Hot to get help
Troubleshooting Asterisk
125. E-Learning
• Use asterisk –vvvc
– Open in console mode, check if some module
is not loading
What to do when Asterisk does not
start?
126. E-Learning
• When a module does not load, its commands
don't exist.
– no such command sip show peers is an
example of this case.
– Try to load manually using module load
chan_sip.so
– Check for UDP/TCP port conflicts using netstat
-tanpu
What to do when a module does not
load
128. E-Learning
Agenda
1. How big is the problem?
2. Anatomy of an attack.
3. Types of attacks
4. How to reduce damage if all previous measures failed
129. E-Learning
How big is the problem?
• AT&T case, 1 million dollar phone bill
Source: https://www.huffpostbrasil.com/entry/michael-smith-att-phone-bill_n_1659136
• Architecture firm received a phone bill of
USD166.000,00
https://www.nytimes.com/2014/10/20/technology/dial-and-redial-phone-hackers-stealing-billions-.html
130. E-Learning
Anatomy of a simple attack.
Step 1 – Buy a Premium Rate Number
Step 2 – Find a vulnerable VoIP device
And call the premium rate number
Step 3 – Withdrawn in the premium number
132. E-Learning
Common ways to get a password
1. SIP Scan and Bruteforce
2. TFTP attacks
3. Phone vulnerabilities
4. PBX web interface vulnerabilities
5. Operating System vulnerabilities
Shell Shock, Heartbleed
133. E-Learning
Under Heavy Attack!
• Basic Scan – sipvicious, friendly-scanner
• Distributed SCAM by W32.Sality virus (discovered by
Symantec/2010)
Source: Symantec http://www.symantec.com/connect/blogs/distributed-cracker-voip
Peer-to-Peer Botnet
Thousands of Corporate PBXs
SIP Scan.
Thousands of
Register Attempts.
134. E-Learning
SIP Scan Mitigation
• Mandatory strong passwords
– 8 digits minimum, special chars…
• Detect multiple authentication failures
– Block IP with Fail2Ban
• Early detection and discard
– Detect specific signatures and patterns
(IPTABLES)
135. E-Learning
TFTP Attack
• Trivial Attack against VoIP Infrastructure
– 1st Option bruteforce tftp server
– 2nd Option sniff tftp files using MitM techniques
TFTP Server
Get file 0001234A5B6C.cfg
Plaintext Configuration File
With credentials in plain text
XML or not
Get file 0001234A5B6D.cfg
…
• Solution
– Use HTTPS or Encrypted config files
136. E-Learning
Attacks on SIP Phones
• How many of you change the default password
for IP phones?
• How many of you update the IP Phone’s
firmware regularly?
Video #1Video #2
137. E-Learning
Tips to prevent attacks
Easy:
1. Use strong passwords
2. Install and configure iptables
3. Limit SSH to specific addresses or networks
4. Limit HTTP access to specific addresses or networks
5. Change the admin password on phones
Hard:
1. Disable the web interface of the phones
138. E-Learning
Damage Control
• Face a simple fact, sooner or later, a system
open to the Internet will be compromised.
• The hacker’s advantage
– Administrators have to defend against all attacks,
while one vulnerability is enough for the attacker!
– The administrator is one, attackers are many!
139. E-Learning
Tips to reduce possible damages?
1. Do not allow all routes to all users.
2. Limit simultaneous calls in International Routes
3. Drop calls after a certain period of time.
4. Use two-way authentication for high-risk international routes
Ex. vmauthenticate(mailbox)
146. E-Learning
• Do not open if:
– Information Requests (Use mailing list, IRC or wiki)
– Support requests: (Use mailing list, IRC or wiki)
– Random wishes and feature requests with no patch
– Business development requests (Asterisk-biz mailing list)
Opening a support case
147. E-Learning
• Evidences
– Do you have strong evidence that it is actually a bug?
– Do you have logs and traces?
– Are you using one of the supported versions?
– All dependencies updated?
– Can you reproduce the problem?
– Are you available to test the fixes?
Before opening
148. E-Learning
• Core Dumps
asterisk –g
Can produce backtraces essential when your
system crashes.
#gdb asterisk corefile
#/var/lib/asterisk/scripts/ast_coredumper core
Debugging
149. E-Learning
• In this chapter you have learned
– How to troubleshoot the most common cases
– How to enable
• Verbose
• Debug
• Logger
– Where to find help
– How and when to open a Ticket
Summary
151. E-Learning
Dispositions
Value Description
NO ANSWER The channel was never answered.
CONGESTION Channel congestion.
FAILED The channel attempted to dial but the call failed
BUSY The remote party was busy.
ANSWERED The channel was answered.
152. E-Learning
• Accountcode or Billing-id
• Amaflags
– Default
– Omit, do not record calls
– Billing, mark for billing
– Documentation mark for documentation
• You can set amaflags on the channel
– sip.conf, example: amaflags=billing
AMAFLAGS and Account Codes
159. E-Learning
In Depth Look at Applications
Applications used in this section
Dial()
Answer()
Hangup()
Background()
Gotoif()
Record()
Playback()
Read()
160. E-Learning
Dial
[Syntax]
Dial(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,options[,U
RL]]])
This application sets the following channel variables:
${DIALEDTIME}: This is the time from dialing a channel until when it is disconnected.
${ANSWEREDTIME}: This is the amount of time for actual call.
${DIALEDPEERNAME}: The name of the outbound channel that answered the call.
${DIALEDPEERNUMBER}: The number that was dialed for the answered outbound channel.
${FORWARDERNAME}: If a call forward occurred, the name of the forwarded channel.
${DIALSTATUS}: This is the status of the call
CHANUNAVAIL
CONGESTION
NOANSWER
BUSY
ANSWER
CANCEL
DONTCALL: For the Privacy and Screening Modes.
TORTURE: For the Privacy and Screening Modes.
INVALIDARGS
161. E-Learning
The most important Dial options
D([called][:calling[:progress]]): Send the specified DTMF strings *after* the
called party has answered, but before the call gets bridged.
k or K Allow the called or calling party respectively to enable parking of the
call by sending the DTMF sequence defined for call parking in "features.conf".
L(x[:y[:z]]): Limits the maximum call time
x - Maximum call time, in milliseconds
y - Warning time, in milliseconds
z - Repeat time, in milliseconds
r([tone]): Indicate ringing to the calling party (False Ring)
tone - Indicate progress to calling party. Send audio 'tone' from the "indications.conf" tonezone currently in
use.
S(x): Hang up the call <x> seconds *after* the called party has answered the call.
162. E-Learning
Asterisk Dial options (cont...)
t or T allow the called or calling party respectively to transfer the calling party
by sending the DTMF sequence defined in "features.conf". This setting does
not perform policy enforcement on transfers initiated by other methods.
x or X allow the called or calling party respectively to enable recording of the
call by sending the DTMF sequence defined for one-touch automixmonitor in
"features.conf".
163. E-Learning
Answer() – Answer a ringing channel
Progress() – Sends a 183 Session Progress
Playback(file,[say,skip,noanswer])
Hangup([causecode]) – Hangup an existing
channel
Answer, Progress,Playback and
Hangup
https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause+Mappings
164. E-Learning
Play an audio file while waiting for digits of an
extension to go to.
[Description]
Background()
Options
s – skip recording if not answered
n - Don't answer the channel before playing the files.
m - Only break if a digit hit matches a one-digit extension
Background
165. E-Learning
Read()
Read()
Read a variable
[Description]
maxdigits -- maximum acceptable number of digits.
option
's' to return immediately if the line is not up,
'i' to play filename as an indication tone from your indications.conf
'n' to read digits even if the line is not up
attempts -- if greater than 1, that many attempts will be made
timeout -- An integer number of seconds to wait for a digit response
167. E-Learning
Record()
Record to a file
[Description]
Options
'a' : append to existing recording rather than replacing
'n' : do not answer, but record anyway if line not yet answered
'q' : quiet (do not play a beep tone)
's' : skip recording if the line is not yet answered
't' : use alternate '*' terminator key (DTMF) instead of default '#'
'x' : ignore all terminator keys (DTMF) and keep recording until hangup
'format' is the format of the file type to be recorded
'silence' is the number of seconds of silence to allow before returning.
'maxduration' is the maximum recording duration in seconds.
Record
173. E-Learning
• In this section you have learned some of the
most important concepts in the dialplan.
– Context inclusion
– Dialplan processing order
– In depth look at some of the main applications
– Asterisk DB
– Application Extensions Language
– Grouping and limiting calls
Section summary
174. E-Learning
1. res_pjsip – The main services and the base layer
2. res_pjsip_session – Media session and addons
3. res_pjsip_messaging – text messages
4. res_pjsip_registrar – registrations
5. res_pjsip_pubsub – subscribe/notify/publish
PJSIP modules
175. E-Learning
1. Endpoints (primary object)
2. AOR (Address of Record)
3. Auth - authentication
4. Transport
5. Registration
6. Identify (By User, IP..., equivalent to peer
matching)
Objects defined in PJSIP
176. E-Learning
PJSIP entity relationship model
Source: wiki.asterisk.org
https://wiki.asterisk.org/wiki/display/AST/PJSIP+Configuration+Sections+and+Relationships
182. E-Learning
• Helpful to troubleshoot SIP
• Excelent article at
https://blogs.asterisk.org/2016/02/24/debugging-
sip-message-traffic-with-pjsip-history/
PJSIP History
184. E-Learning
Access Control Lists ACLs
; Define the ACL in pjsip.conf or acl.conf
[acl]
type=acl
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/24
deny=192.168.0.1
; The ACL configuration is independent of individual endpoint configuration and
; operates on all inbound SIP communication using res_pjsip.
185. E-Learning
• PJSIP is more powerful
– Multiple AORs and Contacts, parallel forking
– Multiple transports
– Easier to extend
– History and Channel Stats
• PJSIP is not simple to use
– Too many objects and sections
– Adoption rate is still very slow
– Less robust, due the lack of a large user base
• No significant performance differences
Comparing channels
188. E-Learning
• By the end of this chapter you should be able to
– Construct a SIP channel acording to the naming
conventions
– Understand how peers are matched for incoming
calls
– Apply the most useful CLI commands to
troubleshoot SIP
– Enable SIP tracing with SIP set debug
– Configure rtptimeout
– Configure QoS tagging
Objectives
189. E-Learning
• Friend – Entity to send and receive calls
• Peer – Entity to send calls
• User – Entity to receive calls
• Host=dynamic, means it can register
Peer Types
190. E-Learning
Peer Matching
A TYPE=USER
SECTION EXISTS AND
MATCHES THE “FROM”
HEADER FI ELD?
CHECK
“FROM”HEADER
FIELD IN THE SIP
PACKET
AGAINST THE
SIP.CONF
YE
S
A TYPE=PEER
SECTION EXISTS AND
MATCHES THE IP
ADRESS DEFINED
IN HOSTS=IP
INSECURE=IN
VITE?
YES
ALLOWGUEST ?
TRUE
ALLOW
USE CONTEXT FROM
GENERAL SECTION
FALSE
DENY
NO NO
MD5
CREDENTIALS
ALLOW/DENY
ALLOW
USE CONTEXT
FROM THE
“USER” SECTION
OK
DENY
NOT OK
NO
MD5
CREDENTIALS
ALLOW
USE CONTEXT
FROM PEER
SECTION
OK
DENY
NOT
OK
YE
S
ALLOW
USE CONTEXT
FROM PEER
SECTION
192. E-Learning
Console Commands
; CLI Commands
; -------------------------------------------------------------
; Useful CLI commands to check peers/users:
; sip show peers Show all SIP peers (including friends)
; sip show registry Show status of hosts we register with
;
; sip set debug on Show all SIP messages
;
; sip reload Reload configuration file
; sip show settings Show the current channel configuration
;
194. E-Learning
RTP timeout
; The settings are settable in
; the global section as well as per device
;
;rtptimeout=60 ; Terminate call if 60 seconds of no RTP or RTCP activity
; on the audio channel
; when we're not on hold. This is to be able to hangup
; a call in the case of a phone disappearing from the net,
; like a powerloss or grandma tripping over a cable.
;rtpholdtimeout=300 ; Terminate call if 300 seconds of no RTP or RTCP activity
; on the audio channel
; when we're on hold (must be > rtptimeout)
;rtpkeepalive=<secs> ; Send keepalives in the RTP stream to keep NAT open
; (default is off - zero)
195. E-Learning
Configure QoS tagging
;tos_sip=cs3 ; Sets TOS for SIP packets.
;tos_audio=ef ; Sets TOS for RTP audio packets.
;tos_video=af41 ; Sets TOS for RTP video packets.
;tos_text=af41 ; Sets TOS for RTP text packets.
;cos_sip=3 ; Sets 802.1p priority for SIP packets.
;cos_audio=5 ; Sets 802.1p priority for RTP audio packets.
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
;cos_text=3 ; Sets 802.1p priority for RTP text packets.
196. E-Learning
NAT on client chan_sip
qualify=yes
directmedia=no
directmedia=nonat
nat=force_rport,comedia
nat = no ; Do no special NAT handling other than RFC3581
nat = force_rport ; Pretend there was an rport parameter even if there wasn't
nat = comedia ; Send media to the port Asterisk received it from regardless
; of where the SDP says to send it.
nat = auto_force_rport ; Set the force_rport option if Asterisk detects NAT (default)
nat = auto_comedia ; Set the comedia option if Asterisk detects NAT
198. E-Learning
Server behind NAT on chan_sip
externaddr = 12.34.56.78 ; use this address.
localnet=192.168.0.0/255.255.0.0 ; RFC 1918 addresses
localnet=10.0.0.0/255.0.0.0 ; Also RFC1918
localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation
localnet=169.254.0.0/255.255.0.0 ; Zero conf local network
externhost=foo.dyndns.net ; refreshed periodically
externrefresh=180 ; change the refresh interval
199. E-Learning
Server behind NAT on PJSIP
[transport-udp-nat]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.0.0/16
external_media_address=203.0.113.1
external_signaling_address=203.0.113.1
external_signaling_port=5060