I'm experiencing some problems getting 2 Kamailios to work together.
A clients - A kamailio - B kamailio - B clients | the outside world
A and B client may or may not be NATed to their own kamailio instance. A and B kamailio (with forced rtpproxies) are in the same public network. A-kamailio and its clients are essentially a reseller of my services on the B side.
The problem arises when A or B incorrectly flag a message as needing NAT help so either an unnecessary add_contact_alias is added (which seems to happen when putting somebody on hold on an A-client). A-kamailio inserts an alias on the Contact header containing the ip/port of B-kamailio. Trying to resume the call sends the contact with the alias to B-kamailio, which does a handle_ruri_alias and thus sets $du to itself, the party that was on hold will never receive these messages.
The problem I have with add_contact_alias/handle_ruri_alias is that any kamailio in the path will parse these hints whether or not it is actually ment for that kamailio. I'd rather see a scheme that somehow identifies if the added alias was generated locally and thus needs to be handled or can just be ignored. Anybody else got these problems/frustrations and maybe a hint for an other way to tackle this problem?
Off to figure out why uac_test incorrectly flags the onhold process as needing the nat helper...
On 02/05/2014 11:20 AM, Daniel Tryba wrote:
Off to figure out why uac_test incorrectly flags the onhold process as needing the nat helper...
Well, nat_uac_test is pretty straightforward, it does what the flags tell it to do: http://kamailio.org/docs/modules/stable/modules/nathelper.html#idp1655008 What I do is skip nat_uac_test for the requests and responses coming from other proxies' IPs..
Andrew
On Wednesday 05 February 2014 12:04:02 Andrew Pogrebennyk wrote:
On 02/05/2014 11:20 AM, Daniel Tryba wrote:
Off to figure out why uac_test incorrectly flags the onhold process as needing the nat helper...
Well, nat_uac_test is pretty straightforward, it does what the flags tell it to do: http://kamailio.org/docs/modules/stable/modules/nathelper.html#idp1655008
nat_uac_test("18") so checks 2 and 16 are active: 2 - the "received" test is used: address in Via is compared against source IP address of signaling 16 - test if the source port is different from the port in Via
U 2014/02/05 13:19:07.820051 109.235.32.40:5060 -> 109.235.36.148:5060 SIP/2.0 200 OK. Via: SIP/2.0/UDP 109.235.36.148;rport=5060;branch=z9hG4bK6d5.b42bb34512cf1a9aca30c530c393effc.1;i=1. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-1eb98d43. Contact: sip:172.19.162.1;line=pcs- mp4KWAydWGy3xGygxG5yxRy6uAXsEOdsE1d3xGmwERypxGcSm8HomgIbmPMl9DQK.
is not natted:
T 2014/02/05 13:19:07.835707 109.235.36.148:5060 -> 109.235.34.226:5074 [AP] SIP/2.0 200 OK. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-1eb98d43. Contact: sip:172.19.162.1;line=pcs- mp4KWAydWGy3xGygxG5yxRy6uAXsEOdsE1d3xGmwERypxGcSm8HomgIbmPMl9DQK.
But this one triggers the nat_uac_test("18") somewhere:
U 2014/02/05 13:19:32.889512 109.235.32.40:5060 -> 109.235.36.148:5060 SIP/2.0 200 OK. Via: SIP/2.0/UDP 109.235.36.148;rport=5060;branch=z9hG4bK2d2f.4ee703b7d124f96de7b6b643ae82b6af.0;i=1. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-63ad12f5. Contact: "Daniel" sip:172.19.162.1;line=pcs- mp4KWiTsxRMKxAnsWGZpxry3xGnoxAxtuAxSuA7KEsktxGZKWgQfZD6smqlf9Gttzjy*.
becomes:
T 2014/02/05 13:19:32.890401 109.235.36.148:5060 -> 109.235.34.226:5074 [AP] SIP/2.0 200 OK. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-63ad12f5. Contact: "Daniel" sip:172.19.162.1;alias=109.235.32.40~5060~1;line=pcs- mp4KWiTsxRMKxAnsWGZpxry3xGnoxAxtuAxSuA7KEsktxGZKWgQfZD6smqlf9Gttzjy*.
From here the contact sent back to 109.235.32.40 contains alias=109.235.32.40~5060~1 so the requests will not be relayed to the actual endpoint:
T 2014/02/05 13:19:36.104652 109.235.34.226:5074 -> 109.235.36.148:5060 [A] INVITE sip:172.19.162.1;alias=109.235.32.40~5060~1;line=pcs- mp4KWiTsxRMKxAnsWGZpxry3xGn6smqlf9Gttzjy* SIP/2.0. Via: SIP/2.0/TCP 10.0.3.175:5074;branch=z9hG4bK-6ef0f7c0. Contact: "klant1" sip:klant1@10.0.3.175:5074;transport=tcp.
U 2014/02/05 13:19:36.108198 109.235.36.148:5060 -> 109.235.32.40:5060 INVITE sip:172.19.162.1;alias=109.235.32.40~5060~1;line=pcs- mp4KWiTsxRMKxAnsWGZpxry3xGn6smqlf9Gttzjy* SIP/2.0. Via: SIP/2.0/UDP 109.235.36.148;branch=z9hG4bKfc2f.a855b8f452b3127d9384838fd250961b.0;i=1. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-6ef0f7c0. Contact: "klant1" sip:klant1@10.0.3.175:5074;alias=109.235.34.226~5074~2;transport=tcp.
U 2014/02/05 13:19:36.110380 109.235.32.40:5060 -> 109.235.36.148:5060 SIP/2.0 100 trying -- your call is important to us. Via: SIP/2.0/UDP 109.235.36.148;branch=z9hG4bKfc2f.a855b8f452b3127d9384838fd250961b.0;i=1;rport=5060. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-6ef0f7c0.
U 2014/02/05 13:19:36.112998 109.235.32.40:5060 -> 109.235.36.148:5060 SIP/2.0 478 Unresolvable destination (478/SL). Via: SIP/2.0/UDP 109.235.36.148;branch=z9hG4bKfc2f.a855b8f452b3127d9384838fd250961b.0;i=1;rport=5060. Via: SIP/2.0/TCP 10.0.3.175:5074;rport=5074;received=109.235.34.226;branch=z9hG4bK-6ef0f7c0.
The only difference between requests/responses to onhold from A is the first is in a call from B to A. The second one is A to B.
What I do is skip nat_uac_test for the requests and responses coming from other proxies' IPs..
That is a solution but breaks the simplicity of the current (public) platform. Thanks for listening :)
On 05.02.2014 11:20, Daniel Tryba wrote:
The problem I have with add_contact_alias/handle_ruri_alias is that any kamailio in the path will parse these hints whether or not it is actually ment for that kamailio.
handle_ruri_alias should only be used by the last proxy in the chain, thus by the proxy which does forwarding based on the RURI, not on Router headers. This is actually what the default config does:
# URI update for dialog requests 802 route[DLGURI] { 803 #!ifdef WITH_NAT 804 if(!isdsturiset()) { 805 handle_ruri_alias(); 806 } 807 #!endif 808 return; 809 }
loose_route() will no set the dest-uri if it is the last proxy in the chain.
If you do not use record-routing, but some static routing, then you have to implement a different logic.
btw: unless you need to save bandwith on media relays you can skip the uac_nat_tests and always* add_contact_alias()
*of course always only on the first proxy which receives the request (request or response). With requests it is easy: There must be only 1 Via header. For responses it is more difficult - thus you need some manual logic, for example: if you send to an external domain, than the external domain must do the NAT traversal, if you send the request within you local domain, then the proxy should have proper knowledge if the request is sent to a SIP client, or some other proxy.
regards Klaus