[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ACD routing



Done:

Remplacer par : ACD routing rejection rate calculator

On 2009-10-22 09:54, Task-By Christian Lathion wrote:
From the data stored in the local openser database (last 10 minutes ACD for colt and verizon), implement routing in openser. This openser is currently running for INA calls (0800, 0848, etc.).

For each call, openser queries its local database and finds which vendor currently has the best ACD.

Routing logic of a call is as follows:

If it was targeted to colt and colt has the best ACD, route 80% of the calls to colt, reject the other 20%.
If it was targeted to colt and verizon has the best ACD, route 20% of the calls to colt, reject the other 80%.
If it was targeted to verizon and verizon has the best ACD, route 80% of the calls to verizon, reject the other 20%.
If it was targeted to verizon and colt has the best ACD, route 20% of the calls to verizon, reject the other 80%.

To know to which vendor the call was targeted, use the IP address on which the openser received the packet.


#
# $Id: kamailio.cfg 4576 2008-08-05 16:22:38Z klaus_darilion $
#
# Kamailion basic configuration script
#     by Anca Vamanu <anca@voice-system.ro>
#
# Please refer to the Core CookBook at http://www.kamailio.org/dokuwiki/doku.php
# for a explanation of possible statements, functions and parameters.
#


####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no

     xlog("=> ACD: prob = $var(prob_routage) + Reject_V = $var(Rej_Verizon) + Reject_C = $var(Rej_Colt)\n");
#    sl_send_reply("500","Error: Test Config !");
#    exit;

	
	if (rand_event())
		{
		xlog("=> ACD: Appel Reussi\n");
		switch($var(Ip_Routing))
			{
			case "212.249.15.9":
				rewritehostport("212.249.15.9:5060");
				break;
                        case "212.249.15.3":
                                rewritehostport("212.249.15.3:5060");
				break;
                        case "217.168.45.3":
		                prefix("00");
                                rewritehostport("217.168.45.3:5060");
				break;
			}	
		t_relay();
		}
	else
		{
		xlog("=> ACD: ECHEC Appel\n");
		sl_send_reply("500","Error: Test Config !");
		}
	
#	xlog("=> ACD: Rp = $Rp . $var(prob_routage) . $var(Ip_Routing):5060 \n");
	exit;
	}
	
	#################   Fin script ACD   #################
	
    # Forbidden destinations
    if($oU=~"^4190")
    {
      xlog("L_INFO","$Ts ==> Forbidden $oU\n");
      sl_send_reply("403","Forbidden");
      exit;
    }
	#################  Debut script ACD  #################
	
	#37410XX numbers :Arménie-Yerevan
	#else if ($oU=~"^37410")
	
	#################   Fin script ACD   #################
    # Unassigned
    else
    {
      xlog("L_INFO","$Ts ==> Unassigned Number $oU\n");
      sl_send_reply("404","Unassigned Number");
      exit;
    }
  }

  if (has_totag())
  {
    if (loose_route())
    {
      route(1);
    }
    else
    {
      if ( is_method("ACK") )
      {
        if ( t_check_trans() )
        {
          # non loose-route, but stateful ACK; must be an ACK after a 487 or e.g. 404 from upstream server
          t_relay();
          exit;
        }
        else
        {
          # ACK without matching transaction ... ignore and discard.\n");
          exit;
        }
      }
      sl_send_reply("404","Not here");
    }
    exit;
  }

  t_check_trans();

  route(1);
}


route[1]
{
  # for INVITEs enable some additional helper routes
  if (is_method("INVITE")) {
    t_on_failure("1");
  }
  if (!t_relay()) {
    sl_reply_error();
  };
  exit;
}

onreply_route[1]
{
  xlog("L_INFO","$Ts ==> Reply: $rs $rr\n");
#  if($rs=="486")
#  {
#    xlog("L_INFO","$Ts ==> 486\n");
#    replace("^SIP/2.0 180","SIP/2.0 486");
#    if(subst('/Busy/BUSY/')) xlog("L_INFO","$Ts ==> ok\n");
#    else xlog("L_INFO","$Ts ==> NO\n");
#  }
}

failure_route[2]
{
  xlog("L_INFO","$Ts ==> Failure route $rs $rr\n");
  if(t_check_status("486"))
  {
    t_reply("500", "User Busy Busy");
  }
}


failure_route[1]
{
  if (t_was_cancelled())
  {
    exit;
  }
}