[OpenSIPS-Users] OpenSIPS ALG

John Morris john at zultron.com
Sat May 30 13:54:26 CEST 2009


Bogdan,

I put this down for a little while, and just picked it up again. See below.

Bogdan-Andrei Iancu wrote:
 > This mid-registrar approach may work but it is not 100% correct as
 > OpenSIPS (as mid-registrar) does not obey the actions of the final
 > registrar (Asterisk). Ex: - Asterisk may forbid the registration and
 > you already saved the registration on OpenSIPS

I think this is OK.  The purpose is just to record the location of the
registered phone.  If the registration fails, the "0x02" flag in the
save() statement prevents an incorrect response to the registration
to the UAC, and the ul entry should be harmless until it expires.

 > - Asterisk may change the Expire time while to saved the registration
 >  with the expire sent by client.

I don't understand this, but it sounds like a case where the expiration
date of the registration doesn't match that in the ul table?  I don't 
know in what circumstances the ul entry in OpenSIPS would expire and 
presumably be removed before the UAC's registration expires, leaving a 
situation where OpenSIPS can't look up the UAC's location.  Can you comment?

 > Anyhow, ignoring this aspects, lets go further :) :
 >
 > 1) is the registration scenario working ok? if not what is the exact
 > problem (some trace will help).

Yes, it seems to be!

 > I will wait for you answer before moving further with the calling
 > stuff.

The registration seems to be the easy part of this configuration (or
else I haven't gotten far enough along to run into the difficulties that 
lie ahead).  The hard part is multi-homed configuration of OpenSIPS and
RTPProxy; I've found few examples to crib from.

By the way, the test setup here is a little bit strange, though I don't 
think it's causing the following problems.  Because I can't touch the 
office gateway (the VPN router, here) for experimenting, the path is set
up to go through an Internet host with traffic tunneled through a VPN.

Zoiper		NAT rtr, int.	NAT rtr, ext.	-->
192.168.7.60	192.168.7.1	221.221.241.189	-->

<-- Internet -->

<--	OpenSIPS eth0	OpenSIPS tun4	(VPN router)	Asterisk
<--	1.2.3.4	192.168.106.1			192.168.3.19

For the most part, the signaling seems to work.  OpenSIPS is passing
REGISTER, NOTIFY, OPTIONS, INVITE and the rest of the associated
dialogs (mostly) correctly.

One bit I'm a little confused about is Contact: header from Asterisk:

	Contact: <sip:*43 at 192.168.3.19>.

(See the INVITE "OK" response.)  This should be changed to the
external IP of OpenSIPS on its way back to Zoiper.  Should a
fix_nated_contact be used, or should this be done manually somehow,
since Asterisk isn't really NATted from OpenSIPS's perspective?

The next problem is with the RTP streams (see below for tcpdumps).
Zoiper and Asterisk both begin to send RTP packets to their respective
RTPProxy ports.  RTPProxy relays the Asterisk traffic back to the
Zoiper, but at its pre-NATted RFC1918 address.  None of the Zoiper
traffic is forwarded to Asterisk.

I've spent quite some time sorting through the documentation, but
haven't found the answer to these problems yet.  I'd also like to know, 
since I really don't know what I'm doing here, whether I'm going down a 
terribly foolish path either with this idea or with the structure of the 
opensips.cfg file at the bottom.

Following are ngreps of the SIP traffic and tcpdumps of the RTP
traffic, all tagged with the interface name, and finally the
opensips.cfg.  RTPProxy is run as follows:

	/usr/bin/rtpproxy -u rtpproxy rtpproxy \
	-s unix:/var/run/rtpproxy.sock \
	-l 192.168.106.1/1.2.3.4 -t 0xB8 -m 35000 \
	-M 35019 -d DBUG

Sorry for the copious output.

       John


----------------------------------------------------------------------
Trace of the INVITE:

[... INVITE/407 Proxy Auth Required sequence deleted ...]

eth0: #
eth0: U 18:08:56.549561 221.221.241.189:5060 -> 1.2.3.4:5060
eth0: INVITE sip:*43 at pbx0.example.com;transport=UDP SIP/2.0.
eth0: Via: SIP/2.0/UDP
   192.168.7.60:5060;branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
eth0: Max-Forwards: 70.
eth0: Contact: <sip:150 at 192.168.7.60:5060;transport=UDP>.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 2 INVITE.
eth0: Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
   OPTIONS, INFO, SUBSCRIBE.
