<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hello,<br>
    <br>
    Yes, you could do that. Just use the drouting's is_from_gw()
    function ( docs at [1] ) to detect direction. If is_from_gw()
    returns true, apply your load-balancer logic, otherwise apply the DR
    logic.<br>
    <br>
    [1]
    <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/1.8.x/drouting.html#id293884">http://www.opensips.org/html/docs/modules/1.8.x/drouting.html#id293884</a><br>
    <br>
    Regards,<br>
    <pre class="moz-signature" cols="72">Vlad Paiu
OpenSIPS Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a> </pre>
    <br>
    On 03/29/2012 11:53 PM, Ali Pey wrote:
    <blockquote
cite="mid:CA+q4kR+9yebBu2km6dadUoHSFFfv8yEhY4n-oahy9PW9_n9oQg@mail.gmail.com"
      type="cite">Is it possible to use the load balancer module on one
      direction- from carriers to media gateways and the DR module on
      the other direction- from media gateways to carriers.
      <div><br>
      </div>
      <div>Regards,<br>
        <div>Ali</div>
        <div>
          <br>
          <br>
          <div class="gmail_quote">On Thu, Mar 29, 2012 at 4:28 AM, Vlad
            Paiu <span dir="ltr">&lt;<a moz-do-not-send="true"
                href="mailto:vladpaiu@opensips.org">vladpaiu@opensips.org</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
              0.8ex; border-left: 1px solid rgb(204, 204, 204);
              padding-left: 1ex;">
              <div bgcolor="#ffffff" text="#000000"> Hello,<br>
                <br>
                The latest dynamic routing improvements allow to
                distribute the load on multiple gw's within a carrier,
                based on weights.<br>
                So for example you can define a new carrier, c1, that
                has two gateways, g1 and g2, like this<br>
                &nbsp;&nbsp;&nbsp; c1 = g1=50,g2=50<tt><br>
                </tt>and then, for a specific prefix rule, set c1 in the
                gw list and the load will be distributed evenly between
                the two gateways.<br>
                <br>
                You might want to read again Bogdan's initial email, in
                order to get a better grasp of the newly available
                features.<br>
                <br>
                <br>
                Regards,<tt><br>
                </tt>
                <pre cols="72">Vlad Paiu
