1 - Take a look at the Kamailio transformations and psuedo-variable page.
     change the $td to the IP of the MSC; modify the $ru as $rU + "@172.22.12.100:5060" where this is IP of MSC side.
2 - Wireshark guys could've said it SIP-3 - point is it doesnt matter at this point since you know your MSC is replying back and talking to you.
 


On Tue, Aug 11, 2015 at 1:16 PM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:
Yes, You are right and done the changes as you suggested.

Kamailio server is forwarding the call to MSC. But two issues are there.
1 .In the INVITE packet which is being sent from kamailio server to MSC, it is coming Request-Line: INVITE sip:0730092190@172.22.14.12 
   That is my kamailio server IP and it should be MSC IP(172.28.0.68) and as of now call is failing as MSC is sending 404 error.
2. Other issue is , in the pcap file it is coming SIP/SDP as protocol and it is not coming SIP-I.

Please find the latest attached pcap.

Regards,
Sandeep


Warm Regards,
Sandeep Chakravarthi.

On Tue, Aug 11, 2015 at 9:47 PM, SamyGo <govoiper@gmail.com> wrote:
Thats because your configuration file is not sending packet out (RELAY) to MSC instead it is only doing a Loadbalancer / destination lookup in TOASTERISK route and comes out of it, processes the following routes in order
  route(SIPOUT);
  route(PRESENCE);
  route(REGISTRAR);
  route(PSTN);
  route(LOCATION);

Where finally in LOCATION route it tries to find the destination user 0730092190 online locally on Kamailio, which it can't find and says 404 Not Found.

You should modify your TOASTERISK route as follow:

