Project

General

Profile

Sip audio session » History » Revision 25

Revision 24 (Adrian Georgescu, 01/24/2010 03:24 PM) → Revision 25/28 (Adrian Georgescu, 01/24/2010 03:34 PM)

== sip-audio-session == 
 [[TOC(SipTesting*, sip_*, xcap*,depth=2)]] 

 === Description === 


 

 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. 

 > This script is available in ''sipclients'' package that must be installed separately from SIP SIMPLe client SDK package. [[Image(http://www.tech-invite.com/img/cf3665/cf3665-32.gif)]] 

 Source code: [source:scripts/sip_audio_session.py scripts/sip_audio_session.py] 

 {{{ 
 adigeo@ag-blink:~$sip-audio-session -h 
 Usage: sip-audio-session [options] [user@domain] 

 This script can sit idle waiting for an incoming audio session, or initiate an 
 outgoing audio session to a SIP address. The program will close the session 
 and quit when Ctrl+D is pressed. 

 Options: 
   -h, --help              show this help message and exit 
   -a NAME, --account=NAME 
                         The account name to use for any outgoing traffic. If 
                         not supplied, the default account will be used. 
   -c FILE, --config-file=FILE 
                         The path to a configuration file to use. This 
                         overrides the default location of the configuration 
                         file. 
   -s, --trace-sip         Dump the raw contents of incoming and outgoing SIP 
                         messages. 
   -j, --trace-pjsip       Print PJSIP logging output. 
   -n, --trace-notifications 
                         Print all notifications (disabled by default). 
   -S, --disable-sound     Disables initializing the sound card. 
   --auto-answer           Interval after which to answer an incoming session 
                         (disabled by default). If the option is specified but 
                         the interval is not, it defaults to 0 (accept the 
                         session as soon as it starts ringing). 
   --auto-hangup           Interval after which to hang up an established session 
                         (disabled by default). If the option is specified but 
                         the interval is not, it defaults to 0 (hangup the 
                         session as soon as it connects). 
   -b, --batch             Run the program in batch mode: reading input from the 
                         console is disabled and the option --auto-answer is 
                         implied. This is particularly useful when running this 
                         script in a non-interactive environment. 
   -D, --daemonize         Enable running this program as a deamon. This option 
                         implies --disable-sound, --auto-answer and --batch. 
 }}} 


 === Example for incoming session === 

 {{{ 
 adigeo@ag-blink:~$sip-audio-session  
 Using account 31208005169@ag-projects.com 
 Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt" 
 Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" 
 Available audio input devices: None, system_default, Built-in Input, Built-in Microphone 
 Available audio output devices: None, system_default, Built-in Output 
 Using audio input device: Built-in Microphone 
 Using audio output device: Built-in Output 
 Using audio alert device: Built-in Output 

 Available control keys: 
   s: toggle SIP trace on the console 
   j: toggle PJSIP trace on the console 
   n: toggle notifications trace on the console 
   p: toggle printing RTP statistics on the console 
   h: hang-up the active session 
   r: toggle audio recording 
   m: mute the microphone 
   i: change audio input device 
   o: change audio output device 
   a: change audio alert device 
   <>: adjust echo cancellation 
   SPACE: hold/unhold 
   Ctrl-d: quit the program 
   ?: display this help message 

 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). 
 Other registered contacts: 
   sip:31208005169@192.168.1.123:5060 (expires in 274 seconds) 
   sip:kwbfxyvl@192.168.1.124:59116 (expires in 522 seconds) 
   sip:ilmegvkp@192.168.1.124:59003 (expires in 339 seconds) 
   sip:31208005169@192.168.1.1;uniq=5B2860C44383A3D6705629A7E1FB8 (expires in 1162 seconds) 
 Detected NAT type: Port Restricted 
 Incoming audio session from 'sip:adi@umts.ro', do you want to accept? (y/n) 
 Audio session established using "speex" codec at 16000Hz 
 Audio RTP endpoints 192.168.1.124:50378 <-> 85.17.186.6:58868 
 RTP audio stream is encrypted 
 Remote SIP User Agent is "Blink-0.9.0" 
 Remote party has put the audio session on hold 
 Audio session is put on hold 
 Audio session ended by remote party 
 Session duration was 6 seconds 
 2009-08-25 16:37:44 Registration ended. 
 }}} 

 === Example for outgoing session === 

 {{{ 
 adigeo@ag-blink:~$sip-audio-session -a umts ag@ag-projects.com 
 Using account adi@umts.ro 
 Logging SIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/sip_trace.txt" 
 Logging PJSIP trace to file "/Users/adigeo/Library/Application Support/Blink/logs/pjsip_trace.txt" 
 Available audio input devices: None, system_default, Built-in Input, Built-in Microphone 
 Available audio output devices: None, system_default, Built-in Output 
 Using audio input device: Built-in Microphone 
 Using audio output device: Built-in Output 
 Using audio alert device: Built-in Output 

 Available control keys: 
   s: toggle SIP trace on the console 
   j: toggle PJSIP trace on the console 
   n: toggle notifications trace on the console 
   p: toggle printing RTP statistics on the console 
   h: hang-up the active session 
   r: toggle audio recording 
   m: mute the microphone 
   i: change audio input device 
   o: change audio output device 
   a: change audio alert device 
   <>: adjust echo cancellation 
   SPACE: hold/unhold 
   Ctrl-d: quit the program 
   ?: display this help message 

 Initiating SIP audio session from 'sip:adi@umts.ro' to 'sip:ag@ag-projects.com' via sip:85.17.186.7:5060;transport=udp... 
 Audio session established using "speex" codec at 16000Hz 
 Audio RTP endpoints 192.168.1.124:50054 <-> 85.17.186.6:58866 
 RTP audio stream is encrypted 
 Audio session is put on hold 
 Remote party has put the audio session on hold 
 Detected NAT type: Port Restricted 
 Ending audio session... 
 Audio session ended by local party 
 Session duration was 7 seconds 
 }}} 

 === Session with sip trace enabled === 

 Use -s parameter you can see on the console detailed trace of all DNS queries/responses and SIP traffic exchanged during the session. 
 
 {{{ 
 adigeo@ag-imac3:~$sip-audio-session -s -a umts ag@ag-projects.com 
 Using account adi@umts.ro 
 Logging SIP trace to file "/Users/adigeo/Desktop/FileTransfers/sip_trace.txt" 
 Logging PJSIP trace to file "/Users/adigeo/Desktop/FileTransfers/pjsip_trace.txt" 
 Logging notifications trace to file "/Users/adigeo/Desktop/FileTransfers/notifications_trace.txt" 
 Available audio input devices: None, system_default, Built-in Input, Built-in Microphone, Logitech Wireless Headset 
 Available audio output devices: None, system_default, Built-in Output, Logitech Wireless Headset 
 Using audio input device: Logitech Wireless Headset 
 Using audio output device: Logitech Wireless Headset 
 Using audio alert device: Built-in Output 

 Available control keys: 
   s: toggle SIP trace on the console 
   j: toggle PJSIP trace on the console 
   n: toggle notifications trace on the console 
   p: toggle printing RTP statistics on the console 
   h: hang-up the active session 
   r: toggle audio recording 
   m: mute the microphone 
   i: change audio input device 
   o: change audio output device 
   a: change audio alert device 
   <>: adjust echo cancellation 
   SPACE: hold/unhold 
   Ctrl-d: quit the program 
   ?: display this help message 

 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. 
 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. 
 2009-09-24 22:31:24.126619: DNS lookup A stun1.dns-hosting.info. succeeded, ttl=845: 81.23.228.150 
 2009-09-24 22:31:24.128383: DNS lookup SRV _sip._udp.ag-projects.com. succeeded, ttl=18: 0 0 5060 proxy.sipthor.net. 
 2009-09-24 22:31:24.132502: DNS lookup A stun2.dns-hosting.info. succeeded, ttl=845: 85.17.186.6 
 2009-09-24 22:31:24.136754: DNS lookup A proxy.sipthor.net. succeeded, ttl=5: 85.17.186.7, 81.23.228.129 
 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... 
 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. 
 2009-09-24 22:31:24.150530: DNS lookup A stun1.dns-hosting.info. succeeded, ttl=845: 81.23.228.150 
 2009-09-24 22:31:24.155510: DNS lookup A stun2.dns-hosting.info. succeeded, ttl=845: 85.17.186.6 
 2009-09-24 22:31:24.572498: SENDING: Packet 1, +0:00:00 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 INVITE sip:ag@ag-projects.com SIP/2.0 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB 
 Max-Forwards: 70 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com> 
 Contact: <sip:pfxtjskq@192.168.1.6:62054> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16887 INVITE 
 Route: <sip:85.17.186.7;lr> 
 Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE 
 Supported: 100rel 
 User-Agent: blink-0.9.0 
 Content-Type: application/sdp 
 Content-Length:    1087 

 v=0 
 o=- 3462813084 3462813084 IN IP4 192.168.1.6 
 s=blink-0.9.0 
 c=IN IP4 80.101.96.20 
 t=0 0 
 m=audio 62066 RTP/AVP 104 103 102 3 9 0 8 101 
 a=rtcp:62067 IN IP4 80.101.96.20 
 a=rtpmap:104 speex/32000 
 a=rtpmap:103 speex/16000 
 a=rtpmap:102 speex/8000 
 a=rtpmap:3 GSM/8000 
 a=rtpmap:9 G722/8000 
 a=rtpmap:0 PCMU/8000 
 a=rtpmap:8 PCMA/8000 
 a=rtpmap:101 telephone-event/8000 
 a=fmtp:101 0-15 
 a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:eQ0XcBiuyy33zR2HEHLiaS5LCxA1T9rvP9J8GLw6 
 a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:zWQU33HIZ0a7otihkQe2Y4jvqpKpXtotNwoW9Xl8 
 a=ice-ufrag:0aa3379a 
 a=ice-pwd:619764ea 
 a=candidate:S 1 UDP 31 80.101.96.20 62066 typ srflx raddr 192.168.1.6 rport 62066 
 a=candidate:H 1 UDP 23 192.168.1.6 62066 typ host 
 a=candidate:H 1 UDP 23 10.211.55.2 62066 typ host 
 a=candidate:H 1 UDP 23 10.37.129.2 62066 typ host 
 a=candidate:S 2 UDP 30 80.101.96.20 62067 typ srflx raddr 192.168.1.6 rport 62067 
 a=candidate:H 2 UDP 22 192.168.1.6 62067 typ host 
 a=candidate:H 2 UDP 22 10.211.55.2 62067 typ host 
 a=candidate:H 2 UDP 22 10.37.129.2 62067 typ host 
 a=sendrecv 

 -- 

 2009-09-24 22:31:24.601167: RECEIVED: Packet 2, +0:00:00.028669 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 100 Giving a try 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB;received=80.101.96.20 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16887 INVITE 
 Server: SIP Thor on OpenSIPS XS 1.4.5 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:24.621860: RECEIVED: Packet 3, +0:00:00.049362 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 407 Proxy Authentication Required 
 Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=e7d4d6b46afb9bf88242924a8d869ebf.962b 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16887 INVITE 
 Proxy-Authenticate: Digest realm="umts.ro", nonce="4abbd73a48ba8c7fc6617208684ad122088d2207" 
 Server: SIP Thor on OpenSIPS XS 1.4.5 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:24.622019: SENDING: Packet 4, +0:00:00.049521 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 ACK sip:ag@ag-projects.com SIP/2.0 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjWy0ZCjWb9Ro6Cy15cBX3FE3H.er7.wzB 
 Max-Forwards: 70 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=e7d4d6b46afb9bf88242924a8d869ebf.962b 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16887 ACK 
 Route: <sip:85.17.186.7;lr> 
 User-Agent: blink-0.9.0 
 Content-Length:    0 


 -- 

 2009-09-24 22:31:24.622214: SENDING: Packet 5, +0:00:00.049716 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 INVITE sip:ag@ag-projects.com SIP/2.0 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T 
 Max-Forwards: 70 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com> 
 Contact: <sip:pfxtjskq@192.168.1.6:62054> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 INVITE 
 Route: <sip:85.17.186.7;lr> 
 Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE 
 Supported: 100rel 
 User-Agent: blink-0.9.0 
 Proxy-Authorization: Digest username="adi", realm="umts.ro", nonce="4abbd73a48ba8c7fc6617208684ad122088d2207", uri="sip:ag@ag-projects.com", response="cb85bbe3dbe0dcd71820c6ceaa027566" 
 Content-Type: application/sdp 
 Content-Length:    1087 

 v=0 
 o=- 3462813084 3462813084 IN IP4 192.168.1.6 
 s=blink-0.9.0 
 c=IN IP4 80.101.96.20 
 t=0 0 
 m=audio 62066 RTP/AVP 104 103 102 3 9 0 8 101 
 a=rtcp:62067 IN IP4 80.101.96.20 
 a=rtpmap:104 speex/32000 
 a=rtpmap:103 speex/16000 
 a=rtpmap:102 speex/8000 
 a=rtpmap:3 GSM/8000 
 a=rtpmap:9 G722/8000 
 a=rtpmap:0 PCMU/8000 
 a=rtpmap:8 PCMA/8000 
 a=rtpmap:101 telephone-event/8000 
 a=fmtp:101 0-15 
 a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:eQ0XcBiuyy33zR2HEHLiaS5LCxA1T9rvP9J8GLw6 
 a=crypto:2 AES_CM_128_HMAC_SHA1_32 inline:zWQU33HIZ0a7otihkQe2Y4jvqpKpXtotNwoW9Xl8 
 a=ice-ufrag:0aa3379a 
 a=ice-pwd:619764ea 
 a=candidate:S 1 UDP 31 80.101.96.20 62066 typ srflx raddr 192.168.1.6 rport 62066 
 a=candidate:H 1 UDP 23 192.168.1.6 62066 typ host 
 a=candidate:H 1 UDP 23 10.211.55.2 62066 typ host 
 a=candidate:H 1 UDP 23 10.37.129.2 62066 typ host 
 a=candidate:S 2 UDP 30 80.101.96.20 62067 typ srflx raddr 192.168.1.6 rport 62067 
 a=candidate:H 2 UDP 22 192.168.1.6 62067 typ host 
 a=candidate:H 2 UDP 22 10.211.55.2 62067 typ host 
 a=candidate:H 2 UDP 22 10.37.129.2 62067 typ host 
 a=sendrecv 

 -- 

 2009-09-24 22:31:24.656088: RECEIVED: Packet 6, +0:00:00.083590 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 100 Giving a try 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T;received=80.101.96.20 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 INVITE 
 Server: SIP Thor on OpenSIPS XS 1.4.5 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:24.721041: RECEIVED: Packet 7, +0:00:00.148543 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 180 Ringing 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport=62054;received=80.101.96.20;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T 
 Record-Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924> 
 Record-Route: <sip:81.23.228.150;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2> 
 Record-Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=FkXkUNDcrT80u8GHaUIUuF4OrIJI6O8f 
 CSeq: 16888 INVITE 
 Server: blink-0.9.0 
 Contact: <sip:iwralmqz@80.101.96.20:61962> 
 Allow: SUBSCRIBE, NOTIFY, PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, MESSAGE 
 Content-Length:    0 


 -- 

 2009-09-24 22:31:24.878489: RECEIVED: Packet 8, +0:00:00.305991 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 180 Ringing 
 Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T 
 Record-Route: <sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924> 
 Record-Route: <sip:81.23.228.150;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2> 
 Record-Route: <sip:85.17.186.7;lr=on;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924> 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=96A4E0ACA527F9AF 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 INVITE 
 Contact: <sip:31208005169@80.101.96.20:5060;uniq=5B2860C44383A3D6705629A7E1FB8> 
 User-Agent: AVM FRITZ!Box Fon WLAN 7170 29.04.56 (May    1 2008) 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:25.154425: RECEIVED: Packet 9, +0:00:00.581927 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 180 Ringing 
 Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 INVITE 
 Server: CSCO/7 
 Contact: <sip:31208005169@80.101.96.20:61000> 
 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> 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:25.368613: RECEIVED: Packet 10, +0:00:00.796115 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 SIP/2.0 200 OK 
 Via: SIP/2.0/UDP 192.168.1.6:62054;received=80.101.96.20;rport=62054;branch=z9hG4bKPjwxj-gfiYVdjLvEWkt0l-pLfriN3gjo-T 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 INVITE 
 Server: CSCO/7 
 Contact: <sip:31208005169@80.101.96.20:61000> 
 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> 
 Content-Type: application/sdp 
 Content-Length: 197 

 v=0 
 o=Cisco-SIPUA 8420 8964 IN IP4 192.168.1.123 
 s=SIP Call 
 c=IN IP4 81.23.228.150 
 t=0 0 
 m=audio 51974 RTP/AVP 0 101 
 a=rtpmap:0 PCMU/8000 
 a=rtpmap:101 telephone-event/8000 
 a=fmtp:101 0-15 

 -- 

 2009-09-24 22:31:25.369124: SENDING: Packet 11, +0:00:00.796626 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 ACK sip:31208005169@80.101.96.20:61000 SIP/2.0 
 Via: SIP/2.0/UDP 192.168.1.6:62054;rport;branch=z9hG4bKPjkq3Y5tZfK3d.zASBBAHQHZMavNNRQw0W 
 Max-Forwards: 70 
 From: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 To: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 16888 ACK 
 Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.8e165924> 
 Route: <sip:81.23.228.150;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.e5ffeb2> 
 Route: <sip:85.17.186.7;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.9e165924> 
 Route: <sip:81.23.228.129;lr;ftag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF;did=2f3.985cae24> 
 User-Agent: blink-0.9.0 
 Content-Length:    0 


 -- 

 Audio session established using "PCMU" codec at 8000Hz 
 Audio RTP endpoints 80.101.96.20:62066 <-> 81.23.228.150:51974 
 Detected NAT type: Port Restricted 
 2009-09-24 22:31:40.495793: RECEIVED: Packet 12, +0:00:15.923295 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 NOTIFY sip:80.101.96.20:62054 SIP/2.0 
 Via: SIP/2.0/UDP 85.17.186.7:5060;branch=0 
 From: sip:keepalive@85.17.186.7;tag=7c29b7d5 
 To: sip:80.101.96.20:62054 
 Call-ID: 296fc4b6-56ba6860-24109f@85.17.186.7 
 CSeq: 1 NOTIFY 
 Event: keep-alive 
 Content-Length: 0 


 -- 

 2009-09-24 22:31:40.495929: SENDING: Packet 13, +0:00:15.923431 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 SIP/2.0 405 Method Not Allowed 
 Via: SIP/2.0/UDP 85.17.186.7:5060;received=85.17.186.7;branch=0 
 Call-ID: 296fc4b6-56ba6860-24109f@85.17.186.7 
 From: <sip:keepalive@85.17.186.7>;tag=7c29b7d5 
 To: <sip:80.101.96.20> 
 CSeq: 1 NOTIFY 
 Server: blink-0.9.0 
 Content-Length:    0 


 -- 

 2009-09-24 22:31:43.425393: RECEIVED: Packet 14, +0:00:18.852895 
 85.17.186.7:5060 -(SIP over UDP)-> 192.168.1.6:62054 
 BYE sip:pfxtjskq@80.101.96.20:62054 SIP/2.0 
 Record-Route: <sip:85.17.186.7;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Record-Route: <sip:81.23.228.150;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Record-Route: <sip:85.17.186.7;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Max-Forwards:    7 
 Record-Route: <sip:81.23.228.129;lr=on;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.feada044.0 
 Via: SIP/2.0/UDP 81.23.228.150;branch=z9hG4bK9c22.3cf12dd3.0 
 Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.eeada044.0 
 Via: SIP/2.0/UDP 81.23.228.129;branch=z9hG4bK9c22.877deec6.0 
 Via: SIP/2.0/UDP 192.168.1.123:5060;rport=61000;received=80.101.96.20;branch=z9hG4bK63eb02c1 
 From: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1 
 To: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 CSeq: 101 BYE 
 User-Agent: CSCO/7 
 Content-Length: 0 
 RTP-RxStat: Dur=18,Pkt=29,Oct=4640,LatePkt=0,LostPkt=0,AvgJit=0 
 RTP-TxStat: Dur=18,Pkt=889,Oct=142240 


 -- 

 2009-09-24 22:31:43.425554: SENDING: Packet 15, +0:00:18.853056 
 192.168.1.6:62054 -(SIP over UDP)-> 85.17.186.7:5060 
 SIP/2.0 200 OK 
 Via: SIP/2.0/UDP 85.17.186.7;received=85.17.186.7;branch=z9hG4bK9c22.feada044.0 
 Via: SIP/2.0/UDP 81.23.228.150;branch=z9hG4bK9c22.3cf12dd3.0 
 Via: SIP/2.0/UDP 85.17.186.7;branch=z9hG4bK9c22.eeada044.0 
 Via: SIP/2.0/UDP 81.23.228.129;branch=z9hG4bK9c22.877deec6.0 
 Via: SIP/2.0/UDP 192.168.1.123:5060;rport=61000;received=80.101.96.20;branch=z9hG4bK63eb02c1 
 Record-Route: <sip:85.17.186.7;lr;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Record-Route: <sip:81.23.228.150;lr;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Record-Route: <sip:85.17.186.7;lr;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Record-Route: <sip:81.23.228.129;lr;ftag=000c854663c02cf2799a9168-4ae390b1> 
 Call-ID: TvSQ8UaRQkYIz53p8itOYiV.MLKdlzC3 
 From: <sip:ag@ag-projects.com>;tag=000c854663c02cf2799a9168-4ae390b1 
 To: "Adrian G." <sip:adi@umts.ro>;tag=tv6vh5PXicua6Zuu0ZCv9smnXR.J-CxF 
 CSeq: 101 BYE 
 Server: blink-0.9.0 
 Content-Length:    0 


 -- 

 Audio session ended by remote party 
 Session duration was 18 seconds 
 }}} 

 === Alarm system === 

 sip-audio-session sip_audio_session script can be used for end-to-end testing of a SIP service including the RTP media path. The following follow failures can be detected: 

  * Timeout 
  * Negative response code 
  * Lack of RTP media after the SIP session has been established 
  * Missing ACK 


 To setup the alarm system start periodically a caller script from a monitoring software using the following arguments: 

   {{{ 
 sip-audio-session --auto-hangup user@domain 
   }}} 

 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. 

 To receive calls and answer them automatically you can also use sip_audio_session script as follows: 

   {{{ 
 sip-audio-session --daemonize 
   }}} 

 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.