[SR-Users] Hello from newbie

Alex Balashov abalashov at evaristesys.com
Tue Feb 4 12:12:48 CET 2014


P.S. There is a dispatcher-oriented example config in the package that 
can help get you started:

http://git.sip-router.org/cgi-bin/gitweb.cgi?p=kamailio;a=blob;f=modules/dispatcher/doc/dispatcher.cfg;h=8c0fc4c1d7adc783bc8e85d0ceed7e59a3e13a43;hb=HEAD

But the central idea is really quite simple:

1. Load the 'dispatcher' module:

loadmodule "dispatcher"

2. Configure 'dispatcher' to load a list of hosts, either from a 
database (db_url), or else from a flat text file:

modparam("dispatcher", "db_url", 
"DB_DRIVER://DB_USER:DB_PASSWORD@DB_HOST/DB_NAME")
modparam("dispatcher", "table_name", "dispatcher")
modparam("dispatcher", "force_dst", 1)
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(s:d_dst_set)")
modparam("dispatcher", "grp_avp", "$avp(s:d_grp_set)")
modparam("dispatcher", "cnt_avp", "$avp(s:d_cnt_avp)")
modparam("dispatcher", "ds_probing_mode", 0)

3. In your initial request route, pick a host from the dispatcher set, 
based on the round-robin strategy (algorithm #4):

	if(!ds_select_domain("1", "4")) {
		# This should only happen if the route set is empty.

		sl_send_reply("503", "Out of Gateways");

		xlog("L_ERR", "[R-DISPATCHER-INITIAL:$ci] !> "
			      "No gateways available!\n");
		exit;
	}

	xlog("L_INFO", "[R-DISPATCHER-INITIAL:$ci] -> "
		       "Selected gateway: $rd:$rp\n");

	t_on_failure("DISPATCHER_ROLLOVER");

4. If that gateway should fail to respond or to accept the call, catch 
that event in a failure_route and pick the next gateway from the set:

failure_route[DISPATCHER_ROLLOVER] {
	if(t_is_expired() || t_is_canceled())
		exit;

	if(!ds_next_domain()) {
		# This should happen when we are out of gateways/have tried
		# the last one in the route set.

		xlog("L_ERR", "[R-DISPATCHER-ROLLOVER:$ci] !> "
			      "No more gateways in route set\n");

		t_reply("503", "Out of gateways");
		exit;
	}

	xlog("L_INFO", "[R-DISPATCHER-ROLLOVER:$ci] -> "
		       "Attempting relay to new gateway: $rd:$rp\n");

	t_on_failure("DISPATCHER_ROLLOVER");
	t_relay();
}

And repeat recursively until you run out of gateways.

5. The timeouts due to non-response of the gateway are regulated by the 
transaction state module (TM):

modparam("tm", "fr_timer", 3000)	# 3 seconds
modparam("tm", "fr_inv_timer", 90000)	# 1.5 minutes.

You can read more about these values here:

http://kamailio.org/docs/modules/4.1.x/modules/tm.html#fr_timer
http://kamailio.org/docs/modules/4.1.x/modules/tm.html#fr_inv_timer

-- Alex

-- 
Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Decatur, GA 30030
United States
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/



More information about the sr-users mailing list