SER is a stateless and/or stateless proxy.  SER by itself it not very useful
but SER teamed with Asterisk is how you make Asterisk scale.  SER normally
has nothing to do with the RTP stream.  Remember in the SIP world there are
really 2 parts, 1 is the SIP messages and 2 is the RTP "voice" stream.  The
SIP messages tell the 2 voice gateways (an ATA and a TNT for example) what
codec, IP, port, etc. to pass the "voice" traffic on.

SER can be setup quite easily (after you get used to its config file) to
handle simple STATELESS SIP message proxying.  Asterisk is a stateful proxy
and is fully aware of the state of the call.  Asterisk is also considered to
be a feature server, IVR, VM, etc. server.  But what Asterisk is most
certainly not is a stateless proxy server.  In the IP world you can relate
the job of a stateless proxy server to a IP router.  It knows what's
attached to it and what path to send it.  It has no idea what is in what it
is sending but it knows how to get it there.

At first this makes SER look quite inferior to Asterisk, but in reality they
are very complimentary.

So below is some of my ser.cfg file that will give you an idea of how to
make it work.  I originally wasn't going to disclose this but I've gotten
about 100 emails on how to do this so I figure since the mailing lists
helped me out when I first got started I might as well return the favor.
IP's and stuff have been changed so substitute with your own.  Also, I do a
lot of DB table combining to make life easier to SER and Asterisk share the
same auth tables.  If you want them I can do a dump of the struct of my
whole Asterisk DB.  Keep in mind its built for working with the res_data
patch and SER.  Plain old Asterisk wont do any of this without the patch.
Also, keep in mind I don't use the standard paths for install so my config
points to non-standard places.  I also took out the SER register replication
stuff because it made it way to confusing for your first time looking at a
live config file.

AND, one final note about NAT.  SER handles NAT for the SIP messages but
Asterisk handles NAT for the RTP packets.  It's a very odd setup but it will
eliminate a point of failure if you tried to have SER run its mediaproxy or
RTP portion of its nathelper module.  After all Asterisk insists on having
the RTP stream go through it anyway. 

I have no idea what res_config is but res_data does do it in real time.


Michael Shuler


debug=3         # debug level (cmd line: -dddddddddd)
log_stderror=no # (cmd line: -E)

# Uncomment these lines to enter debugging mode 
# debug=7
# fork=no
# log_stderror=yes




check_via=no    # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)

# ------------------ module loading ----------------------------------

# Uncomment this if you want to use SQL database
loadmodule "/software/ser/ser/lib/ser/modules/"

loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"

# Uncomment this if you want digest authentication
# must be loaded !
loadmodule "/software/ser/ser/lib/ser/modules/"
loadmodule "/software/ser/ser/lib/ser/modules/"

# ----------------- setting module-specific parameters ---------------

# -- usrloc params --
# Flush every 60 sec
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "db_url",
"sql://Asterisk:[EMAIL PROTECTED]/Asterisk")

# -- auth params --
modparam("auth_db", "db_url",
"sql://Asterisk:[EMAIL PROTECTED]/Asterisk")
modparam("auth_db", "user_column", "username")
modparam("auth_db", "domain_column", "domain")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")

# -- replication auth param --
modparam("auth", "secret", "mysecret")

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# -------------------------  request routing logic -------------------

