Asterisk setup in Linux machine
1) Install and setup asterisk server in Ubuntu. Run the asterisk server using below command.
Ex: asterisk -rvvv
asterisk -rvvv swamidas-HP-Laptop-14q-cs0xxx*CLI> |
2) Install sip clients in two different machines which are in the same network in which asterisk server is running.
3) Configure the sip and extensions files. Reload the updated configuration of both sip and extensions using below commands.
Ex: sip reload
dialplan reload
swamidas@swamidas-HP-Laptop-14q-cs0xxx:/etc/asterisk$ cat sip.conf [general] context=default bindaddr=0.0.0.0 nat=force_rport,comedia externip=192.168.84.236 localnet=192.168.84.1/255.255.255.0 qualify=yes [1001] type=friend context=internal host=dynamic secret=password1 dtmfmode=rfc2833 disallow=all allow=ulaw allow=alaw directmedia=no [1002] type=friend context=internal host=dynamic secret=password2 dtmfmode=rfc2833 disallow=all allow=ulaw allow=alaw directmedia=no |
swamidas@swamidas-HP-Laptop-14q-cs0xxx:/etc/asterisk$ cat extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[internal]
exten => 1001,1,Dial(SIP/1001)
exten => 1002,1,Dial(SIP/1002)
[default]
exten => _X.,1,NoOp(Unhandled call to ${EXTEN})
exten => _X.,n,Playback(vm-nobodyavail)
exten => _X.,n,Hangup()
exten => 1001,1,Dial(SIP/1001,20)
exten => 1001,n,NoOp(Dial status for 1001: ${DIALSTATUS})
exten => 1001,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1001,n(busy),Playback(all-circuits-busy-now)
exten => 1001,n(busy),Hangup()
exten => 1001,n(unavail),Playback(vm-nobodyavail)
exten => 1001,n(unavail),Hangup()
exten => 1002,1,Dial(SIP/1002,20)
exten => 1002,n,NoOp(Dial status for 1002: ${DIALSTATUS})
exten => 1002,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1002,n(busy),Playback(all-circuits-busy-now)
exten => 1002,n(busy),Hangup()
exten => 1002,n(unavail),Playback(vm-nobodyavail)
exten => 1002,n(unavail),Hangup()
exten => 500,1,Echo()
exten => 500,n,Hangup() |
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip reload Reloading SIP swamidas-HP-Laptop-14q-cs0xxx*CLI> dialplan reload Dialplan reloaded. [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1001' priority 5 in 'default', label 'busy' already in use at priority 4 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1001' priority 7 in 'default', label 'unavail' already in use at priority 6 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1002' priority 5 in 'default', label 'busy' already in use at priority 4 [Jun 27 12:59:48] WARNING[27757]: pbx.c:7126 add_priority: Extension '1002' priority 7 in 'default', label 'unavail' already in use at priority 6 -- Including switch 'DUNDi/e164' in context 'ael-dundi-e164-switch' |
4) Make sure the ports are being allowed in the asterisk server to listen to the traffic from the clients. Allow ports using below commands,
Ex: sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp
5) Register the sip clients with the asterisk server ip, username and password as configured in the sip.conf file.
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip show peers Name/username Host Dyn Forcerport Comedia ACL Port Status Description 1001/1001 (Unspecified) D Yes Yes 0 UNKNOWN 1002/1002 (Unspecified) D Yes Yes 0 UNKNOWN 2 sip peers [Monitored: 0 online, 2 offline Unmonitored: 0 online, 0 offline] |
6) After successful registration in both the clients, initiate a call between two clients and verify the logs in the asterisk CLI.
swamidas-HP-Laptop-14q-cs0xxx*CLI> sip show peers Name/username Host Dyn Forcerport Comedia ACL Port Status Description 1001/1001 (Unspecified) D Yes Yes 0 UNKNOWN 1002/1002 (Unspecified) D Yes Yes 0 UNKNOWN 2 sip peers [Monitored: 0 online, 2 offline Unmonitored: 0 online, 0 offline] -- Registered SIP '1001' at 192.168.1.16:39563 [Jun 27 11:50:07] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1001' is now Reachable. (337ms / 2000ms) swamidas-HP-Laptop-14q-cs0xxx*CLI> swamidas-HP-Laptop-14q-cs0xxx*CLI> -- Registered SIP '1002' at 192.168.1.4:43325 [Jun 27 12:21:54] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Reachable. (100ms / 2000ms) swamidas-HP-Laptop-14q-cs0xxx*CLI> |
== Using SIP CoS mark 4
== Using SIP RTP CoS mark 5
-- Executing [1001@internal:1] Dial("SIP/1002-00000000", "SIP/1001") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1001
-- SIP/1001-00000001 is ringing
-- SIP/1001-00000001 is ringing
-- SIP/1001-00000001 answered SIP/1002-00000000
-- Channel SIP/1001-00000001 joined 'simple_bridge' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
-- Channel SIP/1002-00000000 joined 'simple_bridge' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
[Jun 27 13:01:23] WARNING[23025]: chan_sip.c:4151 retrans_pkt: Retransmission timeout reached on transmission SBLw7uYy-wTk5rEGVuN4lQ.. for seqno 2 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 16446ms with no response
[Jun 27 13:01:23] WARNING[23025]: chan_sip.c:4175 retrans_pkt: Hanging up call SBLw7uYy-wTk5rEGVuN4lQ.. - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
-- Channel SIP/1002-00000000 left 'native_rtp' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
-- Channel SIP/1001-00000001 left 'native_rtp' basic-bridge <4f256478-6734-4430-99cc-70dea5a8c97e>
== Spawn extension (internal, 1001, 1) exited non-zero on 'SIP/1002-00000000'
== Using SIP RTP CoS mark 5
-- Executing [1002@internal:1] Dial("SIP/1001-00000002", "SIP/1002") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1002
-- SIP/1002-00000003 is ringing
-- SIP/1002-00000003 answered SIP/1001-00000002
-- Channel SIP/1002-00000003 joined 'simple_bridge' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
-- Channel SIP/1001-00000002 joined 'simple_bridge' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
[Jun 27 13:02:28] WARNING[23025]: chan_sip.c:4151 retrans_pkt: Retransmission timeout reached on transmission lw6Ulds1px-COhEIX7VAbA.. for seqno 2 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6400ms with no response
[Jun 27 13:02:28] WARNING[23025]: chan_sip.c:4175 retrans_pkt: Hanging up call lw6Ulds1px-COhEIX7VAbA.. - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
-- Channel SIP/1001-00000002 left 'native_rtp' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
-- Channel SIP/1002-00000003 left 'native_rtp' basic-bridge <2998d0cc-a467-4838-bc36-c5e71cc78b8e>
== Spawn extension (internal, 1002, 1) exited non-zero on 'SIP/1001-00000002'
[Jun 27 13:05:31] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Lagged. (3389ms / 2000ms)
[Jun 27 13:05:31] NOTICE[23025]: chan_sip.c:25009 handle_response_peerpoke: Peer '1002' is now Reachable. (204ms / 2000ms)
[Jun 27 13:06:35] NOTICE[23025]: chan_sip.c:30551 sip_poke_noanswer: Peer '1002' is now UNREACHABLE! Last qualify: 204
swamidas-HP-Laptop-14q-cs0xxx*CLI> |
7) Voice can be audible clearly between two clients.
Asterisk Server setup in Banana PI R4
1) Added below changes for porting asterisk code for banana pi r4 board.
https://github.com/rdkcentral/meta-cmf-bananapi/commit/eec660282dbeec132b90e3172f72f09ec951e2d7 |
2) Enable asterisk in board using systemctl
systemctl enable asterisk |
3) Add configuration for two sip clients in the banana pi r4 board.
root@Filogic-GW:/etc/asterisk# cat pjsip.conf [udp-transport] type=transport protocol=udp bind=0.0.0.0 external_media_address=192.168.1.12 external_signaling_address=192.168.1.12 [1001] type=endpoint transport=udp-transport context=from-internal disallow=all allow=alaw allow=ulaw auth=1001 aors=1001 direct_media=no [1001] type=auth auth_type=userpass password=1001 username=1001 [1001] type=aor max_contacts=10 [1002] type=endpoint transport=udp-transport context=from-internal disallow=all allow=alaw allow=ulaw auth=1002 aors=1002 direct_media=no [1002] type=auth auth_type=userpass password=1002 username=1002 [1002] type=aor max_contacts=10 |
4) Add dialplan for the two clients in the board
root@Filogic-GW:/etc/asterisk# cat extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[from-internal]
exten => 1001,1,Dial(PJSIP/1001,20)
exten => 1002,1,Dial(PJSIP/1002,20)
[default]
exten => _X.,1,NoOp(Unhandled call to ${EXTEN})
exten => _X.,n,Playback(vm-nobodyavail)
exten => _X.,n,Hangup()
exten => 1001,1,Dial(PJSIP/1001,20)
exten => 1001,n,NoOp(Dial status for 1001: ${DIALSTATUS})
exten => 1001,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1001,n(busy),Playback(all-circuits-busy-now)
exten => 1001,n(busi),Hangup()
exten => 1001,n(unavail),Playback(vm-nobodyavail)
exten => 1001,n(unavail),Hangup()
exten => 1002,1,Dial(PJSIP/1002,20)
exten => 1002,n,NoOp(Dial status for 1002: ${DIALSTATUS})
exten => 1002,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1002,n(busy),Playback(all-circuits-busy-now)
exten => 1002,n(busy),Hangup()
exten => 1002,n(unavail),Playback(vm-nobodyavail)
exten => 1002,n(unavail),Hangup() |
5) Run the asterisk server in the board and reload both the configuration files in the asterisk CLI
root@Filogic-GW:/etc/asterisk# asterisk -rvvv Asterisk 18.15.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk 18.15.1 currently running on Filogic-GW (pid = 4177657) Filogic-GW*CLI> |
5) Make sure that both clients and Banana PI R4 board are in the same network.