acc_user.sgml

来自「性能优秀的SIP Proxy」· SGML 代码 · 共 1,271 行 · 第 1/3 页

SGML
1,271
字号
<!-- Acc Module User's Guide --><chapter>	<chapterinfo>	<revhistory>		<revision>		<revnumber>$Revision: 1.11 $</revnumber>		<date>$Date: 2006/01/13 15:05:36 $</date>		</revision>	</revhistory>	</chapterinfo>	<title>User's Guide</title>		<section>	<title>Overview</title>	<para>		acc module is used to report on transactions to syslog, 		<abbrev>SQL</abbrev>, <acronym>RADIUS</acronym> and 		<acronym>DIAMETER</acronym> (beta version).	</para>	<para>		To report on a transaction using syslog, use <quote>setflag</quote> 		to mark a transaction you are interested in with a flag, load 		accounting module and set its <quote>log_flag</quote> to the same 		flag number. The acc module will then report on completed transaction 		to syslog. A typical usage of the module takes no acc-specific		script command -- the functionality binds invisibly through 		transaction processing. Script writers just need to mark the 		transaction for accounting with proper setflag.	</para>	<para>		What is printed depends on module's <quote>log_fmt</quote> parameter.		It's a string with characters specifying which parts of request 		should be printed: 		<itemizedlist>		<listitem>			<para>n = Cseq number</para>		</listitem>		<listitem>			<para>c = Call-Id</para>		</listitem>		<listitem>			<para>m = Method</para>		</listitem>		<listitem>			<para>i = Inbound Request-URI</para>		</listitem>		<listitem>			<para>o = Outbound Request-URI</para>		</listitem>		<listitem>			<para>p = Username part of inbound Request-URI</para>		</listitem>		<listitem>			<para>D = Domain part of inbound Request-URI</para>		</listitem>		<listitem>			<para>f = From header</para>		</listitem>		<listitem>			<para>r = From TAG</para>		</listitem>		<listitem>			<para>F = From URI</para>		</listitem>		<listitem>			<para>0 = From URI user part</para>		</listitem>		<listitem>			<para>X = From URI domain part</para>		</listitem>		<listitem>			<para>t = To header</para>		</listitem>		<listitem>			<para>d = To TAG</para>		</listitem>		<listitem>			<para>T = To URI</para>		</listitem>		<listitem>			<para>1 = To URI user part</para>		</listitem>		<listitem>			<para>S = 3-digit Status code from reply</para>		</listitem>		<listitem>			<para>s = Status</para>		</listitem>		<listitem>			<para>U = User name (digest, From URI otherwise)</para>		</listitem>		<listitem>			<para>u = digest Username</para>		</listitem>		</itemizedlist>		If a value is not present in request, "n/a" is accounted instead.	</para>	<para>		Note that:		<itemizedlist>		<listitem>			<para>			A single INVITE may produce multiple accounting reports -- that's			due to SIP forking feature			</para>		</listitem>		<listitem>			<para>			Subsequent ACKs and other requests do not hit the server and 			can't be accounted unless record-routing is enforced. 			The ACKs assert very little useful information anyway and 			reporting on INVITE's 200 makes most accounting scenarios happy.			</para>		</listitem>		<listitem>			<para>			There is no session accounting -- &ser; maintains no sessions. 			If one needs to correlate INVITEs with BYEs for example for 			purpose of billing, then it is better done in the entity which 			collects accounting information. Otherwise, SIP server would 			have to become sessions-stateful, which would very badly			impact its scalability.			</para>		</listitem>		<listitem>			<para>			If a UA fails in middle of conversation, a proxy will never 			learn it. In general, a better practice is to account from an 			end-device (such as PSTN gateway), which best knows about call 			status (including media status and PSTN status in case of the 			gateway).			</para>		</listitem>		</itemizedlist>	</para>	<para>		Support for SQL, RADIUS and DIAMETER works analogously. The SQL support		is compiled in the moduls. For RADIUS and DIAMETER you need to 		enable it by recompiling the module with properly set defines: 		uncomment the RAD_ACC or DDIAM_ACC lines in		modules/acc/Makefile. To compile RADIUS support, 		you need to have radiusclient-ng (only versions higher or equal 		to 0.5.0) installed on your system which is available from		<ulink url='http://developer.berlios.de/projects/radiusclient-ng/'>		http://developer.berlios.de/projects/radiusclient-ng/</ulink>. 		The radius client needs to be configured properly. To do so, use the 		template at etc/radiusclient.conf and make sure		that module's radius_config parameter points to its location.  		In particular, accounting secret must match that one configured in 		server and proper dictionary is used (one is available at 		etc/sip_dictionary). Uses along with FreeRadius 		(<ulink url='http://www.freeradius.org/'>		http://www.freeradius.org/</ulink>) and Radiator 		(<ulink url='http://www.open.com.au/radiator/'>		http://www.open.com.au/radiator/</ulink>) servers have been 		reported to us.	</para>	<para>		For Radius support, the radius libraries must be dynamically linkable. 		You need to configure your OS so that &ser;, when started, will 		find it. Typically, you do so by manipulating		LD_LIBRARY_PATH environment variable or configuring ld.so.	</para>	<section>		<title>General Example</title>		<programlisting format="linespecific">loadmodule "modules/acc/acc.so"modparam("acc", "log_level", 1)modparam("acc", "log_flag", 1)if (uri=~"sip:+40") /* calls to Romania */ {    if (!proxy_authorize("sip_domain.net" /* realm */,    "subscriber" /* table name */))  {        proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );        break;    }    if (method=="INVITE" & !check_from()) {        log("from!=digest\n");        sl_send_reply("403","Forbidden");        break;    }    setflag(1); /* set for accounting (the same value as in log_flag!)    t_relay(); 	/* enter stateful mode now */};</programlisting>	</section>	</section>	<section>		<title>Extra accounting</title>		<section>			<title>Overview</title>			<para>			Along the static information defined via FMT-s, ACC modules 			allows dynamical selection of extra information to be logged. 			There are two classes of information that are accessible by 			extra accounting: data from SIP messages (as headers) and 			internal &ser; data (as AVPs).			</para>		</section>		<section>			<title>Definitions and syntax</title>			<para>			Selection of extra information is done via 			<emphasis>xxx_extra<emphasis> parameters by specifying the names			of additional information you want to log. This information is 			defined via pseudo-variables and may include headers or AVPs values			or other message or system values. The syntax of the parameter is:			</para>			<itemizedlist>				<listitem><para><emphasis>				xxx_extra = extra_definition (';'extra_definition)*				</emphasis></para></listitem>				<listitem><para><emphasis>				extra_definition = log_name '=' pseudo_variable				</emphasis></para></listitem>			</itemizedlist>			<para>			The full list of supported pseudo-variables in &ser; is availabe 			at: 			<ulink url="http://openser.org/docs/pseudo-variables-1.1.x.html">			http://openser.org/docs/pseudo-variables-1.1.x.html</ulink>			</para>			<para>			Via <emphasis>log_name</emphasis> you define how/where the 			<emphasis>data</emphasis> will be logged. Its meaning depends 			of the accounting support which is used:			<itemizedlist>				<listitem><para><emphasis>LOG accounting</emphasis> - log_name				will be just printed along with the data in <emphasis>				log_name=data</emphasis> format;				</para></listitem>				<listitem><para><emphasis>DB accounting</emphasis> - log_name 				will be the name of the DB column where the data will be 				stored.<emphasis>IMPORTANT<emphasis>: add in db 				<emphasis>acc</emphasis> table the columns corresponding to 				each extra data;				</para></listitem>				<listitem><para><emphasis>RADIUS accounting</emphasis> - 				log_name will be the AVP name used for packing the data into 				RADIUS message. The log_name will be translated to AVP number 				via the dictionary. <emphasis>IMPORTANT<emphasis>: add in 				RADIUS dictionary the <emphasis>log_name</emphasis> attribute.				</para></listitem>				<listitem><para><emphasis>DIAMETER accounting</emphasis> - 				log_name will be the AVP code used for packing the data 				into DIAMETER message. The AVP code is given directly as 				integer, since DIAMETER has no dictionary support yet.				<emphasis>IMPORTANT</emphasis>:	<emphasis>log_name</emphasis>				must be a number.				</para></listitem>			</itemizedlist>			</para>		</section>		<section>			<title>How it works</title>			<para>			Some pseudo variables may return more than one value (like 			headers or AVPs). In this case, the returned values are			embedded in a single string in a comma-separated format.			</para>		</section>	</section>	<section id="multi-call-legs">		<title>Multi Call-Legs accounting</title>		<section>			<title>Overview</title>			<para>			A SIP call can have multiple legs due forwarding actions. For 			example user A calls user B which forwards the call to user C. 			There is only one SIP call but with 2 legs ( A to B and B to C). 			Accounting the legs of a call is required for proper billing of 			the calls (if C is a PSTN number and the call is billed, user B 			must pay for the call -as last party modifing the call 			destination-, and not A -as initiator of the call. Call 			forwarding on server is only one example which shows the 			necessity of the having an accounting engine with multiple legs 			support.			</para>		</section>		<section>			<title>Configuration</title>			<para>			First how it works? The idea is to store in several &ser; AVP 			pairs the originator and destination for each call-leg. For the			A call B and B forwards to C example, the AVP pairs are (A,B) and			(B,C). There are two type of AVPs -source and destination- which			refined a call-leg. The administator must take care and to 			properly insert these AVP from the script (in proper order and 			with correct type).			</para>			<para>			When the accouning infomation for the call will be written/sent, 			all the call-leg pairs will be added (based on found AVP pairs).			</para>			<para>			By default, the multiple call-legs support is disable - it can be			enabled via the <varname>multi_leg_enabled</varname> module			parameter. By enabling it, you will have also to define the AVPs			to be used for source and destination (which define one call-leg).			From performance reasons, the AVPs may be specified only via IDs.			</para>		</section>		<section>			<title>Logged data</title>			<para>			For each call, all the source-destination pairs (which defined a 			call-leg) will be looged. How the information will be actually			logged, depends of the data backend:			</para>			<itemizedlist>				<listitem>				<para><emphasis>syslog</emphasis> -- all pairs will be added				to one record string as src_leg=xxx, dst_leg=xxxx pairs.				</para>				</listitem>				<listitem>				<para><emphasis>database</emphasis> -- each pair will be 				separatly logged (due DB data structure constraints); several				records will be written, the difference between them being 				only the source & destination of the corresponding call-leg.				with database support.</para>				<note><para>You will need to add in your DB (all acc related				tables) the two colums for call-leg definition (source and				destination).				</para></note>				</listitem>				<listitem>				<para><emphasis>Radius</emphasis> -- all pairs will be added				to same Radius accounting message as RADIUS AVPs - for each				call-leg two RADIUS AVPs will be added: source and 				destination				</para>				<note><para>You will need to add in your dictionaty the two 				RADIUS AVPs used for call-leg definition (source and				destination): Sip-Leg-Source and Sip-Leg-Destination				</para></note>				</listitem>				<listitem>				<para><emphasis>Diameter</emphasis> -- not supported.				with database support.</para>				</listitem>			</itemizedlist>		</section>	</section>	<section>		<title>Dependencies</title>		<section>			<title>&ser; Modules</title>			<para>			The module depends on the following modules (in the other words 			the listed modules must be loaded before this module):			<itemizedlist>				<listitem>				<para><emphasis>tm</emphasis> -- Transaction Manager</para>				</listitem>				<listitem>				<para><emphasis>a database module</emphasis> -- If database 				support is used.</para>				</listitem>				<listitem>				<para><emphasis>rr</emphasis> -- Record Route, if 				<quote>detect_direction</quote> module parameter is enabled.				</para>				</listitem>			</itemizedlist>			</para>		</section>		<section>			<title>External Libraries or Applications</title>			<para>			The following libraries or applications must be installed 			before running &ser; with this module loaded:			<itemizedlist>				<listitem>				<para><emphasis>radiusclient-ng</emphasis> 0.5.0 or higher -- 				if compiled with RADIUS support. See <ulink 				url='http://developer.berlios.de/projects/radiusclient-ng/'>				http://developer.berlios.de/projects/radiusclient-ng/</ulink>.				</para>				</listitem>			</itemizedlist>		</section>	</section>	<section>	<title>Exported Parameters</title>	<!-- Generic ACC parameters -->	<section>		<title><varname>early_media</varname> (integer)</title>		<para>		Should be early media (183) accounted too ?		</para>		<para>		Default value is 0 (no).		</para>		<example>		<title>early_media example</title>		<programlisting format="linespecific">modparam("acc", "early_media", 1)</programlisting>		</example>	</section>	<section>		<title><varname>failed_transaction_flag</varname> (integer)</title>		<para>		Per transaction flag which says if the transaction should be 		accounted also in case of failure (status>=300).		</para>		<para>		Default value is 0 (no flag).		</para>		<example>		<title>failed_transaction_flag example</title>		<programlisting format="linespecific">modparam("acc", "failed_transaction_flag", 4)</programlisting>		</example>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?