route[TOASTERISK] {
if(ds_is_from_list("2")) {
#Call from Telco Should goto Asterisk pool in Loadbalanced mode
                 if(!ds_select_dst("1", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
                route(RELAY);
}if(ds_is_from_list("1")) {
#Call from Asterisk servers pool, send it to telco using LoadBalancer
                if(!ds_select_dst("2", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
                route(RELAY);
 }

}


This will immediately route the packet out towards the new $du after the loadbalancer function ds_select_dst(...)


On Tue, Aug 11, 2015 at 10:48 AM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:
Hi,
Kamailio  is sending 404 Response and its not MSC.
If you see the pcap file , Kamailio has to forward the SIP invite packet to MSC which it got from Asterisk server. But it is not happening.
I am attaching the pcap one more time for your reference.

In my pcap, below are the server details

172.22.14.12 - Kamailio server
172.22.14.17 - Asterisk server
172.22.0.68 - MSC


Regards,
Sandeep

Warm Regards,
Sandeep Chakravarthi.

On Tue, Aug 11, 2015 at 7:10 PM, SamyGo <govoiper@gmail.com> wrote:
Hi Sandeep,
what is the problem here ? Kamailio just sends a 404 on its own or is really sending calls to MSC and MSC is replying with 404 ?


On Mon, Aug 10, 2015 at 12:33 PM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:
Hi ,
Sorry for the delayed reply.
I have configured my Asterisk and kamailio server, but when i initiate one outbound call from my asterisk server to kamailio server, kamailio server is initiating the call to MSC.
Please find the attached pcap details for your reference.
Below is my kamailio debug log and kamailio.cfg file.
Please check the pcap and below cfg file and log file and let me know whether to change anything in cfg file or not.

++++++++++++++++++++++++++++++++++++++++++++++++


request_route {

        # per request initial checks
        route(REQINIT);

        # NAT detection
        route(NATDETECT);

        # CANCEL processing
        if (is_method("CANCEL"))
        {
                if (t_check_trans()) {
                        route(RELAY);
                }
                exit;
        }

        # handle requests within SIP dialogs
        route(WITHINDLG);

        ### only initial requests (no To tag)

        t_check_trans();

        # authentication
        route(AUTH);


        # record routing for dialog forming requests (in case they are routed)
        # - remove preloaded route headers
        remove_hf("Route");
        if (is_method("INVITE|SUBSCRIBE"))
                record_route();

        # account only INVITEs
        if (is_method("INVITE"))
        {
                setflag(FLT_ACC); # do accounting
        }
        route(TOASTERISK);

        # dispatch requests to foreign domains
        route(SIPOUT);

        ### requests for my local domains

        # handle presence related requests
        route(PRESENCE);

        # handle registrations
        route(REGISTRAR);

        if ($rU==$null)
        {
                # request with no Username in RURI
                sl_send_reply("484","Address Incomplete");
                exit;
        }

        # dispatch destinations to PSTN
        route(PSTN);
# user location service
        route(LOCATION);
}

route[TOASTERISK] {
if(ds_is_from_list("2")) {
#Call from Telco Should goto Asterisk pool in Loadbalanced mode
                 if(!ds_select_dst("1", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
}if(ds_is_from_list("1")) {
#Call from Asterisk servers pool, send it to telco using LoadBalancer
                if(!ds_select_dst("2", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
 }

}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Debug log

 8(1186) DEBUG: <core> [parser/msg_parser.c:623]: parse_msg(): SIP Request:
 8(1186) DEBUG: <core> [parser/msg_parser.c:625]: parse_msg():  method:  <INVITE>
 8(1186) DEBUG: <core> [parser/msg_parser.c:627]: parse_msg():  uri:     <sip:0730092190@172.22.14.12>
 8(1186) DEBUG: <core> [parser/msg_parser.c:629]: parse_msg():  version: <SIP/2.0>
 8(1186) DEBUG: <core> [parser/parse_via.c:1284]: parse_via_param(): Found param type 232, <branch> = <z9hG4bK3c5fb091>; state=16
 8(1186) DEBUG: <core> [parser/parse_via.c:2672]: parse_via(): end of header reached, state=5
 8(1186) DEBUG: <core> [parser/msg_parser.c:513]: parse_headers(): parse_headers: Via found, flags=2
 8(1186) DEBUG: <core> [parser/msg_parser.c:515]: parse_headers(): parse_headers: this is the first via
 8(1186) DEBUG: <core> [receive.c:152]: receive_msg(): After parse_msg...
 8(1186) DEBUG: <core> [receive.c:193]: receive_msg(): preparing to run routing scripts...
 8(1186) DEBUG: maxfwd [mf_funcs.c:85]: is_maxfwd_present(): value = 70
 8(1186) DEBUG: <core> [parser/parse_addr_spec.c:898]: parse_addr_spec(): end of header reached, state=10
 8(1186) DEBUG: <core> [parser/msg_parser.c:190]: get_hdr_field(): DEBUG: get_hdr_field: <To> [31]; uri=[sip:0730092190@172.22.14.12]
 8(1186) DEBUG: <core> [parser/msg_parser.c:192]: get_hdr_field(): DEBUG: to body [<sip:0730092190@172.22.14.12>
]
 8(1186) DEBUG: <core> [parser/msg_parser.c:170]: get_hdr_field(): get_hdr_field: cseq <CSeq>: <102> <INVITE>
 8(1186) DEBUG: <core> [parser/msg_parser.c:204]: get_hdr_field(): DEBUG: get_hdr_body : content_length=327
 8(1186) DEBUG: <core> [parser/msg_parser.c:106]: get_hdr_field(): found end of header
 8(1186) DEBUG: <core> [parser/parse_addr_spec.c:176]: parse_to_param(): DEBUG: add_param: tag=as4decf975
 8(1186) DEBUG: <core> [parser/parse_addr_spec.c:898]: parse_addr_spec(): end of header reached, state=29
 8(1186) DEBUG: sanity [mod_sanity.c:255]: w_sanity_check(): sanity checks result: 1
 8(1186) DEBUG: siputils [checks.c:103]: has_totag(): no totag
 8(1186) DEBUG: tm [t_lookup.c:1072]: t_check_msg(): DEBUG: t_check_msg: msg id=2 global id=1 T start=0xffffffff
 8(1186) DEBUG: tm [t_lookup.c:527]: t_lookup_request(): t_lookup_request: start searching: hash=3888, isACK=0
 8(1186) DEBUG: tm [t_lookup.c:485]: matching_3261(): DEBUG: RFC3261 transaction matching failed
 8(1186) DEBUG: tm [t_lookup.c:709]: t_lookup_request(): DEBUG: t_lookup_request: no transaction found
 8(1186) DEBUG: tm [t_lookup.c:1141]: t_check_msg(): DEBUG: t_check_msg: msg id=2 global id=2 T end=(nil)
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.17] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.17] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.17] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.17] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [forward.c:450]: check_self(): check_self: host != me
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.17] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.17] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.17] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.17] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [forward.c:450]: check_self(): check_self: host != me
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.12] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.12] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: dispatcher [dispatch.c:1629]: ds_select_dst(): set [2]
 8(1186) DEBUG: dispatcher [dispatch.c:1731]: ds_select_dst(): alg hash [0]
 8(1186) DEBUG: dispatcher [dispatch.c:1772]: ds_select_dst(): selected [4-2/0] <sip:172.28.0.68:5060>
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==9 && [172.22.14.12] == [127.0.0.1]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: <core> [socket_info.c:583]: grep_sock_info(): grep_sock_info - checking if host==us: 12==12 && [172.22.14.12] == [172.22.14.12]
 8(1186) DEBUG: <core> [socket_info.c:587]: grep_sock_info(): grep_sock_info - checking if port 5060 (advertise 0) matches port 5060
 8(1186) DEBUG: registrar [lookup.c:158]: lookup(): '0730092190' Not found in usrloc
 8(1186) DEBUG: tm [t_lookup.c:1373]: t_newtran(): DEBUG: t_newtran: msg id=2 , global msg id=2 , T on entrance=(nil)
 8(1186) DEBUG: tm [t_lookup.c:527]: t_lookup_request(): t_lookup_request: start searching: hash=3888, isACK=0
 8(1186) DEBUG: tm [t_lookup.c:485]: matching_3261(): DEBUG: RFC3261 transaction matching failed
 8(1186) DEBUG: tm [t_lookup.c:709]: t_lookup_request(): DEBUG: t_lookup_request: no transaction found
 8(1186) DEBUG: tm [t_hooks.c:380]: run_reqin_callbacks_internal(): DBG: trans=0xb5d3f20c, callback type 1, id 0 entered
 8(1186) DEBUG: <core> [md5utils.c:67]: MD5StringArray(): DEBUG: MD5 calculated: 3d26b7732e22874c5837c971c8ec76cd
 8(1186) DEBUG: tm [t_lookup.c:1072]: t_check_msg(): DEBUG: t_check_msg: msg id=2 global id=2 T start=0xb5d3f20c
 8(1186) DEBUG: tm [t_lookup.c:1144]: t_check_msg(): DEBUG: t_check_msg: T already found!
 8(1186) DEBUG: <core> [msg_translator.c:205]: check_via_address(): check_via_address(172.22.14.17, 172.22.14.17, 0)
 8(1186) DEBUG: <core> [mem/shm_mem.c:111]: _shm_resize(): WARNING:vqm_resize: resize(0) called
 8(1186) DEBUG: tm [t_reply.c:1653]: cleanup_uac_timers(): DEBUG: cleanup_uac_timers: RETR/FR timers reset
 8(1186) DEBUG: tm [t_hooks.c:288]: run_trans_callbacks_internal(): DBG: trans=0xb5d3f20c, callback type 512, id 0 entered
 8(1186) DEBUG: acc [acc_logic.c:571]: tmcb_func(): acc callback called for t(0xb5d3f20c) event type 512, reply code 404
 8(1186) DEBUG: tm [t_reply.c:728]: _reply_light(): DEBUG: reply sent out. buf=0xb7bb8030: SIP/2.0 404 Not Foun..., shmem=0xb5d40cdc: SIP/2.0 404 Not Foun
 8(1186) DEBUG: tm [t_reply.c:738]: _reply_light(): DEBUG: _reply_light: finished
 8(1186) DEBUG: sl [sl.c:288]: send_reply(): reply in stateful mode (tm)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++