OpenSIPS Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a> </pre>
                <div>
                  <div class="h5"> <br>
                    On 03/29/2012 10:26 AM, [Digital^Dude] &reg; wrote:
                    <blockquote type="cite"><font face="trebuchet
                        ms,sans-serif">If I set DR to route based on all
                        dialed prefixes, can I achieve load balanced
                        setup with failover? If yes, how do I configure
                        them? I have been able to configure them
                        individually, but how to made these two modules
                        work together?<br>
                      </font><br>
                      <div class="gmail_quote">On Wed, Mar 28, 2012 at
                        2:31 PM, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a
                            moz-do-not-send="true"
                            href="mailto:bogdan@opensips.org"
                            target="_blank">bogdan@opensips.org</a>&gt;</span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:
                          0pt 0pt 0pt 0.8ex; border-left: 1px solid
                          rgb(204, 204, 204); padding-left: 1ex;">
                          <div bgcolor="#ffffff" text="#000000"> Hi Ali,<br>
                            <br>
                            Both modules are routing engines - the DR
                            module routes based on dialled prefix, while
                            the LB routes based on the load of the
                            destinations (active calls).<br>
                            <br>
                            Regards,<br>
                            <font color="#888888"> Bogdan</font>
                            <div>
                              <div><br>
                                <br>
                                On 03/27/2012 07:36 PM, Ali Pey wrote:
                                <blockquote type="cite">
                                  <div><br>
                                  </div>
                                  What are the differences between the
                                  Dynamic Routing and Load-Balancer
                                  Modules?&nbsp;
                                  <div><br>
                                  </div>
                                  <div>They seem very&nbsp;similar&nbsp;except
                                    that we don't have rules in
                                    Load-Balancer Module. Can DR module
                                    be used as a load-balancer? Is it
                                    possible to have the features of
                                    both modules together? A
                                    load-balancer with rules?</div>
                                  <div><br>
                                  </div>
                                  <div><br>
                                  </div>
                                  <div>Regards,</div>
                                  <div>Ali<br>
                                    <div><br>
                                    </div>
                                    <div><br>
                                      <br>
                                      <div class="gmail_quote">On Fri,
                                        Mar 23, 2012 at 9:11 AM,
                                        Bogdan-Andrei Iancu <span
                                          dir="ltr">&lt;<a
                                            moz-do-not-send="true"
                                            href="mailto:bogdan@opensips.org"
                                            target="_blank">bogdan@opensips.org</a>&gt;</span>
                                        wrote:<br>
                                        <blockquote class="gmail_quote"
                                          style="margin: 0pt 0pt 0pt
                                          0.8ex; border-left: 1px solid
                                          rgb(204, 204, 204);
                                          padding-left: 1ex;">
                                          <div bgcolor="#ffffff"
                                            text="#000000"> <tt>Hi all<br>
                                              <br>
                                              In OpenSIPS 1.8.0, the
                                              Dynamic Module comes with
                                              some major changes and
                                              enhancements :<br>
                                              <br>
                                              Carrier concept added<br>
                                              ----------------------<br>
                                              Now you can group the GWs
                                              in carrier, so you can
                                              achieve a better control
                                              over the destinations. A
                                              carrier is a list of gws -
                                              for each carrier, you can
                                              define how the gws should
                                              be sort - based on the
                                              definition order, or based
                                              on weigths . Once again,
                                              this setting is per
                                              carrier. Also you can
                                              enabled / disable carriers
                                              (via MI) during runtime.
                                              The carrier has attached
                                              an attribute string that
                                              will be pushed to script
                                              when a gws from the
                                              carrier will be used.<br>
                                              <br>
                                              When defining a routing
                                              rule, you can define a
                                              list of gws and carriers
                                              to be used (a mixed list).
                                              How the list from the rule
                                              is interpreted (order or
                                              weight), depends on a flag
                                              in do_routing() function.<br>
                                              <br>
                                              Ex:<br>
                                              &nbsp;&nbsp;&nbsp; gateways :&nbsp; g1, g2,
                                              g3, g4, g5<br>
                                              &nbsp;&nbsp;&nbsp; carriers :&nbsp; c1 =
                                              g1=75,g2=25&nbsp; (a premium
                                              carrier), ordering based
                                              on weight<br>
                                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c2 = </tt><tt>g3,g4&nbsp;
                                              (a standard carrier),
                                              ordering based on given
                                              order<br>
                                              &nbsp;&nbsp;&nbsp; rules:&nbsp;&nbsp; prefix=
                                              004021 ; list =
                                              #c1,#c2,g5&nbsp; - first we
                                              will try do distribute
                                              75/25 the traffic <br>
                                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; between
                                              the gws from carrier c1
                                              and if all fail, we will
                                              try gws from carrier c2<br>
                                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                              (according the ordering
                                              defined for c2), and so on<br>
                                              <br>
                                            </tt><tt>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                              prefix= 004072 ; list =
                                              #c2=50,g5=50&nbsp; - all
                                              traffic will be weight
                                              balanced between carrier<br>
                                              &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c2 and
                                              gw g5; of course, if
                                              carrier c2 is to be used,
                                              the corresponding traffic
                                              will<br>
                                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; routed
                                              over the c2 gateways
                                              according to its
                                              definition<br>
                                            </tt><br>
                                            <tt><br>
                                              do_routing() enhancements</tt><tt><br>
                                              --------------------------<br>
                                              The do_routing() function
                                              takes several flags (as
                                              second optional parameter)
                                              to control the matching
                                              and ordering in the rules:<br>
                                            </tt>
                                            <div>
                                              <ul type="circle">
                                                <li><tt><span><i>W</i></span>
                                                    - Instead of using
                                                    the destination
                                                    (from the rule
                                                    definition) in the
                                                    given order, sort
                                                    them based on their
                                                    weight. </tt></li>
                                                <li><tt><span><i>F</i></span>
                                                    - Enable rule
                                                    fallback; normally
                                                    the engine is using
                                                    a single rule for
                                                    routing a call; by
                                                    setting this flag,
                                                    the engine will
                                                    fallback and use
                                                    rules with less
                                                    priority or shorter
                                                    prefix when all the
                                                    destination from the
                                                    current rules
                                                    failed. </tt></li>
                                                <li><tt><span><i>L</i></span>
                                                    - Do strict length
                                                    matching over the
                                                    prefix - actually DR
                                                    engine will do full
                                                    number matching and
                                                    not prefix matching
                                                    anymore. </tt></li>
                                              </ul>
                                            </div>
                                            <tt>Also, the function takes
                                              a new third optional
                                              parameter - a white list
                                              of gateways -&gt; during
                                              the routing, only the
                                              gateways from this list
                                              will be considered valid
                                              (from the gws specified by
                                              the routing rules)<br>
                                            </tt><tt><br>
                                              <br>
                                              Rule fallback<br>
                                              --------------<br>
                                              Before, the dr module was
                                              matching and using a
                                              single rule. Now, via the
                                              F flag, you can instruct
                                              the DR engine to fallback
                                              and use additional rules
                                              that match (with looser
                                              matching) the dialed
                                              prefix - like rules with
                                              same prefix but lower
                                              priority, rules with
                                              shorter prefix.<br>
                                              The fallback is
                                              transparent done, via the
                                              use_next_gw() function.<br>
                                              <br>
                                              Ex:<br>
                                              &nbsp;&nbsp; prefix 004072, prio 10&nbsp;
                                              =&gt; g1,g2<br>
                                            </tt><tt>&nbsp;</tt><tt>&nbsp; prefix
                                              004072, prio&nbsp; 1&nbsp; =&gt; g3<br>
                                            </tt><tt>&nbsp;&nbsp; prefix 0040,&nbsp;&nbsp;
                                              prio&nbsp; 1&nbsp; =&gt; g4,g5<br>
                                              &nbsp;&nbsp;&nbsp; <br>
                                              &nbsp;&nbsp; when dialing
                                              00407221234567 and using
                                              fallback, the gws g1, g2
                                              (first rule), g3 (second
                                              rule) and g4 , g5 (third
                                              rule) will be used.<br>
                                              <br>
                                            </tt><br>
                                            <tt>New routing functions<br>
                                              ----------------------<br>
                                              route_to_gw(gw_id) -
                                              function to trigger the
                                              direct routing to a given
                                              gateway. Attributes and
                                              per-gw preocessing will be
                                              available.<br>
                                              <br>
                                              route_to_carrier(carrier_id)
                                              -f unction to trigger the
                                              direct routing to a given
                                              carrier. In this case the
                                              routing is not done prefix
                                              based, but carrier based
                                              (call will be sent to the
                                              GWs of that carrier, based
                                              on carrier policy)<br>
                                            </tt><tt><br>
                                              <br>
                                              <br>
                                              For more, please see the
                                              online documentation for
                                              the DR module:<br>
                                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <a
                                                moz-do-not-send="true"
                                                href="http://www.opensips.org/html/docs/modules/1.8.x/drouting.html"
                                                target="_blank">www.opensips.org/html/docs/modules/1.8.x/drouting.html</a><br>
                                              <br>
                                              <br>
                                              Regards,<br>
                                              Bogdan<span><font
                                                  color="#888888"><br>
                                                </font></span></tt><span><font
                                                color="#888888">
                                                <pre cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
                                              </font></span></div>
                                          <br>
_______________________________________________<br>
                                          Users mailing list<br>
                                          <a moz-do-not-send="true"
                                            href="mailto:Users@lists.opensips.org"
                                            target="_blank">Users@lists.opensips.org</a><br>
                                          <a moz-do-not-send="true"
                                            href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                                            target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                                          <br>
                                        </blockquote>
                                      </div>
                                      <br>
                                    </div>
                                  </div>
                                  <pre><fieldset></fieldset>
_______________________________________________
Users mailing list
<a moz-do-not-send="true" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                                </blockquote>
                                <br>
                                <br>
                                <pre cols="72">-- 
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
                              </div>
                            </div>
                          </div>
                          <br>
_______________________________________________<br>
                          Users mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:Users@lists.opensips.org"
                            target="_blank">Users@lists.opensips.org</a><br>
                          <a moz-do-not-send="true"
                            href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                            target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                      <pre><fieldset></fieldset>
_______________________________________________
Users mailing list
<a moz-do-not-send="true" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                    </blockquote>
                  </div>
                </div>
              </div>
              <br>
              _______________________________________________<br>
              Users mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
              <a moz-do-not-send="true"
                href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
  </body>
</html>