Просмотр исходного кода

dispatcher: updated documentation

- added new parameters and functions
- updated the docs about dispatcher list file
Daniel-Constantin Mierla 15 лет назад
Родитель
Сommit
bef7e92f9e

+ 1 - 1
modules_k/dispatcher/doc/dispatcher.list

@@ -3,7 +3,7 @@
 #
 
 # line format
-# setit(integer) destination(sip uri) flags (integer, optional)
+# setit(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(str,opt)
 
 # proxies
 2 sip:127.0.0.1:5080

+ 6 - 8
modules_k/dispatcher/doc/dispatcher.xml

@@ -38,15 +38,13 @@
 	</copyright>
 	<copyright>
 	    <year>2005</year>
-	    <holder>Voice-System.RO</holder>
+	    <holder>Voice Sistem</holder>
 	</copyright>
-	<revhistory>
-	    <revision>
-		<revnumber>$Revision$</revnumber>
-		<date>$Date$</date>
-	    </revision>
-	</revhistory>
-    </bookinfo>
+ 	<copyright>
+	    <year>2010</year>
+	    <holder>Daniel-Constantin Mierla (asipto.com)</holder>
+	</copyright>
+   </bookinfo>
     <toc></toc>
     
     <xi:include href="dispatcher_admin.xml"/>

+ 297 - 21
modules_k/dispatcher/doc/dispatcher_admin.xml

@@ -291,7 +291,7 @@ modparam("dispatcher", "force_dst", 1)
  		</para>
 		<note>
  		<para>
-		You must set this parameter if you want do do load balancing fail over.
+		You must set this parameter if you want to do load balancing fail over.
  		</para>
 		</note>
  		<para>
@@ -303,7 +303,7 @@ modparam("dispatcher", "force_dst", 1)
  		<title>Set the <quote>dst_avp</quote> parameter</title>
  <programlisting format="linespecific">
  ...
- modparam("dispatcher", "dst_avp", "$avp(i:271)")
+ modparam("dispatcher", "dst_avp", "$avp(dsdst)")
  ...
  </programlisting>
  		</example>
@@ -316,7 +316,7 @@ modparam("dispatcher", "force_dst", 1)
  		</para>
 		<note>
  		<para>
-		You must set this parameter if you want do do load balancing fail over.
+		You must set this parameter if you want to do load balancing fail over.
  		</para>
 		</note>
  		<para>
@@ -328,7 +328,7 @@ modparam("dispatcher", "force_dst", 1)
  		<title>Set the <quote>grp_avp</quote> parameter</title>
  <programlisting format="linespecific">
  ...
- modparam("dispatcher", "grp_avp", "$avp(i:272)")
+ modparam("dispatcher", "grp_avp", "$avp(dsgrp)")
  ...
  </programlisting>
  		</example>
@@ -341,7 +341,7 @@ modparam("dispatcher", "force_dst", 1)
  		</para>
 		<note>
  		<para>
-		You must set this parameter if you want do do load balancing fail over.
+		You must set this parameter if you want to do load balancing fail over.
  		</para>
 		</note>
  		<para>
@@ -353,7 +353,54 @@ modparam("dispatcher", "force_dst", 1)
  		<title>Set the <quote>cnt_avp</quote> parameter</title>
  <programlisting format="linespecific">
  ...
- modparam("dispatcher", "cnt_avp", "$avp(i:273)")
+ modparam("dispatcher", "cnt_avp", "$avp(dscnt)")
+ ...
+ </programlisting>
+ 		</example>
+ 	</section>
+ 	<section>
+ 		<title><varname>dstid_avp</varname> (str)</title>
+ 		<para>
+		The name of the avp storing the destination unique ID used for
+		call load based dispatching.
+ 		</para>
+		<note>
+ 		<para>
+		You must set this parameter if you want to do load balancing on
+		call load (alg 10).
+ 		</para>
+		</note>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>null</quote> - don't add AVP.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>dstid_avp</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "dstid_avp", "$avp(dsdstid)")
+ ...
+ </programlisting>
+ 		</example>
+ 	</section>
+ 	<section>
+ 		<title><varname>attrs_avp</varname> (str)</title>
+ 		<para>
+		The name of the avp storing destination's attributes value.
+ 		</para>
+		<note>
+		</note>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>null</quote> - don't add AVP.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>attrs_avp</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "attrs_avp", "$avp(dsattrs)")
  ...
  </programlisting>
  		</example>
@@ -542,6 +589,91 @@ modparam("dispatcher", "force_dst", 1)
  		</example>
 	</section>
 