eth0: Content-Type: application/sdp.
eth0: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at pbx0.example.com;transport=UDP",
   response="1445b6b432b9b275b4880d71cf8e1c96",algorithm=MD5.
eth0: User-Agent: Zoiper rev.3938.
eth0: Content-Length: 171.
eth0: .
eth0: v=0.
eth0: o=Zoiper_user 0 0 IN IP4 192.168.7.60.
eth0: s=Idefisk_user.
eth0: c=IN IP4 192.168.7.60.
eth0: t=0 0.
eth0: m=audio 8000 RTP/AVP 0 3.
eth0: a=rtpmap:0 PCMU/8000.
eth0: a=rtpmap:3 GSM/8000.
eth0: a=sendrecv.
eth0:
eth0: #
eth0: U 18:08:56.775261 1.2.3.4:5060 -> 221.221.241.189:5060
eth0: SIP/2.0 100 Giving a try.
eth0: Via: SIP/2.0/UDP 1.2.3.4:5060;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-;
   rport=5060;received=221.221.241.189.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 2 INVITE.
eth0: Server: OpenSIPS (1.5.0-notls (i386/linux)).
eth0: Content-Length: 0.
eth0: .
eth0:
tun4: #
tun4: U 18:08:56.775920 192.168.106.1:5060 -> 192.168.3.19:5060
tun4: INVITE sip:*43 at pbx0.example.com;transport=UDP SIP/2.0.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: Via: SIP/2.0/UDP 192.168.106.1:5060;branch=z9hG4bK74c8.dacafed2.0.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
tun4: Max-Forwards: 70.
tun4: Contact: <sip:150 at 192.168.106.1:5060;transport=UDP>.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 2 INVITE.
tun4: Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
   OPTIONS, INFO, SUBSCRIBE.
tun4: Content-Type: application/sdp.
tun4: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at pbx0.example.com;transport=UDP",
   response="1445b6b432b9b275b4880d71cf8e1c96",algorithm=MD5.
tun4: User-Agent: Zoiper rev.3938.
tun4: Content-Length: 219.
tun4: .
tun4: v=0.
tun4: o=Zoiper_user 0 0 IN IP4 192.168.106.1.
tun4: s=Idefisk_user.
tun4: c=IN IP4 192.168.106.1.
tun4: t=0 0.
tun4: m=audio 35016 RTP/AVP 0 3.
tun4: a=rtpmap:0 PCMU/8000.
tun4: a=rtpmap:3 GSM/8000.
tun4: a=sendrecv.
tun4: a=oldmediaip:192.168.7.60.
tun4: a=nortpproxy:yes.
tun4:
eth0: #
eth0: U 18:08:57.058325 221.221.241.189:5060 -> 1.2.3.4:5060
eth0: INVITE sip:*43 at pbx0.example.com;transport=UDP SIP/2.0.
eth0: Via: SIP/2.0/UDP 192.168.7.60:5060;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
eth0: Max-Forwards: 70.
eth0: Contact: <sip:150 at 192.168.7.60:5060;transport=UDP>.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 2 INVITE.
eth0: Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
   OPTIONS, INFO, SUBSCRIBE.
eth0: Content-Type: application/sdp.
eth0: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at pbx0.example.com;transport=UDP",
   response="1445b6b432b9b275b4880d71cf8e1c96",algorithm=MD5.
eth0: User-Agent: Zoiper rev.3938.
eth0: Content-Length: 171.
eth0: .
eth0: v=0.
eth0: o=Zoiper_user 0 0 IN IP4 192.168.7.60.
eth0: s=Idefisk_user.
eth0: c=IN IP4 192.168.7.60.
eth0: t=0 0.
eth0: m=audio 8000 RTP/AVP 0 3.
eth0: a=rtpmap:0 PCMU/8000.
eth0: a=rtpmap:3 GSM/8000.
eth0: a=sendrecv.
eth0:
eth0: #
eth0: U 18:08:57.058884 1.2.3.4:5060 -> 221.221.241.189:5060
eth0: SIP/2.0 100 Giving a try.
eth0: Via: SIP/2.0/UDP 1.2.3.4:5060;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-;
   rport=5060;received=221.221.241.189.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 2 INVITE.
