Project

General

Profile

Sip audio session » History » Version 23

Adrian Georgescu, 09/24/2009 10:34 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 21 Adrian Georgescu
adigeo@ag-blink:~$sip_audio_session -h
14 17 Adrian Georgescu
Usage: sip_audio_session [options] [user@domain]
15 1 Adrian Georgescu
16 17 Adrian Georgescu
This script can sit idle waiting for an incoming audio session, or initiate an
17
outgoing audio session to a SIP address. The program will close the session
18
and quit when Ctrl+D is pressed.
19 1 Adrian Georgescu
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 19 Adrian Georgescu
  -c FILE, --config-file=FILE
26 1 Adrian Georgescu
                        The path to a configuration file to use. This
27 5 Adrian Georgescu
                        overrides the default location of the configuration
28
                        file.
29 17 Adrian Georgescu
  -s, --trace-sip       Dump the raw contents of incoming and outgoing SIP
30
                        messages.
31
  -j, --trace-pjsip     Print PJSIP logging output.
32
  -n, --trace-notifications
33
                        Print all notifications (disabled by default).
34 5 Adrian Georgescu
  -S, --disable-sound   Disables initializing the sound card.
35 17 Adrian Georgescu
  --auto-answer         Interval after which to answer an incoming session
36 1 Adrian Georgescu
                        (disabled by default). If the option is specified but
37 17 Adrian Georgescu
                        the interval is not, it defaults to 0 (accept the
38 1 Adrian Georgescu
                        session as soon as it starts ringing).
39
  --auto-hangup         Interval after which to hang up an established session
40 19 Adrian Georgescu
                        (disabled by default). If the option is specified but
41
                        the interval is not, it defaults to 0 (hangup the
42
                        session as soon as it connects).
43
  -b, --batch           Run the program in batch mode: reading input from the
44
                        console is disabled and the option --auto-answer is
45
                        implied. This is particularly useful when running this
46
                        script in a non-interactive environment.
47
  -D, --daemonize       Enable running this program as a deamon. This option
48 20 Adrian Georgescu
                        implies --disable-sound, --auto-answer and --batch.