# main routing logic


        # initial sanity checks -- messages with
        # max_forwards==0, or excessively long requests
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
        if ( msg:len > max_len ) {
                sl_send_reply("513", "Message too big");

        # if(method != "REGISTER")
        # {
        #       xlog("L_INFO", "Got a %rm (URI = %ru) from %is");
        # };

        # By default we are already responding to the learned IP:PORT that
the message came from.  
        # This will properly fix the contact header.  Asterisk will fix the
SDP (actually it learns it).


        # if the request is for other domain use UsrLoc
        # (in case, it does not work, use the following command
        # with proper names and addresses in it)
        if(uri == myself || src_ip ==
                if(method == "REGISTER") 
                        # Make sure they are a valid user on our proxy
                        if(!www_authorize("", "sipfriends")) 
                                # xlog("L_INFO", "Req Auth For %ct, URI =
                                www_challenge("", "1");

                        # xlog("L_INFO", "Registered Contact %ct,  URI =



        # we record-route all messages -- to make sure that
        # subsequent messages will go through our proxy; that's
        # particularly good if upstream and downstream entities
        # use different transport protocol
          # This will make the return path the VIRTUAL IP on a L4 switch
instead of our REAL IP
        # record_route_preset("111.222.333.444:5060");

        # loose-route processing
                xlog("L_INFO", "loose_route(): Looking up %rm URI %ru from
                xlog("L_INFO", "loose_route(): t_relay() %rm to URI %ru");


        # We only need to do load balancing on the INVITE.  
        # After the dest IP has been put in the message the servers will
follow it on their own.
        if(method == "INVITE")

                # If it came from Asterisk send it to a TNT box for final
routing if it can't be looked up
                # As of now its ast0 and ast1 which are and
333.333.333.333 which fall within this subnet
                if(src_ip == || src_ip == 333.333.333.333)
                        xlog("L_INFO", "%rm came from Asterisk server %is,
URI = %ru");
                        # native SIP destinations are handled using our
                                # Found a match, this is going to a VoIP
                                xlog("L_INFO", "Sending %rm (URI = %ru) to
Contact (%ct)");
                                # Lookup failed, assume that this is a phone
number URL until I setup pattern matching
                                # Send to the TNT
                                xlog("L_INFO", "Sending URI (%ru) to TNT");


                # NOTE: I could have combine the following "else if" and
"else" but I wanted to seperate them for debug purposes
                # If it came from a TNT send it to an Asterisk box for final
                # As of now TNT is 444.444.444.444 which falls within this
                else if(src_ip == 444.444.444.444)
                        xlog("L_INFO", "%rm came from TNT (%is), sending to
Asterisk (URI = %ru)");
                                # I cheated here because I made a DNS round robing with a 5 sec experation.  It's not a
load checking load balancer but its REALLY close.    
                # Assume it came from one of our VoIP phones, all routing is
done by Asterisk
                        xlog("L_INFO", "%rm came from a VoIP phone (%is),
attempting to authorize %fu");

                        # Make sure they are a valid user on our proxy
                        if (!www_authorize("", "sipfriends"))
                                www_challenge("", "0");
                                xlog("L_INFO", "Failed to authorize %fu

                        # Found a match, this is going to a VoIP phone
                        xlog("L_INFO", "Auth OK, sending URI %ru to Asterisk
for routing");

                xlog("L_INFO", "INVITE New URI = %ru, t_relay()ing now");
                # forward(uri:host, uri:port);


        # forward to current uri now; use stateful forwarding; that
        # works reliably even if we forward from TCP to UDP
        xlog("L_INFO", "Default t_relay() (method = %rm, URI = %ru, >From =
                xlog("L_INFO", "Failed sending requesting %rm URI (%ru)");

> -----Original Message-----
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Tracy R Reed
> Sent: Thursday, November 18, 2004 7:08 PM
> To: Asterisk Users Mailing List - Non-Commercial Discussion
> Subject: Re: [Asterisk-Users] Speaking of DS3s....
> On Thu, Nov 18, 2004 at 04:30:24PM -0600, Michael Shuler spake thusly:
> > the VoIP devices and to the media gateways.  The SER 
> machines don't know
> > what to do with a call they only know to hand it over to 
> Asterisk for
> > routing/CLASS features or whatever you want the call to do. 
>  You then have a
> This is exactly what I am trying to figure out how to set up. 
> I am still a
> bit confused by how the SER box can "hand it over" to the 
> Asterisk box. I
> am pretty fluent in Asterisk by now and have written various code for
> Asterisk so I would like to do my routing and accounting in 
> Asterisk, and
> not SER which I understand requires coding in C to SER's API 
> (correct me
> if I'm wrong here). Since SER is a proxy it does not handle the rtp
> stream, right? But someone recently told me that SER 
> implements comfort
> noise and other nice SIP things that asterisk does not and 
> that you really
> don't want all of the media stream going through asterisk 
> because it won't
> scale. Or maybe the media stream does have to go through 
> asterisk but SER
> just balances the load but that doesn't jive with what I was 
> told about
> comfort noise etc. We also are using asterisk to talk to 
> TNT's and that
> part is working really slick. We have a few DS-3's and I 
> intend to have
> asterisk least cost route traffic to the appropriate TNT etc.
> > Asterisk as media gateways in our setup we use the Lucent 
> TNTs but it
> > accomplishes the same thing but on a much larger scale.  As 
> far as sharing
> > the common configs we use 
> to read all
> > of our configs (sip.conf, extensions.conf, etc.) live from 
> a MySQL database.
> > Just apply the patch and go.
> Hmm...what's the difference between res_config and res_data? They both
> seem to put all of the asterisk configs in a database. Does res_config
> just read from the db once and res_data reads in real time?
> -- 
> Tracy Reed 
> This message is cryptographically signed for your protection.
> Info:

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:

Reply via email to