eth0: Server: OpenSIPS (1.5.0-notls (i386/linux)).
eth0: Content-Length: 0.
eth0: .
eth0:
tun4: #
tun4: U 18:08:57.295341 192.168.106.1:5060 -> 192.168.3.19:5060
tun4: INVITE sip:*43 at pbx0.example.com;transport=UDP SIP/2.0.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: Via: SIP/2.0/UDP 192.168.106.1:5060;branch=z9hG4bK74c8.dacafed2.0.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
tun4: Max-Forwards: 70.
tun4: Contact: <sip:150 at 192.168.106.1:5060;transport=UDP>.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 2 INVITE.
tun4: Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, 
INFO, SUBSCRIBE.
tun4: Content-Type: application/sdp.
tun4: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at pbx0.example.com;transport=UDP",
   response="1445b6b432b9b275b4880d71cf8e1c96",algorithm=MD5.
tun4: User-Agent: Zoiper rev.3938.
tun4: Content-Length: 219.
tun4: .
tun4: v=0.
tun4: o=Zoiper_user 0 0 IN IP4 192.168.106.1.
tun4: s=Idefisk_user.
tun4: c=IN IP4 192.168.106.1.
tun4: t=0 0.
tun4: m=audio 35016 RTP/AVP 0 3.
tun4: a=rtpmap:0 PCMU/8000.
tun4: a=rtpmap:3 GSM/8000.
tun4: a=sendrecv.
tun4: a=oldmediaip:192.168.7.60.
tun4: a=nortpproxy:yes.
tun4:
tun4: #
tun4: U 18:08:57.536179 192.168.3.19:5060 -> 192.168.106.1:5060
tun4: SIP/2.0 100 Trying.
tun4: Via: SIP/2.0/UDP 192.168.3.19:5060;branch=z9hG4bK74c8.dacafed2.0;
   received=192.168.106.1.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>.
eth0: #
eth0: U 18:08:57.541789 1.2.3.4:5060 -> 221.221.241.189:5060
eth0: SIP/2.0 200 OK.
eth0: Via: SIP/2.0/UDP 1.2.3.4:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
eth0: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
eth0: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 2 INVITE.
eth0: User-Agent: Asterisk PBX.
eth0: Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER,
   SUBSCRIBE, NOTIFY.
eth0: Supported: replaces.
eth0: Contact: <sip:*43 at 192.168.3.19>.
eth0: Content-Type: application/sdp.
eth0: Content-Length: 204.
eth0: .
eth0: v=0.
eth0: o=root 1501 1501 IN IP4 1.2.3.4.
eth0: s=session.
eth0: c=IN IP4 1.2.3.4.
eth0: t=0 0.
eth0: m=audio 35006 RTP/AVP 0.
eth0: a=rtpmap:0 PCMU/8000.
eth0: a=silenceSupp:off - - - -.
eth0: a=ptime:20.
eth0: a=sendrecv.
eth0: a=nortpproxy:yes.
eth0:
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 2 INVITE.
tun4: User-Agent: Asterisk PBX.
tun4: Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY.
tun4: Supported: replaces.
tun4: Contact: <sip:*43 at 192.168.3.19>.
tun4: Content-Length: 0.
tun4: .
tun4:
tun4: #
tun4: U 18:08:57.541168 192.168.3.19:5060 -> 192.168.106.1:5060
tun4: SIP/2.0 200 OK.
tun4: Via: SIP/2.0/UDP 192.168.3.19:5060;branch=z9hG4bK74c8.dacafed2.0;
   received=192.168.106.1.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-621e7cd587b50f77-1---d8754z-.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 2 INVITE.
tun4: User-Agent: Asterisk PBX.
tun4: Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER,
   SUBSCRIBE, NOTIFY.
tun4: Supported: replaces.
tun4: Contact: <sip:*43 at 192.168.3.19>.
tun4: Content-Type: application/sdp.
tun4: Content-Length: 182.
tun4: .
tun4: v=0.
tun4: o=root 1501 1501 IN IP4 192.168.3.19.
tun4: s=session.
tun4: c=IN IP4 192.168.3.19.
tun4: t=0 0.
tun4: m=audio 11948 RTP/AVP 0.
tun4: a=rtpmap:0 PCMU/8000.
tun4: a=silenceSupp:off - - - -.
tun4: a=ptime:20.
tun4: a=sendrecv.
tun4:


RTP packets start here:
eth0: 18:08:57.906935 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
eth0: 18:08:57.926913 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
eth0: 18:08:57.946936 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
[...]
tun4: 18:08:58.539710 IP 192.168.3.19.11948 > 192.168.106.1.35016: UDP, 
length 172
eth0: 18:08:58.539819 IP 1.2.3.4.35006 > 192.168.7.60.8000: UDP, length 172
eth0: 18:08:58.547647 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
tun4: 18:08:58.560680 IP 192.168.3.19.11948 > 192.168.106.1.35016: UDP, 
length 172
eth0: 18:08:58.560739 IP 1.2.3.4.35006 > 192.168.7.60.8000: UDP, length 172
eth0: 18:08:58.569607 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
eth0: 18:08:58.587601 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
tun4: 18:08:58.599667 IP 192.168.3.19.11948 > 192.168.106.1.35016: UDP, 
length 172
eth0: 18:08:58.599728 IP 1.2.3.4.35006 > 192.168.7.60.8000: UDP, length 172
eth0: 18:08:58.607647 IP 221.221.241.189.8000 > 1.2.3.4.35006: UDP, 
length 172
[...]

RTPProxy logs near this point:
May 30 18:08:55 horseman rtpproxy[1367]: INFO:handle_command: new
   session Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk., tag 11409305;1
   requested, type strong
May 30 18:08:55 horseman rtpproxy[1367]: INFO:handle_command: new
   session on a port 35016 created, tag 11409305;1
May 30 18:08:55 horseman rtpproxy[1367]: INFO:handle_command:
   pre-filling caller's address with 192.168.7.60:8000
[...]
May 30 18:08:56 horseman rtpproxy[1367]: INFO:handle_command: adding
   strong flag to existing session, new=1/0/0
May 30 18:08:56 horseman rtpproxy[1367]: INFO:handle_command: lookup on
   ports 35016/0, session timer restarted
[...]
May 30 18:08:57 horseman rtpproxy[1367]: INFO:handle_command: adding
   strong flag to existing session, new=1/0/0
May 30 18:08:57 horseman rtpproxy[1367]: INFO:handle_command: lookup on
   ports 35016/0, session timer restarted
[...]
May 30 18:08:57 horseman rtpproxy[1367]: INFO:handle_command: lookup on
   ports 35016/35006, session timer restarted
May 30 18:08:57 horseman rtpproxy[1367]: INFO:handle_command:
   pre-filling callee's address with 192.168.3.19:11948


eth0: #
eth0: U 18:09:03.553257 221.221.241.189:5060 -> 1.2.3.4:5060
eth0: BYE sip:*43 at 192.168.3.19 SIP/2.0.
eth0: Via: SIP/2.0/UDP 192.168.7.60:5060;
   branch=z9hG4bK-d8754z-8ae3d2f2611224da-1---d8754z-.
eth0: Max-Forwards: 70.
eth0: Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
eth0: Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
eth0: Contact: <sip:150 at 192.168.7.60:5060;transport=UDP>.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
eth0: From: 
"jman-test"<sip:150 at pbx0.example.com;transport=UDP>;tag=11409305.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 3 BYE.
eth0: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at 192.168.3.19",
   response="ac91faccd6e8fef383b17d04757bbdc7",algorithm=MD5.
eth0: User-Agent: Zoiper rev.3938.
eth0: Content-Length: 0.
eth0: .
eth0:
tun4: #
tun4: U 18:09:03.553586 192.168.106.1:5060 -> 192.168.3.19:5060
tun4: BYE sip:*43 at 192.168.3.19 SIP/2.0.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: Via: SIP/2.0/UDP 192.168.106.1:5060;branch=z9hG4bK84c8.ca5a3281.0.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-8ae3d2f2611224da-1---d8754z-.
tun4: Max-Forwards: 70.
tun4: Contact: <sip:150 at 192.168.106.1:5060;transport=UDP>.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 3 BYE.
tun4: Proxy-Authorization: Digest username="150",realm="asterisk",
   nonce="6e0d2196",uri="sip:*43 at 192.168.3.19",
   response="ac91faccd6e8fef383b17d04757bbdc7",algorithm=MD5.
tun4: User-Agent: Zoiper rev.3938.
tun4: Content-Length: 0.
tun4: .
tun4:

tun4: 18:09:03.576347 IP 192.168.3.19.11948 > 192.168.106.1.35016: UDP, 
length 172
eth0: 18:09:03.576422 IP 1.2.3.4.35006 > 192.168.7.60.8000: UDP, length 172
tun4: 18:09:03.596299 IP 192.168.3.19.11948 > 192.168.106.1.35016: UDP, 
length 172
eth0: 18:09:03.596354 IP 1.2.3.4.35006 > 192.168.7.60.8000: UDP, length 172
[...]

eth0: #
eth0: U 18:09:03.793383 1.2.3.4:5060 -> 221.221.241.189:5060
eth0: SIP/2.0 200 OK.
eth0: Via: SIP/2.0/UDP 1.2.3.4:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-8ae3d2f2611224da-1---d8754z-.
eth0: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
eth0: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
eth0: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
eth0: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
eth0: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
eth0: CSeq: 3 BYE.
eth0: User-Agent: Asterisk PBX.
eth0: Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER,
   SUBSCRIBE, NOTIFY.
eth0: Supported: replaces.
eth0: Contact: <sip:*43 at 192.168.3.19>.
eth0: Content-Length: 0.
eth0: .
eth0:
tun4: #
tun4: U 18:09:03.793193 192.168.3.19:5060 -> 192.168.106.1:5060
tun4: SIP/2.0 200 OK.
tun4: Via: SIP/2.0/UDP 192.168.3.19:5060;
   branch=z9hG4bK84c8.ca5a3281.0;received=192.168.106.1.
tun4: Via: SIP/2.0/UDP 192.168.7.60:5060;rport=5060;
   received=221.221.241.189;
   branch=z9hG4bK-d8754z-8ae3d2f2611224da-1---d8754z-.
tun4: Record-Route: <sip:192.168.106.1;r2=on;lr;ftag=11409305>.
tun4: Record-Route: <sip:1.2.3.4;r2=on;lr;ftag=11409305>.
tun4: From: "jman-test"<sip:150 at pbx0.example.com;transport=UDP>;
   tag=11409305.
tun4: To: <sip:*43 at pbx0.example.com;transport=UDP>;tag=as621c37a2.
tun4: Call-ID: Nzg5MTBmNDcwNzhmNjEwM2YwNjFjZTRhN2JlZDRjZDk..
tun4: CSeq: 3 BYE.
tun4: User-Agent: Asterisk PBX.
tun4: Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER,
   SUBSCRIBE, NOTIFY.
tun4: Supported: replaces.
tun4: Contact: <sip:*43 at 192.168.3.19>.
tun4: Content-Length: 0.
tun4: .
tun4:

More RTPProxy logs:
[...]
May 30 18:09:09 horseman rtpproxy[1367]: INFO:process_rtp: session
   timeout
May 30 18:09:09 horseman rtpproxy[1367]: INFO:remove_session: RTP stats:
   752 in from callee, 0 in from caller, 752 relayed, 0 dropped
May 30 18:09:09 horseman rtpproxy[1367]: INFO:remove_session: RTCP
   stats: 3 in from callee, 0 in from caller, 3 relayed, 0 dropped
May 30 18:09:09 horseman rtpproxy[1367]: INFO:remove_session: session on
   ports 35010/35018 is cleaned up



----------------------------------------------------------------------
opensips.cfg:

debug=3
fork=yes
log_stderror=no

check_via=no    # (cmd. line: -v)
dns=no          # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
auto_aliases=no
listen=udp:eth0
listen=udp:tun4
children=1
mhomed=1
disable_tcp=yes
disable_dns_blacklist=true

# ------------------ module loading ----------------------------------
mpath="/usr/lib/opensips/modules/"

loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

loadmodule "textops.so"
loadmodule "xlog.so"
loadmodule "signaling.so"
loadmodule "sl.so"

loadmodule "tm.so"
# -- tm params --
modparam("tm", "fr_inv_timer", 100)
modparam("tm", "fr_inv_timer_avp", "$avp(i:26)")
modparam("tm", "fr_timer", 10)
modparam("tm", "fr_timer_avp", "$avp(i:25)")
modparam("tm", "onreply_avp_mode", 1)

loadmodule "rr.so"

loadmodule "usrloc.so"
modparam("usrloc", "db_mode",   0)
modparam("usrloc", "nat_bflag", 6)

loadmodule "registrar.so"
modparam("registrar", "method_filtering", 1)