49 1 Adrian Georgescu
}}}
50
51
52
=== Example for incoming session ===
53
54
{{{
55 21 Adrian Georgescu
adigeo@ag-blink:~$sip_audio_session 
56 1 Adrian Georgescu
Using account 31208005169@ag-projects.com
57 21 Adrian Georgescu
Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt"
58
Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt"
59
Available audio input devices: None, system_default, Built-in Input, Built-in Microphone
60
Available audio output devices: None, system_default, Built-in Output
61 19 Adrian Georgescu
Using audio input device: Built-in Microphone
62
Using audio output device: Built-in Output
63
Using audio alert device: Built-in Output
64
65 1 Adrian Georgescu
Available control keys:
66
  s: toggle SIP trace on the console
67
  j: toggle PJSIP trace on the console
68
  n: toggle notifications trace on the console
69
  p: toggle printing RTP statistics on the console
70 19 Adrian Georgescu
  h: hang-up the active session
71
  r: toggle audio recording
72 21 Adrian Georgescu
  m: mute the microphone
73
  i: change audio input device
74
  o: change audio output device
75
  a: change audio alert device
76 1 Adrian Georgescu
  <>: adjust echo cancellation
77
  SPACE: hold/unhold
78
  Ctrl-d: quit the program
79
  ?: display this help message
80
81 21 Adrian Georgescu
2009-08-25 16:37:12 Registered contact "sip:hxsyungk@192.168.1.124:59164" for sip:31208005169@ag-projects.com at 81.23.228.150:5060;transport=udp (expires in 600 seconds).
82 1 Adrian Georgescu
Other registered contacts:
83 21 Adrian Georgescu
  sip:31208005169@192.168.1.123:5060 (expires in 274 seconds)
84
  sip:kwbfxyvl@192.168.1.124:59116 (expires in 522 seconds)
85
  sip:ilmegvkp@192.168.1.124:59003 (expires in 339 seconds)
86
  sip:31208005169@192.168.1.1;uniq=5B2860C44383A3D6705629A7E1FB8 (expires in 1162 seconds)
87 19 Adrian Georgescu
Detected NAT type: Port Restricted
88 21 Adrian Georgescu
Incoming audio session from 'sip:adi@umts.ro', do you want to accept? (y/n)
89
Audio session established using "speex" codec at 16000Hz
90
Audio RTP endpoints 192.168.1.124:50378 <-> 85.17.186.6:58868
91 19 Adrian Georgescu
RTP audio stream is encrypted
92 21 Adrian Georgescu
Remote SIP User Agent is "Blink-0.9.0"
93
Remote party has put the audio session on hold
94
Audio session is put on hold
95 8 Adrian Georgescu
Audio session ended by remote party
96 21 Adrian Georgescu
Session duration was 6 seconds
97
2009-08-25 16:37:44 Registration ended.
98 1 Adrian Georgescu
}}}
99
100
=== Example for outgoing session ===
101 11 Adrian Georgescu
102
{{{
103 21 Adrian Georgescu
adigeo@ag-blink:~$sip -a umts ag@ag-projects.com
104
Using account adi@umts.ro
105
Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt"
106
Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt"
107
Available audio input devices: None, system_default, Built-in Input, Built-in Microphone
108
Available audio output devices: None, system_default, Built-in Output
109 1 Adrian Georgescu
Using audio input device: Built-in Microphone
110 11 Adrian Georgescu
Using audio output device: Built-in Output
111 1 Adrian Georgescu
Using audio alert device: Built-in Output
112 11 Adrian Georgescu
113 12 Adrian Georgescu
Available control keys:
114 11 Adrian Georgescu
  s: toggle SIP trace on the console
115 12 Adrian Georgescu
  j: toggle PJSIP trace on the console
116 11 Adrian Georgescu
  n: toggle notifications trace on the console
117
  p: toggle printing RTP statistics on the console
118 12 Adrian Georgescu
  h: hang-up the active session
119
  r: toggle audio recording
120 21 Adrian Georgescu
  m: mute the microphone
121
  i: change audio input device
122
  o: change audio output device
123
  a: change audio alert device
124 15 Adrian Georgescu
  <>: adjust echo cancellation
125 14 Adrian Georgescu
  SPACE: hold/unhold
126 16 Adrian Georgescu
  Ctrl-d: quit the program
127 14 Adrian Georgescu
  ?: display this help message
128
129 21 Adrian Georgescu
Initiating SIP audio session from 'sip:adi@umts.ro' to 'sip:ag@ag-projects.com' via sip:85.17.186.7:5060;transport=udp...
130
Audio session established using "speex" codec at 16000Hz
131
Audio RTP endpoints 192.168.1.124:50054 <-> 85.17.186.6:58866
132 18 Adrian Georgescu
RTP audio stream is encrypted
133 21 Adrian Georgescu
Audio session is put on hold
134
Remote party has put the audio session on hold
135
Detected NAT type: Port Restricted
136 18 Adrian Georgescu
Ending audio session...
137
Audio session ended by local party
138 21 Adrian Georgescu
Session duration was 7 seconds
139 18 Adrian Georgescu
}}}
140 1 Adrian Georgescu
141 23 Adrian Georgescu
=== Session with sip trace enabled ===
142
143
Use -s parameter you can see on the console detailed trace of all DNS queries/responses and SIP traffic exchanged during the session.
144
 