+ 	<section>
+ 		<title><varname>ds_hash_size</varname> (int)</title>
+ 		<para>
+		The value to be used as power of two to set the number of slots
+		to hash table storing data for call load dispatching (e.g., value
+		8 will create a hash table with 256 slots).
+		It must be greater than 0 to enable call load dispatching feature
+		(alg 10).
+ 		</para>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>0</quote>.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>ds_hash_size</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "ds_hash_size", 9)
+ ...
+ </programlisting>
+ 		</example>
+	</section>
+ 	<section>
+ 		<title><varname>ds_hash_expire</varname> (int)</title>
+ 		<para>
+		Expiration time in seconds to remove the load on a destination if no
+		BYE was received meanwhile.
+ 		</para>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>7200</quote>.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>ds_hash_expire</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "ds_hash_expire", 3600)
+ ...
+ </programlisting>
+ 		</example>
+	</section>
+ 	<section>
+ 		<title><varname>ds_hash_initexpire</varname> (int)</title>
+ 		<para>
+		Expiration time in seconds to remove the load on a destination if no
+		200 for INVITE was received meanwhile and state updated with
+		ds_load_update().
+ 		</para>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>7200</quote>.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>ds_hash_initexpire</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "ds_hash_initexpire", 60)
+ ...
+ </programlisting>
+ 		</example>
+	</section>
+ 	<section>
+ 		<title><varname>ds_hash_check_interval</varname> (int)</title>
+ 		<para>
+		Time interval in seconds to scan internal hash table with call load
+		dispatching data for expired items.
+ 		</para>
+ 		<para>
+ 		<emphasis>
+ 			Default value is <quote>30</quote>.
+ 		</emphasis>
+ 		</para>
+ 		<example>
+ 		<title>Set the <quote>ds_hash_check_interval</quote> parameter</title>
+ <programlisting format="linespecific">
+ ...
+ modparam("dispatcher", "ds_hash_check_interval", 60)
+ ...
+ </programlisting>
+ 		</example>
+	</section>
+
 	</section>
 
 	<section>
@@ -618,6 +750,38 @@ modparam("dispatcher", "force_dst", 1)
 				<quote>8</quote> - use first destination (good for failover).
 				</para>
 			</listitem>
+			<listitem>
+				<para>
+				<quote>9</quote> - use weight based load distribution. You
+				have to set the attribute 'weight' per each address in
+				destination set.
+				</para>
+			</listitem>
+			<listitem>
+				<para>
+				<quote>10</quote> - use call load distribution. You have
+				to set the attribute 'duid' (as an unique string id)
+				per each address in destination set. Also, you must set
+				parameters 'dstid_avp' and 'ds_hash_size'.
+				</para>
+				<para>
+				The algorithm can be used even with stateless proxy mode,
+				there is no SIP dialog tracking depending on other modules,
+				just an internal lightweight call tracking by Call-Id, thus
+				is fast and suitable even for embedded systems.
+				</para>
+				<para>
+				The first destination selected by this algorithm is the one
+				that has the least number of calls associated. The rest of
+				the destination list is taken in order of the entries in set
+				- anyhow, until a re-route to next destination happens, the
+				load on each address can change.
+				</para>
+				<para>
+				This algorithm can be used only for dispatching INVITE
+				requests as it is the only SIP method creating a SIP call.
+				</para>
+			</listitem>
 			<listitem>
 				<para>
 				<quote>X</quote> - if the algorithm is not implemented, the
@@ -710,20 +874,29 @@ ds_select_dst("1", "$var(a)");
  		<function moreinfo="none">ds_mark_dst("s")</function>
  		</title>
  		<para>
- 		Mark the last used address from destination set as inactive ("i"/"I"/"0"), active ("a"/"A"/"1") or probing ("p"/"P"/"2").
- 		With this function, an automatic detection of failed gateways can be implemented. When an address is marked as
-		inactive or probing, it will be ignored by 'ds_select_dst' and 'ds_select_domain'.
+		Mark the last used address from destination set as inactive
+		("i"/"I"/"0"), active ("a"/"A"/"1") or probing ("p"/"P"/"2").
+		With this function, an automatic detection of failed gateways
+		can be implemented. When an address is marked as
+		inactive or probing, it will be ignored by 'ds_select_dst' and
+		'ds_select_domain'.
  		</para>
 		<para>possible parameters:</para>
 		<itemizedlist>
 		<listitem>
-			<para><emphasis>"i", "I" or "0"</emphasis> - the last destination should be set to inactive and will be ignored in future requests.</para>
+			<para><emphasis>"i", "I" or "0"</emphasis> - the last destination
+				should be set to inactive and will be ignored in future
+				requests.</para>
 		</listitem>
 		<listitem>
-			<para><emphasis>"a", "A" or "1"</emphasis> - the last destination should be set to active.</para>
+			<para><emphasis>"a", "A" or "1"</emphasis> - the last destination
+				should be set to active.</para>
 		</listitem>
 		<listitem>
