Hello. I try to provide call scheme:

internal client  -> asterisk -> Kamailio -> provider -> external endpoint call

when I make call I see this:

asterisk     kamailio   provider
invite -->       invite -->   
                                <--     407
                       ACK   -->    
                       invite w/Auth -->
              <--    100  <--    100
              <--    180  <--    180
              <--    183  <--    183
               <--    200  <--      200
   ACK  -->   ACK  -->

My problem with last ACK, that I send to provider. Provider ignores it, and sends me some OK packets. As resultI can notend session ( answer to BYE 481 - transaction does not exists). I think it is wrong ACK but can not undrtand where I do mistake.

Please help me to find it: 

My invite (with Auth creditans):

IP 10.0.1.18.5068 > my.provider.ip.5060: UDP, length 1606
E...]. .@..R
...6........N0TINVITE sip:12345678900@my.provider.ip:5060 SIP/2.0
Record-Route: <sip:my.external.ip:5068;nat=yes;ftag=as7d06fc50;lr=on>
Via: SIP/2.0/UDP my.external.ip:5068;branch=z9hG4bK48ba.74ed5eb56b172cd802c50dcc201cce56.1
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK258b5220;rport=50600
Max-Forwards: 70
From: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>
Contact:<provider_username@my.external.ip:5068>
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 INVITE
User-Agent: Asterisk PBX 12.5.0
Date: Wed, 27 Aug 2014 22:02:58 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 544
Proxy-Authorization: Digest username="provider_username", realm="my.provider.ip", nonce="U/5Wv1P+VZNjFBLf6fwPizgd6iLto5St", uri="sip:12345678900@my.provider.ip:5060", qop=auth, nc=00000001, cnonce="2888860875", response="9f23110471fe9ff751cd55466e70ded2", algorithm=MD5

v=0
o=root 1370647246 1370647246 IN IP4 12.34.56.78
s=Asterisk PBX 12.5.0
c=IN IP4 12.34.56.78
t=0 0
a=ice-lite
m=audio 30296 RTP/AVP 0 3 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp:30297
a=ice-ufrag:p5k92ynl
a=ice-pwd:FIOYKt96NlBfEqKsQipUuadUev1g
a=candidate:vV3V06Tv



Provider trying


IP my.provider.ip.5060 > 10.0.1.18.5068: UDP, length 500
E.........PX6...
..........ySIP/2.0 100 trying -- your call is important to us
Via: SIP/2.0/UDP my.external.ip:5068;branch=z9hG4bK48ba.74ed5eb56b172cd802c50dcc201cce56.1;rport=5068;received=12.34.56.78
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK258b5220;rport=50600
From: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 INVITE
Server: kamailio (4.1.2 (x86_64/linux))
Content-Length: 0




provider ringing




IP my.provider.ip.5060 > 10.0.1.18.5068: UDP, length 1098
E..f......M.6...
........RV.SIP/2.0 180 Ringing
Via: SIP/2.0/UDP my.external.ip:5068;rport=5068;received=12.34.56.78;branch=z9hG4bK48ba.74ed5eb56b172cd802c50dcc201cce56.1
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK258b5220;rport=50600
Record-Route: <sip:my.provider.ip;lr=on;ftag=as7d06fc50;did=5bc.33f1>
Record-Route: <sip:my.external.ip:5068;nat=yes;ftag=as7d06fc50;lr=on>
From: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>;tag=v9g4HD4vrNFUH
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 INVITE
Contact: <sip:12345678900@67.192.253.160:5060;transport=udp>
User-Agent: Plivo
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Length: 0
Remote-Party-ID: "12345678900" <sip:12345678900@my.provider.ip>;party=calling;privacy=off;screen=no



provider seesion in progress



IP my.provider.ip.5060 > 10.0.1.18.5068: UDP, length 1887
E..... ...,.6...
........g.DSIP/2.0 183 Session Progress
Via: SIP/2.0/UDP my.external.ip:5068;rport=5068;received=12.34.56.78;branch=z9hG4bK48ba.74ed5eb56b172cd802c50dcc201cce56.1
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK258b5220;rport=50600
Record-Route: <sip:my.provider.ip;lr=on;ftag=as7d06fc50;did=5bc.33f1>
Record-Route: <sip:my.external.ip:5068;nat=yes;ftag=as7d06fc50;lr=on>
From: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>;tag=v9g4HD4vrNFUH
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 INVITE
Contact: <sip:12345678900@67.192.253.160:5060;transport=udp>
User-Agent: Plivo
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 742
Remote-Party-ID: "12345678900" <sip:12345678900@my.provider.ip>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1409149800 1409149801 IN IP4 67.192.253.160
s=FreeSWITCH
c=IN IP4 67.192.253.160
t=0 0
a=msid-semantic: WMS uIWGGSqM8mUp5NEgQ9CU0svyzqjzisqD
m=audio 27180 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=ssrc:326362635 cnam




provider OK



IP my.provider.ip.5060 > 10.0.1.18.5068: UDP, length 2026
E..... ...,.6...
...........SIP/2.0 200 OK
Via: SIP/2.0/UDP my.external.ip:5068;rport=5068;received=12.34.56.78;branch=z9hG4bK48ba.74ed5eb56b172cd802c50dcc201cce56.1
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK258b5220;rport=50600
Record-Route: <sip:my.provider.ip;lr=on;ftag=as7d06fc50;did=5bc.33f1>
Record-Route: <sip:my.external.ip:5068;nat=yes;ftag=as7d06fc50;lr=on>
Fл2rom: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>;tag=v9g4HD4vrNFUH
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 INVITE
Contact: <sip:12345678900@67.192.253.160:5060;transport=udp>
User-Agent: Plivo
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY, PUBLISH, SUBSCRIBE
SupлЛ
o=FreeSWITCH 1409149800 1409149801 IN IP4 67.192.253.160
s=FreeSWITCH
c=л2IN IP4 67.192.253.160
t=0 0
a=msid-semantic: WMS uIWGGSqM8mUp5NEgQ9CU0svyzqjzisqD
m=audio 27180 RTP/AVP 0




my ACK




IP 10.0.1.18.5068 > my.provider.ip.5060: UDP, length 614
E...]...@...
...6........n.hACK sip:12345678900@my.provider.ip:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP my.external.ip:5068;branch=z9hG4bK48ba.4250e4d315c4aa6697b6d7f70e861b62.0
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK4d28fc11;rport=50600
Route: <sip:my.provider.ip;lr=on;ftag=as7d06fc50;did=5bc.33f1>
Max-Forwards: 70
From: "John" <sip:provider_username@my.provider.ip>;tag=as7d06fc50
To: <sip:12345678900@my.provider.ip:5068>;tag=v9g4HD4vrNFUH
Contact:<provider_username@my.external.ip:5068>
Call-ID: 2122fc6a3cbe2e64253289cf23c3dd2a@10.0.1.6:50600
CSeq: 102 ACK
User-Agent: Asterisk PBX 12.5.0
Content-Length: 0



So after this ACK provider still sends me 200 OK and my server still sends ACK....

tags and call-id always one.


Thanks