loadmodule "nathelper.so"
modparam("nathelper", "rtpproxy_sock", "/var/run/rtpproxy.sock")
modparam("nathelper|registrar", "received_avp", "$avp(i:42)")
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", "sip:pinger at zultron.com")

# -------------------------  request routing logic -------------------

# main routing logic

route{
	xlog("L_ERR","Source IP:  $si, Received IP: $Ri, method:  $rm\n");

         if (uri==myself) {
                 sl_send_reply("404", "Not Found");
                 exit;
         };

         # NAT detection
         route(2);

         if (!method=="REGISTER") {
		xlog("L_ERR","! is_method REGISTER\n");
                 record_route();
         }

	if (is_method("REGISTER"))
	{
		xlog("L_ERR","is_method REGISTER\n");
		if (!save("location","0x02")) {
			xlog("L_ERR","! save location\n");
			sl_reply_error();
		} else {
			xlog("L_ERR","saved location\n");
		}
	} else {
		xlog("L_ERR","! is_method REGISTER\n");
		if ($Ri == "192.168.106.1") {
			xlog("L_ERR","looking up location\n");
			if (!lookup("location")) {
				switch ($retcode) {
					case -1:
						xlog("L_ERR","lookup location: no contact found\n");
					case -3:
						xlog("L_ERR","lookup location: internal error\n");
						t_newtran();
						t_reply("404", "Not Found");
						exit;
					case -2:
						xlog("L_ERR","lookup location: contact found, method not 
supported\n");
						sl_send_reply("405", "Method Not Allowed");
						exit;
				}
			} else {
				xlog("L_ERR","	contact found, socket:  $fs\n");
			}
		}
	}

         if (loose_route()) {
		xlog("L_ERR","loose_route\n");
                 route(1);
         };

         route(1);
}

route[1] {
	# do rtpproxy
	route(3);

         if (!t_relay()) {
                 sl_reply_error();
         };
         exit;
}


route[2]{
         force_rport();
         if (nat_uac_test("19")) {
                 xlog("L_ERR","  nat_uac_test(19)");
                 if (method=="REGISTER") {
                         fix_nated_register();
                 } else {
                         fix_nated_contact();
                 };
                 setflag(5);
         };
}

route[3]{
	# start rtpproxy on INVITEs
	
         if (is_method("INVITE")) {
                 xlog("L_ERR","is_method INVITE\n");
                 t_on_branch("2");
	        if (nat_uac_test("19")) {
         	        xlog("L_ERR","  nat_uac_test(19): fix_nated_sdp");
			fix_nated_sdp("8");
		}

                 if ($Ri == "192.168.106.1") {
                         xlog("L_ERR","  INVITE received on internal IP\n");
                         #if (rtpproxy_offer("FAI","192.168.254.1"))
                         if (rtpproxy_offer("FAI"))
                                 t_on_reply("3");
                 } else {
                         xlog("L_ERR","  INVITE received on external IP\n");
                         #if (rtpproxy_offer("FAE","1.2.3.4"))
                         if (rtpproxy_offer("FAE"))
                                 t_on_reply("3");
                 }
                 #t_on_reply("3");
                 t_on_failure("3");
         }
}

onreply_route[3] {
         xlog("L_ERR","onreply_route[3], source IP $si, method $rm\n");
         xlog("incoming reply\n");
         if (status=~"(183)|(2[0-9][0-9])") {
                 if ($Ri == "192.168.254.1") {
                         xlog("L_ERR","  INVITE reply received on 
internal IP\n");
                         #fix_nated_sdp("2","1.2.3.4");
                         #if (rtpproxy_answer("FAI","1.2.3.4"))
                         if (rtpproxy_answer("FAI"))
                                 t_on_reply("1");
                 } else {
                         xlog("L_ERR","  INVITE reply received on 
external IP\n");
                         #fix_nated_sdp("2","1.2.3.4");
                         #if (rtpproxy_answer("FAE","192.168.254.1"))
                         if (rtpproxy_answer("FAE"))
                                 t_on_reply("1");
                 }
         }
}

failure_route[3] {
         xlog("L_ERR","failure_route[3], source IP $si, method $rm\n");
         if (t_was_cancelled()) {
                 xlog("L_ERR","t_was_cancelled\n");
                 exit;
         }
}




More information about the Users mailing list