-			<para><emphasis>"p", "P" or "2"</emphasis> - the last destination will be set to probing. Note: You will need to call this function "threshhold"-times, before it will be actually set to probing.</para>
+			<para><emphasis>"p", "P" or "2"</emphasis> - the last destination
+				will be set to probing. Note: You will need to call this
+				function "threshhold"-times, before it will be actually set
+				to probing.</para>
 		</listitem>
 		</itemizedlist>
 		<para>
@@ -735,10 +908,12 @@ ds_select_dst("1", "$var(a)");
  		<function moreinfo="none">ds_is_from_list()</function>
  		</title>
  		<para>
- 		This function returns true, if the current request comes from a host from the dispatcher-list; otherwise false.
+			This function returns true, if the current request comes from a
+			host from the dispatcher-list; otherwise false.
  		</para>
 		<para>
-		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and ONREPLY_ROUTE.
+			This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+			BRANCH_ROUTE and ONREPLY_ROUTE.
 		</para>
  	</section>
   	<section>
@@ -746,12 +921,76 @@ ds_select_dst("1", "$var(a)");
  		<function moreinfo="none">ds_is_from_list("group")</function>
  		</title>
  		<para>
- 		This function returns true, if the current request comes from a host in the given group of the dispatcher-list; otherwise false.
+		This function returns true, if the current request comes from a host
+		in the given group of the dispatcher-list; otherwise false.
+ 		</para>
+		<para>
+			This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+			BRANCH_ROUTE and ONREPLY_ROUTE.
+		</para>
+ 	</section>
+  	<section>
+ 		<title>
+ 		<function moreinfo="none">ds_load_update()</function>
+ 		</title>
+ 		<para>
+		Updates the load state:
  		</para>
+		<itemizedlist>
+		<listitem>
+			<para>if it is a BYE or CANCEL - remove the load from
+			destination address used to forward the INVITE</para>
+		</listitem>
+		<listitem>
+			<para>if it is a reply to INVITE - set internal state
+				to confirmed for call load structure when reply code is
+				2xx.</para>
+		</listitem>
+		</itemizedlist>
 		<para>
-		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and ONREPLY_ROUTE.
+			This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+			BRANCH_ROUTE and ONREPLY_ROUTE.
 		</para>
  	</section>
+  	<section>
+ 		<title>
+ 		<function moreinfo="none">ds_load_unset()</function>
+ 		</title>
+ 		<para>
+		Remove the call load for the destination that routed the call.
+ 		</para>
+		<para>
+			This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
+			BRANCH_ROUTE and ONREPLY_ROUTE.
+		</para>
+		<example>
+		<title><function>ds_load_unset</function> usage</title>
+		<programlisting format="linespecific">
+...
+route {
+    ...
+	if(is_method("BYE|CANCEL"))
+        ds_load_update();
+    ...
+	ds_select_dst("1", "10");
+    ...
+}
+
+onreply_route {
+    ...
+    if(is_method("INVITE")
+	{
+        if(status=~"2[0-9][0-9]")
+            ds_load_update();
+        else if(status=~"[3-7][0-9][0-9]")
+            ds_load_unset();
+    }
+    ...
+}
+...
+</programlisting>
+		</example>
+ 	</section>
 	</section>
 
 	<section>
@@ -838,11 +1077,48 @@ ds_select_dst("1", "$var(a)");
 		<title>Destination List File</title>
 		<para>
 		Each destination point must be on one line. First token is the set
-		id, followed by destination address. Optionally, the third field can
-		be flags value (1 - destination inactive, 2 - destination in probing
-		mod -- you can do bitwise OR to set both flags). The set id must be
-		an integer value. Destination address must be a valid SIP URI. Empty
-		lines or lines starting with <quote>#</quote> are ignored.
+		id (an integer value), followed by destination address
+		(s string value in SIP URI format).
+		</para>
+		<para>
+		Optionally, these fields can be followed by:
+		</para>
+		<itemizedlist>
+			<listitem>
+			<para>flags: 1 - destination inactive, 2 - destination in probing
+			mode -- you can do bitwise OR to set both flags</para>
+			</listitem>
+			<listitem>
+			<para>priority: sets the priority in destination list (based on it
+			is done the initial ordering inside the set)</para>
+			</listitem>
+			<listitem>
+			<para>attributes: extra filed in form of
+			name1=value1;...;nameN=valueN. There are some predefined names
+			that are used of weight and call load dispatching.</para>
+			</listitem>
+		</itemizedlist>
+		<para>
+		Line format is:
+		</para>
+		<programlisting format="linespecific">
+...
+setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attrs(str,opt)
+...
+</programlisting>
+
+		<para>
+		Full line example:
+		</para>
+		<programlisting format="linespecific">
+...
+1 sip:127.0.0.1:5080 0 0 duid=abc;my=xyz
+...
+</programlisting>
+
+		<para>
+		For database, each element of a line resides in a different column.
+		Next is a dispatcher.list file example:
 		</para>
 		<example>
 		<title>dispatcher list file</title>