145
{{{
146
adigeo@ag-imac3:~$sip -s -a umts ag@ag-projects.com
147
Using account adi@umts.ro
148
Logging SIP trace to file "/Users/adigeo/Desktop/FileTransfers/sip_trace.txt"
149
Logging PJSIP trace to file "/Users/adigeo/Desktop/FileTransfers/pjsip_trace.txt"
150
Logging notifications trace to file "/Users/adigeo/Desktop/FileTransfers/notifications_trace.txt"
151
Available audio input devices: None, system_default, Built-in Input, Built-in Microphone, Logitech Wireless Headset
152
Available audio output devices: None, system_default, Built-in Output, Logitech Wireless Headset
153
Using audio input device: Logitech Wireless Headset
154
Using audio output device: Logitech Wireless Headset
155
Using audio alert device: Built-in Output
156
157
Available control keys:
158
  s: toggle SIP trace on the console
159
  j: toggle PJSIP trace on the console
160
  n: toggle notifications trace on the console
161
  p: toggle printing RTP statistics on the console
162
  h: hang-up the active session
163
  r: toggle audio recording
164
  m: mute the microphone
165
  i: change audio input device
166
  o: change audio output device
167
  a: change audio alert device
168
  <>: adjust echo cancellation
169
  SPACE: hold/unhold
170
  Ctrl-d: quit the program
171
  ?: display this help message
172
173
2009-09-24 22:31:24.118467: DNS lookup SRV _stun._udp.umts.ro succeeded, ttl=10758: 0 0 3478 stun1.dns-hosting.info., 0 0 3479 stun2.dns-hosting.info.
174
2009-09-24 22:31:24.120425: DNS lookup NAPTR ag-projects.com succeeded, ttl=244: 20 0 "s" "SIP+D2U" "" _sip._udp.ag-projects.com.
175
2009-09-24 22:31:24.126619: DNS lookup A stun1.dns-hosting.info. succeeded, ttl=845: 81.23.228.150
176
2009-09-24 22:31:24.128383: DNS lookup SRV _sip._udp.ag-projects.com. succeeded, ttl=18: 0 0 5060 proxy.sipthor.net.
177
2009-09-24 22:31:24.132502: DNS lookup A stun2.dns-hosting.info. succeeded, ttl=845: 85.17.186.6
178
2009-09-24 22:31:24.136754: DNS lookup A proxy.sipthor.net. succeeded, ttl=5: 85.17.186.7, 81.23.228.129
179
Initiating SIP audio session from '"Adrian G." <sip:adi@umts.ro>' to 'sip:ag@ag-projects.com' via sip:85.17.186.7:5060;transport=udp...
180
2009-09-24 22:31:24.145751: DNS lookup SRV _stun._udp.umts.ro succeeded, ttl=10758: 0 0 3478 stun1.dns-hosting.info., 0 0 3479 stun2.dns-hosting.info.
181
2009-09-24 22:31:24.150530: DNS lookup A stun1.dns-hosting.info. succeeded, ttl=845: 81.23.228.150
182
2009-09-24 22:31:24.155510: DNS lookup A stun2.dns-hosting.info. succeeded, ttl=845: 85.17.186.6
183
2009-09-24 22:31:24.572498: SENDING: Packet 1, +0:00:00
184
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
185
INVITE sip:ag@ag-projects.com SIP/2.0
186
Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB
187
Max-Forwards: 70
188
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
189
To: <sip:ag@ag-projects.com>
190
Contact: <sip:pfxtjskq@192.168.1.6:62054>
191
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
192
CSeq: 16887 INVITE
193
Route: <sip:85.17.186.7;lr>
194
Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE
195
Supported: 100rel
196
User-Agent: blink-0.9.0
197
Content-Type: application/sdp
198
Content-Length:  1087
199
200
v=0
201
o=- 3462813084 3462813084 IN IP4 192.168.1.6
202
s=blink-0.9.0
203
c=IN IP4 80.101.96.20
204
t=0 0
205
m=audio 62066 RTP/AVP 104 103 102 3 9 0 8 101
206
a=rtcp:62067 IN IP4 80.101.96.20
207
a=rtpmap:104 speex/32000
208
a=rtpmap:103 speex/16000
209
a=rtpmap:102 speex/8000
210
a=rtpmap:3 GSM/8000
211
a=rtpmap:9 G722/8000
212
a=rtpmap:0 PCMU/8000
213
a=rtpmap:8 PCMA/8000
214
a=rtpmap:101 telephone-event/8000
215
a=fmtp:101 0-15
216
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:eQ0XcBiuyy33zR2HEHLiaS5LCxA1T9rvP9J8GLw6
217
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:zWQU33HIZ0a7otihkQe2Y4jvqpKpXtotNwoW9Xl8
218
a=ice-ufrag:0aa3379a
219
a=ice-pwd:619764ea
220
a=candidate:S 1 UDP 31 80.101.96.20 62066 typ srflx raddr 192.168.1.6 rport 62066
221
a=candidate:H 1 UDP 23 192.168.1.6 62066 typ host
222
a=candidate:H 1 UDP 23 10.211.55.2 62066 typ host
223
a=candidate:H 1 UDP 23 10.37.129.2 62066 typ host
224
a=candidate:S 2 UDP 30 80.101.96.20 62067 typ srflx raddr 192.168.1.6 rport 62067
225
a=candidate:H 2 UDP 22 192.168.1.6 62067 typ host
226
a=candidate:H 2 UDP 22 10.211.55.2 62067 typ host
227
a=candidate:H 2 UDP 22 10.37.129.2 62067 typ host
228
a=sendrecv
229
230
--
231
232
2009-09-24 22:31:24.601167: RECEIVED: Packet 2, +0:00:00.028669
233
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
234
SIP/2.0 100 Giving a try
235
Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB;received=80.101.96.20
236
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
237
To: <sip:ag@ag-projects.com>
238
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
239
CSeq: 16887 INVITE
240
Server: SIP Thor on OpenSIPS XS 1.4.5
241
Content-Length: 0
242
243
244
--
245
246
2009-09-24 22:31:24.621860: RECEIVED: Packet 3, +0:00:00.049362
247
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
248
SIP/2.0 407 Proxy Authentication Required
249
Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB
250
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
251
To: <sip:ag@ag-projects.com>;tag=e7d4d6b46afb9bf88242924a8d869ebf.962b
252
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
253
CSeq: 16887 INVITE
254
Proxy-Authenticate: Digest realm="umts.ro", nonce="4abbd73a48ba8c7fc6617208684ad122088d2207"
255
Server: SIP Thor on OpenSIPS XS 1.4.5
256
Content-Length: 0
257
258
259
--
260
261
2009-09-24 22:31:24.622019: SENDING: Packet 4, +0:00:00.049521
262
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
263
ACK sip:ag@ag-projects.com SIP/2.0
264
Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB
265
Max-Forwards: 70
266
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
267
To: <sip:ag@ag-projects.com>;tag=e7d4d6b46afb9bf88242924a8d869ebf.962b
268
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
269
CSeq: 16887 ACK
270
Route: <sip:85.17.186.7;lr>
271
User-Agent: blink-0.9.0
272
Content-Length:  0
273
274
275
--
276
277
2009-09-24 22:31:24.622214: SENDING: Packet 5, +0:00:00.049716
278
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
279
INVITE sip:ag@ag-projects.com SIP/2.0
280
Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T
281
Max-Forwards: 70
282
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
283
To: <sip:ag@ag-projects.com>
284
Contact: <sip:pfxtjskq@192.168.1.6:62054>
285
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
286
CSeq: 16888 INVITE
287
Route: <sip:85.17.186.7;lr>
288
Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE
289
Supported: 100rel
290
User-Agent: blink-0.9.0
291
Proxy-Authorization: Digest username="adi", realm="umts.ro", nonce="4abbd73a48ba8c7fc6617208684ad122088d2207", uri="sip:ag@ag-projects.com", response="cb85bbe3dbe0dcd71820c6ceaa027566"
292
Content-Type: application/sdp
293
Content-Length:  1087
294
295
v=0
296
o=- 3462813084 3462813084 IN IP4 192.168.1.6
297
s=blink-0.9.0
298
c=IN IP4 80.101.96.20
299
t=0 0
300
m=audio 62066 RTP/AVP 104 103 102 3 9 0 8 101
301
a=rtcp:62067 IN IP4 80.101.96.20
302
a=rtpmap:104 speex/32000
303
a=rtpmap:103 speex/16000
304
a=rtpmap:102 speex/8000
305
a=rtpmap:3 GSM/8000
306
a=rtpmap:9 G722/8000
307
a=rtpmap:0 PCMU/8000
308
a=rtpmap:8 PCMA/8000
309
a=rtpmap:101 telephone-event/8000
310
a=fmtp:101 0-15
311
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:eQ0XcBiuyy33zR2HEHLiaS5LCxA1T9rvP9J8GLw6
312
a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:zWQU33HIZ0a7otihkQe2Y4jvqpKpXtotNwoW9Xl8
313
a=ice-ufrag:0aa3379a
314
a=ice-pwd:619764ea
315
a=candidate:S 1 UDP 31 80.101.96.20 62066 typ srflx raddr 192.168.1.6 rport 62066
316
a=candidate:H 1 UDP 23 192.168.1.6 62066 typ host
317
a=candidate:H 1 UDP 23 10.211.55.2 62066 typ host
318
a=candidate:H 1 UDP 23 10.37.129.2 62066 typ host
319
a=candidate:S 2 UDP 30 80.101.96.20 62067 typ srflx raddr 192.168.1.6 rport 62067
320
a=candidate:H 2 UDP 22 192.168.1.6 62067 typ host
321
a=candidate:H 2 UDP 22 10.211.55.2 62067 typ host
322
a=candidate:H 2 UDP 22 10.37.129.2 62067 typ host
323
a=sendrecv
324
325
--
326
327
2009-09-24 22:31:24.656088: RECEIVED: Packet 6, +0:00:00.083590
328
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
329
SIP/2.0 100 Giving a try
330
Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T;received=80.101.96.20
331
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
332
To: <sip:ag@ag-projects.com>
333
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
334
CSeq: 16888 INVITE
335
Server: SIP Thor on OpenSIPS XS 1.4.5
336
Content-Length: 0
337
338
339
--
340
341
2009-09-24 22:31:24.721041: RECEIVED: Packet 7, +0:00:00.148543
342
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
343
SIP/2.0 180 Ringing
344
Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;received=80.101.96.20;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T
345
Record-Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924>
346
Record-Route: <sip:81.23.228.150;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2>
347
Record-Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924>
348
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
349
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
350
To: <sip:ag@ag-projects.com>;tag=FkXkUNDcrT80u8GHaUIUuF4OrIJI6O8f
351
CSeq: 16888 INVITE
352
Server: blink-0.9.0
353
Contact: <sip:iwralmqz@80.101.96.20:61962>
354
Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE
355
Content-Length:  0
356
357
358
--
359
360
2009-09-24 22:31:24.878489: RECEIVED: Packet 8, +0:00:00.305991
361
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
362
SIP/2.0 180 Ringing
363
Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T
364
Record-Route: <sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924>
365
Record-Route: <sip:81.23.228.150;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2>
366
Record-Route: <sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924>
367
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
368
To: <sip:ag@ag-projects.com>;tag=96A4E0ACA527F9AF
369
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
370
CSeq: 16888 INVITE
371
Contact: <sip:31208005169@80.101.96.20:5060;uniq=5B2860C44383A3D6705629A7E1FB8>
372
User-Agent: AVM FRITZ!Box Fon WLAN 7170 29.04.56 (May  1 2008)
373
Content-Length: 0
374
375
376
--
377
378
2009-09-24 22:31:25.154425: RECEIVED: Packet 9, +0:00:00.581927
379
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
380
SIP/2.0 180 Ringing
381
Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T
382
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
383
To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1
384
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
385
CSeq: 16888 INVITE
386
Server: CSCO/7
387
Contact: <sip:31208005169@80.101.96.20:61000>
388
Record-Route: <sip:81.23.228.129;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.985cae24>,<sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924>,<sip:81.23.228.150;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2>,<sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924>
389
Content-Length: 0
390
391
392
--
393
394
2009-09-24 22:31:25.368613: RECEIVED: Packet 10, +0:00:00.796115
395
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
396
SIP/2.0 200 OK
397
Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T
398
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
399
To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1
400
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
401
CSeq: 16888 INVITE
402
Server: CSCO/7
403
Contact: <sip:31208005169@80.101.96.20:61000>
404
Record-Route: <sip:81.23.228.129;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.985cae24>,<sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924>,<sip:81.23.228.150;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2>,<sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924>
405
Content-Type: application/sdp
406
Content-Length: 197
407
408
v=0
409
o=Cisco-SIPUA 8420 8964 IN IP4 192.168.1.123
410
s=SIP Call
411
c=IN IP4 81.23.228.150
412
t=0 0
413
m=audio 51974 RTP/AVP 0 101
414
a=rtpmap:0 PCMU/8000
415
a=rtpmap:101 telephone-event/8000
416
a=fmtp:101 0-15
417
418
--
419
420
2009-09-24 22:31:25.369124: SENDING: Packet 11, +0:00:00.796626
421
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
422
ACK sip:31208005169@80.101.96.20:61000 SIP/2.0
423
Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjkq3Y5tZfK3d.zASBBAHQHZMavNNRQw0W
424
Max-Forwards: 70
425
From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
426
To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1
427
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
428
CSeq: 16888 ACK
429
Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924>
430
Route: <sip:81.23.228.150;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2>
431
Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924>
432
Route: <sip:81.23.228.129;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.985cae24>
433
User-Agent: blink-0.9.0
434
Content-Length:  0
435
436
437
--
438
439
Audio session established using "PCMU" codec at 8000Hz
440
Audio RTP endpoints 80.101.96.20:62066 <-> 81.23.228.150:51974
441
Detected NAT type: Port Restricted
442
2009-09-24 22:31:40.495793: RECEIVED: Packet 12, +0:00:15.923295
443
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
444
NOTIFY sip:80.101.96.20:62054 SIP/2.0
445
Via: SIP/2.0/UDP 85.17.186.7:5060;branch=0
446
From: sip:keepalive@85.17.186.7;tag=7c29b7d5
447
To: sip:80.101.96.20:62054
448
Call-ID: 296fc4b6-56ba6860-24109f@85.17.186.7
449
CSeq: 1 NOTIFY
450
Event: keep-alive
451
Content-Length: 0
452
453
454
--
455
456
2009-09-24 22:31:40.495929: SENDING: Packet 13, +0:00:15.923431
457
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
458
SIP/2.0 405 Method Not Allowed
459
Via: SIP/2.0/UDP 85.17.186.7:5060;received=85.17.186.7;branch=0
460
Call-ID: 296fc4b6-56ba6860-24109f@85.17.186.7
461
From: <sip:keepalive@85.17.186.7>;tag=7c29b7d5
462
To: <sip:80.101.96.20>
463
CSeq: 1 NOTIFY
464
Server: blink-0.9.0
465
Content-Length:  0
466
467
468
--
469
470
2009-09-24 22:31:43.425393: RECEIVED: Packet 14, +0:00:18.852895
471
85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054
472
BYE sip:pfxtjskq@80.101.96.20:62054 SIP/2.0
473
Record-Route: <sip:85.17.186.7;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1>
474
Record-Route: <sip:81.23.228.150;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1>
475
Record-Route: <sip:85.17.186.7;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1>
476
Max-Forwards:  7
477
Record-Route: <sip:81.23.228.129;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1>
478
Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.feada044.0
479
Via: SIP/2.0/UDP 81.23.228.150;branch=z9hG4bK9c22.3cf12dd3.0
480
Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.eeada044.0
481
Via: SIP/2.0/UDP 81.23.228.129;branch=z9hG4bK9c22.877deec6.0
482
Via: SIP/2.0/UDP 192.168.1.123:5060;rport=61000;received=80.101.96.20;branch=z9hG4bK63eb02c1
483
From: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1
484
To: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
485
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
486
CSeq: 101 BYE
487
User-Agent: CSCO/7
488
Content-Length: 0
489
RTP-RxStat: Dur=18,Pkt=29,Oct=4640,LatePkt=0,LostPkt=0,AvgJit=0
490
RTP-TxStat: Dur=18,Pkt=889,Oct=142240
491
492
493
--
494
495
2009-09-24 22:31:43.425554: SENDING: Packet 15, +0:00:18.853056
496
192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060
497
SIP/2.0 200 OK
498
Via: SIP/2.0/UDP 85.17.186.7;received=85.17.186.7;branch=z9hG4bK9c22.feada044.0
499
Via: SIP/2.0/UDP 81.23.228.150;branch=z9hG4bK9c22.3cf12dd3.0
500
Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.eeada044.0
501
Via: SIP/2.0/UDP 81.23.228.129;branch=z9hG4bK9c22.877deec6.0
502
Via: SIP/2.0/UDP 192.168.1.123:5060;rport=61000;received=80.101.96.20;branch=z9hG4bK63eb02c1
503
Record-Route: <sip:85.17.186.7;lr;ftag=000c854663c02cf2799a9168-4ae390b1>
504
Record-Route: <sip:81.23.228.150;lr;ftag=000c854663c02cf2799a9168-4ae390b1>
505
Record-Route: <sip:85.17.186.7;lr;ftag=000c854663c02cf2799a9168-4ae390b1>
506
Record-Route: <sip:81.23.228.129;lr;ftag=000c854663c02cf2799a9168-4ae390b1>
507
Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3
508
From: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1
509
To: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF
510
CSeq: 101 BYE
511
Server: blink-0.9.0
512
Content-Length:  0
513
514
515
--
516
517
Audio session ended by remote party
518
Session duration was 18 seconds
519
}}}
520
521 1 Adrian Georgescu
=== Alarm system ===
522
523 22 Adrian Georgescu
sip_audio_session script can be used for end-to-end testing of a SIP service including the RTP media path. The follow failures can be detected:
524 1 Adrian Georgescu
525 22 Adrian Georgescu
 * Timeout
526
 * Negative response code
527
 * Lack of RTP media after the SIP session has been established
528
 * Missing ACK
529
530
531
To setup the alarm system start periodically a caller script from a monitoring software using the following arguments:
532
533 1 Adrian Georgescu
  {{{
534
sip_audio_session --auto-hangup user@domain
535
  }}}
536
537 22 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.
538 1 Adrian Georgescu
539
To receive calls and answer them automatically you can also use sip_audio_session script as follows:
540
541
  {{{
542
sip_audio_session --daemonize
543
  }}}
544
545
You must run the script as user root. The --daemonize option puts the client in the background and the logging goes to /var/log/syslog. The program saves its pid file to /var/run/sip_audio_session.pid.