Warm Regards,
Sandeep Chakravarthi.

On Thu, Jul 30, 2015 at 6:35 PM, SamyGo <govoiper@gmail.com> wrote:
Below is output from the dispatcher table, Set-2 is a pool of asterisk servers to be Load balanced, and Set-1 is the Telco IP.

KAMSBC01:~# kamctl dispatcher dump
SET_NO:: 2
SET:: 2 
        URI:: sip:192.168.0.150:5050 flags=AP priority=1 attrs=
        URI:: sip:192.168.0.151:5060 flags=AP priority=1 attrs=
        URI:: sip:192.168.0.152:5070 flags=AP priority=1 attrs=
        URI:: sip:192.168.0.153:5080 flags=AP priority=1 attrs=
        URI:: sip:192.168.0.155:5090 flags=AP priority=1 attrs=
SET:: 1
        URI:: sip:124.311.201.600:5060 flags=AP priority=1 attrs=

Now in my kamailio.cfg in relevant route

if(ds_is_from_list("1")) {
#Call from Telco Should goto Asterisk pool in Loadbalanced mode
                 if(!ds_select_dst("2", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
} else if (ds_is_from_list("2")) {
#Call from Asterisk servers pool, send it to telco using LoadBalancer
                if(!ds_select_dst("1", "4")) {
                        sl_send_reply("500", "Service Unavailable");
                        xlog("L_INFO","[$fU@$si:$sp]{$rm} No destinations available for $rd \n");
                        exit;
                }
}


So if your Telco has more than 1 IP you can do Load balancing.

I hope this solves your problem.


Best Regards,
Sammy



On Thu, Jul 30, 2015 at 3:17 AM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:
Hi,

Can you share the sample code to differentiate the both telco IP and our server IP?

.



Warm Regards,
Sandeep Chakravarthi.

On Tue, Jul 14, 2015 at 10:55 PM, SamyGo <govoiper@gmail.com> wrote:
Sure but if you look into the dispatcher module there is a field called 'setid' or groupid. Use it wisely to differentiate between the Load Balanced asterisk pool and the Telco IP. 
The dispatcher module is exactly what you should use. You can find out if incoming source IP belongs to a particular set in dispatcher table thus you can tell if call is coming from Telco or from your Asterisks.
You can select the dispatcher set for load balancing but if we only have one IP in there then it gets all the load.

BR,
Sammy


On Tue, Jul 14, 2015 at 1:21 PM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:
Hi,
Thanks for the immediate reply.

You are right ,using the dispatcher module , i am able to send the OPTIONS packet to MSC Telco.

But as i describer in  my earlier mail, i am using the same dispatcher module to establish the sip trunk  between my My Kamailio server and my Asterisk server.

There is a table in the database with the name dispatcher.
Now, in that table i have 2 records
one is my Telco SIP IP and the other is Asterisk PBX IP.

But as per my understanding from the google, dispatcher module is used for load balancing between the servers

Telco SIP server will be sending the calls to Kamailio and Kamailio has to distribute completely to Asterisk server instead of distributing the calls between Telco SIP IP and Asterisk.


Please help with it.




Warm Regards,
Sandeep Chakravarthi.

On Tue, Jul 14, 2015 at 10:28 PM, SamyGo <govoiper@gmail.com> wrote:
Hi,
You're right about using IP Auth in Kamailio. You'll need to use the permissions module. However I believe permissions module wont send the OPTIONS to the MSC SIP Server. For this you may alternatively use the "dispatcher" module.


Follow the tag WITH_IPAUTH and I'm sure you'll be able to implement it easily.

BR,
Sammy

On Tue, Jul 14, 2015 at 12:51 PM, Sandeep Chakravarthi <ivschakravarthi@gmail.com> wrote:

Hi,
We have a requirement with one of our telco
We are using asterisk in our servers and we are planning to implement SIP-I protocol and we choosed kamailio for it.

In Kamailio website, i came to know that kamailio will be supporting both SIP-I and SIP-T protocols

Below is what we need and pls confirm whether it is possible or not?

Asterisk PBX <-------> Kamailio <--------> Telco MSC


Telco will be forwarding the calls to kamailio on sip-i protocol and kamailio server has to forward the calls to our Asterisk server by converting sip-i to standard sip protocol

Similiarly Asterisk will be initiating sip call to kamailio server and kamailio server should convert it into SIP-I and should forward the call to Telco MSC


1.  I am able to establish the SIP trunk [sending OPTIONS from asterisk and kamailio acknowledges with 200 OK] between Asterisk and Kamailio using dispatcher module in kamailio and sip.conf in asterisk.

How to establish the SIP trunk between kamailio and telco MSC?
[Generally MSC will act as SIP server and kamalio should send OPTIONS packet and MSC will acknowledges with 200 OK]


My telco MSC has only provided me the MSC SIP IP and there were no username/passwords provided.
Means i need to use IP based authentication for the SIP Trunk establishment.

In Kamailio how to achieve it?

Please help and any suggestions/feedback will be highly appreciated and thankful


Regards,
Sandeep

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users