Project

General

Profile

Sip audio session » History » Version 16

Adrian Georgescu, 04/14/2009 10:42 PM

1 1 Adrian Georgescu
== sip_audio_session ==
2 2 Adrian Georgescu
[[TOC(SipTesting*, sip_*, xcap*,depth=2)]]
3 1 Adrian Georgescu
4
=== Description ===
5
6
This script can be used for interactive audio session or for scripting alarms. The script returns appropriate shell response codes for failed or successful sessions. The script can be setup to auto answer and auto hangup after predefined number of seconds, detects SIP negative response codes, missing ACK and the lack of RTP media after a session has been established.
7 6 Adrian Georgescu
8 10 Adrian Georgescu
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-32.gif)]]
9 1 Adrian Georgescu
10
Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py]
11
12
{{{
13 5 Adrian Georgescu
adigeo@ag-oxygen:~$sip_audio_session --help
14 1 Adrian Georgescu
Usage: sip_audio_session [options] [target-user@target-domain.com]
15
16
This script can sit idle waiting for an incoming audio call, or perform an
17
outgoing audio call to the target SIP account. The program will close the
18
session and quit when Ctrl+D is pressed.
19
20
Options:
21
  -h, --help            show this help message and exit
22 5 Adrian Georgescu
  -a NAME, --account=NAME
23
                        The account name to use for any outgoing traffic. If
24
                        not supplied, the default account will be used.
25
  -c [FILE], --config_file=[FILE]
26
                        The path to a configuration file to use. This
27
                        overrides the default location of the configuration
28
                        file.
29
  -s [stdout|file|all|none], --trace-sip=[stdout|file|all|none]
30
                        Dump the raw contents of incoming and outgoing SIP
31
                        messages. The argument specifies where the messages
32
                        are to be dumped.
33
  -j [stdout|file|all|none], --trace-pjsip=[stdout|file|all|none]
34
                        Print PJSIP logging output. The argument specifies
35 1 Adrian Georgescu
                        where the messages are to be dumped.
36 5 Adrian Georgescu
  -S, --disable-sound   Disables initializing the sound card.
37
  --auto-answer         Interval after which to answer an incoming call
38
                        (disabled by default). If the option is specified but
39
                        the interval is not, it defaults to 0 (answer the call
40
                        as soon as it starts ringing).
41 1 Adrian Georgescu
  --auto-hangup         Interval after which to hangup an on-going call
42
                        (applies only to outgoing calls, disabled by default).
43
                        If the option is specified but the interval is not, it
44
                        defaults to 0 (hangup the call as soon as it
45
                        connects).
46
}}}
47
48
49
=== Example for incoming session ===
50
51
{{{
52 7 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session
53
Using account 31208005169@ag-projects.com
54 1 Adrian Georgescu
Available control keys:
55
  h: hang-up the active session
56
  r: toggle audio recording
57
  t: toggle SIP trace on the console
58 7 Adrian Georgescu
  j: toggle PJSIP trace on the console
59 1 Adrian Georgescu
  <> : adjust echo cancellation
60
  SPACE: hold/on-hold
61
  Ctrl-d: quit the program
62
  ?: display this help message
63 7 Adrian Georgescu
Succesfully registered using contact "sip:cwntuzyl@192.168.1.6:61163"
64 1 Adrian Georgescu
Detected NAT type: Port Restricted
65 7 Adrian Georgescu
Incoming audio session from ""Adrian G." <sip:31208005169@ag-projects.com>", do you want to accept? (y/n)
66
Session established, using "PCMU" codec at 8000Hz
67
Audio RTP endpoints 192.168.1.6:50132 <-> 85.17.186.7:53358
68
Remote SIP User Agent is "CSCO/7"
69
Session ended by remote party.
70
Session duration was 3 seconds
71
72 1 Adrian Georgescu
}}}
73
74
=== Example for outgoing session ===
75
76
{{{
77 7 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session ag@ag-projects.com
78
Using account 31208005169@ag-projects.com
79 8 Adrian Georgescu
Initiating SIP session from "Adrian G." <sip:31208005169@ag-projects.com> to 
80
sip:ag@ag-projects.com via udp:81.23.228.150:5060 ...
81 1 Adrian Georgescu
Available control keys:
82
  h: hang-up the active session
83
  r: toggle audio recording
84
  t: toggle SIP trace on the console
85 7 Adrian Georgescu
  j: toggle PJSIP trace on the console
86 1 Adrian Georgescu
  <> : adjust echo cancellation
87
  SPACE: hold/on-hold
88
  Ctrl-d: quit the program
89
  ?: display this help message
90 7 Adrian Georgescu
Succesfully registered using contact "sip:ztomvpis@192.168.1.6:61215"
91 1 Adrian Georgescu
Ringing...
92
Session established, using "speex" codec at 32000Hz
93 7 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50374 <-> 81.23.228.129:52156
94
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
95
Detected NAT type: Port Restricted
96
Ending session...
97
Session ended by local party.
98
Session duration was 12 seconds
99 1 Adrian Georgescu
}}}
100 11 Adrian Georgescu
101
102
=== Example for bonjour mode ===
103
104
In bonjour mode no server is used. This mode is useful for serverless ad-hoc LAN operation. 
105
106
> The actual bonjour protocol that uses multicast DNS to broadcast the contact SIP URIs is not implemented.
107
108
[[Image(http://www.tech-invite.com/img/cf3665/cf3665-31.gif)]]
109
110 12 Adrian Georgescu
'''Called party'''
111
112 1 Adrian Georgescu
{{{
113 12 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session -a bonjour@local
114 11 Adrian Georgescu
Using account bonjour@local
115 12 Adrian Georgescu
Listening on "sip:wjnrczhi@192.168.1.6:57624;transport=tls"
116
Listening on "sip:wjnrczhi@192.168.1.6:57623;transport=tcp"
117
Listening on "sip:wjnrczhi@192.168.1.6:61994"
118 11 Adrian Georgescu
Available control keys:
119
  h: hang-up the active session
120
  r: toggle audio recording
121 1 Adrian Georgescu
  t: toggle SIP trace on the console
122
  j: toggle PJSIP trace on the console
123 11 Adrian Georgescu
  <> : adjust echo cancellation
124
  SPACE: hold/on-hold
125
  Ctrl-d: quit the program
126
  ?: display this help message
127 12 Adrian Georgescu
Incoming audio session from "sip:imdyzosg@192.168.1.6", do you want to accept? (y/n)
128 1 Adrian Georgescu
Session established, using "speex" codec at 32000Hz
129 12 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50276 <-> 192.168.1.6:50100
130 1 Adrian Georgescu
RTP audio stream is encrypted
131
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
132 12 Adrian Georgescu
Session ended by remote party.
133 11 Adrian Georgescu
Session duration was 5 seconds
134
}}}
135
136 12 Adrian Georgescu
'''Calling party'''
137
138 11 Adrian Georgescu
{{{
139 12 Adrian Georgescu
adigeo@ag-imac3:~$sip_audio_session -a bonjour@local "sip:wjnrczhi@192.168.1.6:57624;transport=tls"
140 1 Adrian Georgescu
Using account bonjour@local
141 12 Adrian Georgescu
Listening on "sip:imdyzosg@192.168.1.6:57626;transport=tls"
142
Listening on "sip:imdyzosg@192.168.1.6:57625;transport=tcp"
143
Listening on "sip:imdyzosg@192.168.1.6:62008"
144
Initiating SIP session from sip:imdyzosg@192.168.1.6 to sip:wjnrczhi@192.168.1.6:57624;transport=tls via tls:192.168.1.6:57624 ...
145 11 Adrian Georgescu
Available control keys:
146
  h: hang-up the active session
147
  r: toggle audio recording
148
  t: toggle SIP trace on the console
149
  j: toggle PJSIP trace on the console
150
  <> : adjust echo cancellation
151
  SPACE: hold/on-hold
152
  Ctrl-d: quit the program
153
  ?: display this help message
154 12 Adrian Georgescu
Ringing...
155 11 Adrian Georgescu
Session established, using "speex" codec at 32000Hz
156 12 Adrian Georgescu
Audio RTP endpoints 192.168.1.6:50100 <-> 192.168.1.6:50276
157 11 Adrian Georgescu
RTP audio stream is encrypted
158
Remote SIP User Agent is "sip2sip-0.9.0-pjsip-1.0.2-trunk-r2553"
159 12 Adrian Georgescu
Ending session...
160
Session ended by local party.
161 1 Adrian Georgescu
Session duration was 5 seconds
162
}}}
163 14 Adrian Georgescu
164
165 15 Adrian Georgescu
=== Alarm system ===
166 14 Adrian Georgescu
167 16 Adrian Georgescu
sip_audio_session script can be used for end-to-end testing of a SIP service. To setup the alarm system start periodically a caller script from a monitoring software using the following arguments:
168 14 Adrian Georgescu
  {{{
169
sip_audio_session --auto-hangup user@domain
170
  }}}
171
172 16 Adrian Georgescu
Where the user@domain has been configured as the SIP account of the listener, can be an answering machine on the PSTN network. The caller script hangs up after each call. The shell return code can be used to determine if the session setup has failed. The failure can be caused by timeout, a negative response code or lack of RTP media after the SIP session has been established.