[asterisk-users] SIP sprials and "482 Loop Detected"

Robby Dermody robbyd at fastmail.fm
Mon Jul 28 12:08:39 CDT 2008


Hi guys, I know this problem has just been fixed in trunk
(http://bugs.digium.com/view.php?id=7403), but I'm asking for a
workaround for previous versions of Asterisk, as we can't run off of
Trunk (e.g. we have to run with Asterisk from Ubuntu 8.10).

Basically, I have a situation where I have Openser and Asterisk running
on the same box. I get a SIP call in (from a remote SIP trunk) to
Asterisk. Asterisk then does a Dial() and sends the INVITE over to
Openser, which rewrites the RURI and then sends the call back to
Asterisk. With this, as the callID and To: fields are the same Asterisk
gets confused and issues a 486 Loop detected error. Of course, the RURI
is different but Asterisk doesn't see this. 

And yes, this may seem convoluted. Normally these components run on
different machines, but I am testing a use case where we have them all
on the same machine. When they're running on different machines (e.g.
Asterisk on box A gets the request, passes it to Openser on box A, then
Openser sends it to Asterisk on box B) this works without a problem.

What I'm wondering is if there is some harmless way the Openser Proxy
can mangle the INVITE back to the Asterisk box so that it avoids this
Loop detected error we see here. Most likely any of this will violate
the SIP spec, but it is a temporary solution so as far as this goes I'd
just like something that works for now until that patch comes to Ubuntu.

Any ideas? I have a SIP debug dump from the Asterisk box below. Note
that I have Openser running on port 5060 and Asterisk running on port
5080. They both run on lab1-int-012 (10.1.14.12), which is 1 to 1 NATted
through to 74.229.XXX.XXX. 64.85.162.136 is the IP of the SIP trunk.

--------------------------

Connected to Asterisk 1.4.17~dfsg-2ubuntu1 currently running on
lab1-int-012 (pid = 7543) Verbosity was 0 and is now 3 lab1-int-012*CLI>
<--- SIP read from 64.85.162.136:5060 ---> INVITE
sip:10000 at 74.229.XXX.XXX:5080 SIP/2.0
Via: SIP/2.0/UDP 64.85.162.136:5060;branch=z9hG4bK332bdcbc;rport
From: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
To: <sip:10000 at 74.229.XXX.XXX:5080>
Contact: <sip:1919932XXXX at 64.85.162.136>
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 INVITE
User-Agent: CWU SIP-GW
Max-Forwards: 70
Date: Mon, 28 Jul 2008 14:03:21 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length: 385

v=0
o=root 4133 4133 IN IP4 208.44.220.234
s=session
c=IN IP4 208.44.220.234
t=0 0
m=audio 14852 RTP/AVP 0 8 3 97 18 111 101 a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:111 G726-32/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
<------------->
--- (14 headers 18 lines) ---
Sending to 64.85.162.136 : 5060 (NAT)
Using INVITE request as basis request -
3b9eec082a54507e4223870654ca232d at 64.85.162.136
Found no matching peer or user for '64.85.162.136:5060'
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 3
Found RTP audio format 97
Found RTP audio format 18
Found RTP audio format 111
Found RTP audio format 101
Peer audio RTP is at port 208.44.220.234:14852 Found audio description
format PCMU for ID 0 Found audio description format PCMA for ID 8 Found
audio description format GSM for ID 3 Found audio description format
iLBC for ID 97 Found audio description format G729 for ID 18 Found audio
description format G726-32 for ID 111 Found audio description format
telephone-event for ID 101
Capabilities: us - 0x100 (g729), peer - audio=0xd0e
(gsm|ulaw|alaw|g726|g729|ilbc)/video=0x0 (nothing), combined - 0x100
(g729) Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer -
0x1 (telephone-event), combined - 0x1 (telephone-event) Peer audio RTP
is at port 208.44.220.234:14852 Looking for 10000 in public (domain
74.229.XXX.XXX)
list_route: hop: <sip:1919932XXXX at 64.85.162.136>

<--- Transmitting (NAT) to 64.85.162.136:5060 ---> SIP/2.0 100 Trying
Via: SIP/2.0/UDP
64.85.162.136:5060;branch=z9hG4bK332bdcbc;received=64.85.162.136;rport=5060
From: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
To: <sip:10000 at 74.229.XXX.XXX:5080>
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: <sip:10000 at 74.229.XXX.XXX:5080>
Content-Length: 0


<------------>
    -- Executing [10000 at public:1] Answer("SIP/64.85.162.136-007414e0",
    "") in new stack Audio is at 74.229.XXX.XXX port 12660 Adding codec
    0x100 (g729) to SDP Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to 64.85.162.136:5060 ---> SIP/2.0 200
