Monday 2 June 2014

Asterisk and Opensips Integration (source : VOIP-INFO)

By vm  |  07:21 2 comments

[SIP_Client]----->[OpenSER]------>[Asterisk]----->[PSTN]
Let's talk about something interesting. I have been working on IP telephony systems for the last year. I have implemented IP PBX solutions for many organizations. I have good expertise on telephony and Asterisk systems. Basically Asterisk is not a SIP server but it can support the SIP protocol. That's why Asterisk can handle only 200 to 300 SIP device registrations, and that on large productions it doesn't to work great. Finally, I have decided to implement Asterisk on a large production with the help of OpenSER. OpenSER is pure SIP server and a lightweight binary, so it can handle 10,000 call per second. I am using OpenSER in front of Asterisk. OpenSER handles my call SIP registration requests, and Asterisk handles my PSTN functionality because OpenSER doesn't support telephony hardware. Asterisk provides media application services like VoiceMail, Conference, IVR, and PSTN functions.

I am going to show you how to integrate this combined system: OpenSER and Asterisk.

My configuration example.

 $cat /usr/local/etc/openser/openser.cfg
 
 debug=6
 fork=yes
 log_stderror=yes
 port=5060
 children=4
 fifo="/tmp/ser_fifo"
 loadmodule "/usr/local/lib/ser/modules/sl.so"
 loadmodule "/usr/local/lib/ser/modules/tm.so"
 loadmodule "/usr/local/lib/ser/modules/rr.so"
 loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
 loadmodule "/usr/local/lib/ser/modules/usrloc.so"
 loadmodule "/usr/local/lib/ser/modules/registrar.so"
 loadmodule "/usr/local/lib/ser/modules/textops.so"
 modparam("usrloc", "db_mode", 0)
 modparam("rr", "enable_full_lr", 1)
 route{
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                break;
        };
        if (msg:len >=  2048 ) {
                sl_send_reply("513", "Message too big");
                break;
        };
 
        if (!method=="REGISTER") record_route();
        if (loose_route()) {
                append_hf("P-hint: rr-enforced\r\n");
                route(1);
                break;
        };
        if (!uri==myself) {
                append_hf("P-hint: outbound\r\n");
                route(1);
                break;
        };
        if (uri==myself) {
                if (method=="REGISTER") {
                        save("location");
                        break;
                };
                if(method=="INVITE") {
                        if (uri =~ "sip:5[0-9]@*"){
                        route(3);
                        break;
                }
                }
                lookup("aliases");
                if (!uri==myself) {
                        append_hf("P-hint: outbound alias\r\n");
                        route(1);
                        break;
                };
                if (!lookup("location")) {
                        sl_send_reply("404", "Not Found");
                        break;
                };
        };
        append_hf("P-hint: usrloc applied\r\n");
        route(1);
 }
 route[1]
 {
        if (!t_relay()) {
                sl_reply_error();
        };
 }
 route[3]{
 
   if (uri =~ "sip:5[0-9]@*"){
        log(1, "Forwarding to Asterisk \n");
        rewritehostport("192.168.104.20:5060");
        route(1);
        break;
    }

Asterisk configuration for openser

sip.conf


[203.124.16.109]
 type=friend ; We allow incoming and outgoing calls. Use peer if you are only doing MWI
 context=outgoing ; This is the context incoming calls land in
 host=<openser_server_ip> ; This is the hostname or IP address of your SER server
 fromdomain=<openser_server_ip> ; This is your SER_DOMAIN
 insecure=very ; This allows incoming calls from the phones routing through ser to be passed into asterisk
 mailbox=user@context

extention.conf

 [globals]
 SERADDRESS=xxx.xxx.xxx.xxx

 [outgoing]
 exten => _XXXX,1,Dial(SIP/${EXTEN}@${SERADDRESS},20,r)
 exten => _0XXXXXXXXXX,1,Dial(Zap/g1/${EXTEN},60) 

Author: vm

Hello, I am Author, decode to know more: In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In commodo magna nisl, ac porta turpis blandit quis. Lorem ipsum dolor sit amet.

2 comments:

  1. Hi. will u be able to update it to latest Asterisk, Opensip and Gui, please/

    ReplyDelete
  2. update to newer versions please Thanks

    ReplyDelete

E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

© 2014 VOIP4Learn. WP themonic converted by Bloggertheme9. Powered by Blogger.
TOP