OK
Via: SIP/2.0/UDP
64.85.162.136:5060;branch=z9hG4bK332bdcbc;received=64.85.162.136;rport=5060
From: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
To: <sip:10000 at 74.229.XXX.XXX:5080>;tag=as47267a1a
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: <sip:10000 at 74.229.XXX.XXX:5080>
Content-Type: application/sdp
Content-Length: 265

v=0
o=root 7543 7543 IN IP4 74.229.XXX.XXX
s=session
c=IN IP4 74.229.XXX.XXX
t=0 0
m=audio 12660 RTP/AVP 18 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

<------------>
    -- Executing [10000 at public:2] NoOp("SIP/64.85.162.136-007414e0",
    "Asterisk PBX: Incoming from 10000 at 74.229.XXX.XXX") in new stack
    -- Executing [10000 at public:3]
    SIPAddHeader("SIP/64.85.162.136-007414e0", "X-Intermediate-Mangle:
    Incoming") in new stack
    -- Executing [10000 at public:4] Dial("SIP/64.85.162.136-007414e0",
    "SIP/10000 at 10.1.14.12") in new stack Audio is at 10.1.14.12 port
    18546 Adding codec 0x100 (g729) to SDP Adding non-codec 0x1
    (telephone-event) to SDP Reliably Transmitting (NAT) to
    10.1.14.12:5060:
INVITE sip:10000 at 10.1.14.12 SIP/2.0
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>
Contact: <sip:1919932XXXX at 10.1.14.12:5080>
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 70
Date: Mon, 28 Jul 2008 14:03:21 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
X-Intermediate-Mangle: Incoming
Content-Type: application/sdp
Content-Length: 257

v=0
o=root 7543 7543 IN IP4 10.1.14.12
s=session
c=IN IP4 10.1.14.12
t=0 0
m=audio 18546 RTP/AVP 18 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

---
    -- Called 10000 at 10.1.14.12
lab1-int-012*CLI>
<--- SIP read from 10.1.14.12:5060 --->
SIP/2.0 100 Giving a try
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport=5080
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 INVITE
Date: Mon, 28 Jul 2008 14:03:21 GMT
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---
lab1-int-012*CLI>
<--- SIP read from 10.1.14.12:5060 --->
INVITE sip:9000 at 10.1.14.12:5080 SIP/2.0
Record-Route: <sip:74.229.XXX.XXX:5060;ftag=as124ec431;lr=on>
Via: SIP/2.0/UDP 74.229.XXX.XXX:5060;branch=z9hG4bK3f3b.ac918d15.0
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport=5080
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>
Contact: <sip:1919932XXXX at 10.1.14.12:5080>
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 69
Date: Mon, 28 Jul 2008 14:03:21 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
X-Intermediate-Mangle: Incoming
Content-Type: application/sdp
Content-Length: 257
P-hint: sip trunk recognized

v=0
o=root 7543 7543 IN IP4 10.1.14.12
s=session
c=IN IP4 10.1.14.12
t=0 0
m=audio 18546 RTP/AVP 18 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv
<------------->
--- (22 headers 13 lines) ---

<--- Transmitting (NAT) to 10.1.14.12:5060 ---> SIP/2.0 482 Loop
Detected
Via: SIP/2.0/UDP
74.229.XXX.XXX:5060;branch=z9hG4bK3f3b.ac918d15.0;received=10.1.14.12
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport=5080
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>;tag=as124ec431
all-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0
X-Asterisk-HangupCause: Normal Clearing
X-Asterisk-HangupCauseCode: 16


<------------>
Scheduling destruction of SIP dialog
'3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12' in 32000 ms (Method:
INVITE)

<--- SIP read from 10.1.14.12:5060 --->
ACK sip:9000 at 10.1.14.12:5080 SIP/2.0
Via: SIP/2.0/UDP 74.229.XXX.XXX:5060;branch=z9hG4bK3f3b.ac918d15.0
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
To: <sip:10000 at 10.1.14.12>;tag=as124ec431
CSeq: 102 ACK
Max-Forwards: 70
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---

<--- SIP read from 10.1.14.12:5060 --->
SIP/2.0 482 Loop Detected
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport=5080
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>;tag=as124ec431
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0
X-Asterisk-HangupCause: Normal Clearing
X-Asterisk-HangupCauseCode: 16

<------------->
--- (12 headers 0 lines) ---
    -- Got SIP response 482 "Loop Detected" back from 10.1.14.12
    Transmitting (NAT) to 10.1.14.12:5060:
ACK sip:10000 at 10.1.14.12 SIP/2.0
Via: SIP/2.0/UDP 10.1.14.12:5080;branch=z9hG4bK5cd0e7a9;rport
From: "919932XXXX" <sip:1919932XXXX at 10.1.14.12:5080>;tag=as124ec431
To: <sip:10000 at 10.1.14.12>;tag=as124ec431
Contact: <sip:1919932XXXX at 10.1.14.12:5080>
Call-ID: 3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12
CSeq: 102 ACK
User-Agent: Asterisk PBX
Max-Forwards: 70
Content-Length: 0


---
    -- Now forwarding SIP/64.85.162.136-007414e0 to 'Local/10000 at public'
    (thanks to SIP/10.1.14.12-00745820)
    -- Executing [10000 at public:1] Answer("Local/10000 at public-8712,2",
    "") in new stack
    -- Executing [10000 at public:2] NoOp("Local/10000 at public-8712,2",
    "Asterisk PBX: Incoming from 10000@") in new stack
    -- Executing [10000 at public:3]
    SIPAddHeader("Local/10000 at public-8712,2", "X-Intermediate-Mangle:
    Incoming") in new stack
    -- Executing [10000 at public:4] Dial("Local/10000 at public-8712,2",
    "SIP/10000 at 10.1.14.12") in new stack [Jul 28 14:03:21]
    WARNING[7579]: app_dial.c:1177 dial_exec_full: Skipping dialing
    interface 'SIP/10000 at 10.1.14.12' again since it has already been
    dialed
  == Spawn extension (public, 10000, 4) exited non-zero on
  'Local/10000 at public-8712,2'
    -- Local/10000 at public-8712,1 answered SIP/64.85.162.136-007414e0
  == Spawn extension (public, 10000, 4) exited non-zero on
  'SIP/64.85.162.136-007414e0'
Scheduling destruction of SIP dialog
'3b9eec082a54507e4223870654ca232d at 64.85.162.136' in 32000 ms (Method:
INVITE) lab1-int-012*CLI>
<--- SIP read from 64.85.162.136:5060 ---> ACK
sip:10000 at 74.229.XXX.XXX:5080 SIP/2.0
Via: SIP/2.0/UDP 64.85.162.136:5060;branch=z9hG4bK1fc6c8b1;rport
From: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
To: <sip:10000 at 74.229.XXX.XXX:5080>;tag=as47267a1a
Contact: <sip:1919932XXXX at 64.85.162.136>
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 ACK
User-Agent: CWU SIP-GW
Max-Forwards: 70
Content-Length: 0

<------------->
--- (10 headers 0 lines) ---
set_destination: Parsing <sip:1919932XXXX at 64.85.162.136> for
address/port to send to
set_destination: set destination to 64.85.162.136, port 5060 Reliably
Transmitting (NAT) to 64.85.162.136:5060:
BYE sip:1919932XXXX at 64.85.162.136 SIP/2.0
Via: SIP/2.0/UDP 74.229.XXX.XXX:5080;branch=z9hG4bK6363baab;rport
From: <sip:10000 at 74.229.XXX.XXX:5080>;tag=as47267a1a
To: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 BYE
User-Agent: Asterisk PBX
Max-Forwards: 70
Content-Length: 0


---
Scheduling destruction of SIP dialog
'3b9eec082a54507e4223870654ca232d at 64.85.162.136' in 32000 ms (Method:
ACK) Really destroying SIP dialog
'3cbcce510aabf19f7fb70ec94b593ab4 at 10.1.14.12' Method: ACK
lab1-int-012*CLI>
<--- SIP read from 64.85.162.136:5060 ---> SIP/2.0 200 OK
Via: SIP/2.0/UDP
74.229.XXX.XXX:5080;branch=z9hG4bK6363baab;received=74.229.XXX.XXX;rport=5080
From: <sip:10000 at 74.229.XXX.XXX:5080>;tag=as47267a1a
To: "919932XXXX" <sip:1919932XXXX at 64.85.162.136>;tag=as36c86fee
Call-ID: 3b9eec082a54507e4223870654ca232d at 64.85.162.136
CSeq: 102 BYE
User-Agent: CWU SIP-GW
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: <sip:1919932XXXX at 64.85.162.136>
Content-Length: 0

<------------->I>
--- (11 headers 0 lines) ---
SIP Response message for INCOMING dialog BYE arrived Really destroying
SIP dialog '3b9eec082a54507e4223870654ca232d at 64.85.162.136' Method: ACK

-------------------------
Thanks,

Robby




More information about the asterisk-users mailing list