1 <?xml version="1.0" encoding='ISO-8859-1'?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
5 <!-- Include general documentation entities -->
6 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
10 <!-- Module User's Guide -->
14 <title>&adminguide;</title>
17 <title>Overview</title>
19 The sipcapture module stores incoming/outgoing SIP messages in database.
22 Kamailio can capture SIP messages in three modes
26 IPIP encapsulation. (ETHHDR+IPHDR+IPHDR+UDPHDR).
31 Monitoring/mirroring port.
36 Homer encapsulation protocol mode (HEP v1, v2, v3).
43 The capturing can be turned on/off using mi or rpc commands. Example:
46 &ctltool; fifo sip_capture on
49 &ctltool; fifo sip_capture off
53 <title>Dependencies</title>
55 <title>&kamailio; Modules</title>
57 The following modules must be loaded before this module:
61 <emphasis>database module</emphasis> - mysql, postrgress,
69 <title>External Libraries or Applications</title>
71 The following libraries or applications must be installed before running
72 &kamailio; with this module loaded:
76 <emphasis>None</emphasis>.
84 <title>Parameters</title>
85 <section id="sipcapture.p.db_url">
86 <title><varname>db_url</varname> (str)</title>
96 <title>Set <varname>db_url</varname> parameter</title>
97 <programlisting format="linespecific">
99 modparam("sipcapture", "db_url", "mysql://user:passwd@host/dbname")
104 <section id="sipcapture.p.table_name">
105 <title><varname>table_name</varname> (str)</title>
107 Name of the table's name used to store the SIP messages. Can contain multiple tables, separated by "|".
111 Default value is "sip_capture". Only for Homer 3. For Homer 5, please use an argument for the sip_capture function.
115 <title>Set <varname>sip_capture</varname> parameter</title>
116 <programlisting format="linespecific">
118 modparam("sipcapture", "table_name", "homer_capture")
120 modparam("sipcapture", "table_name", "homer_capture1|homer_capture2");
125 <section id="sipcapture.p.mt_mode">
126 <title><varname>mt_mode</varname> (str)</title>
128 Name of the mode used for storing data in multiple tables. Modes can be "rand" (random), "round_robin" (use a round_robin algorithm) or "hash" (use hashing to determine the table to store). These modes are only triggered if there is more than one table specified in table_name parameter, separated by "|".
132 Default value is "rand".
136 <title>Set <varname>mt_mode</varname> parameter</title>
137 <programlisting format="linespecific">
139 modparam("sipcapture", "mt_mode", "hash")
144 <section id="sipcapture.p.hash_source">
145 <title><varname>hash_source</varname> (str)</title>
147 The field of the SIP message used for hashing, when mt_mode is set to "hash". The value can be "call_id", "to_user" or "from_user".
151 Default value is "call_id".
155 <title>Set <varname>mt_mode</varname> parameter</title>
156 <programlisting format="linespecific">
158 modparam("sipcapture", "hash_source", "to_user")
163 <section id="sipcapture.p.db_insert_mode">
164 <title><varname>db_insert_mode</varname> (integer)</title>
166 If set to 1, use INSERT DELAYED to store sip message into capture table
167 when the DB driver has support for it. If no INSERT DELAYED support
168 is offered by DB driver, then standard INSERT is used.
171 If set to 2, use ASYNC INSERT to store sip message into capture table
172 when the DB driver has support for it. If no ASYNC INSERT support is
173 offered by DB driver, then standard INSERT is used.
176 Default value is 0 (no INSERT DELAYED).
179 <title>db_insert_mode example</title>
180 <programlisting format="linespecific">
181 modparam("sipcapture", "db_insert_mode", 1)
185 <section id="sipcapture.p.capture_on">
186 <title><varname>capture_on</varname> (integer)</title>
188 Parameter to enable/disable capture globaly (on(1)/off(0))
192 Default value is "0".
196 <title>Set <varname>capture_on</varname> parameter</title>
197 <programlisting format="linespecific">
199 modparam("sipcapture", "capture_on", 1)
205 <section id="sipcapture.p.capture_mode">
206 <title><varname>capture_mode</varname> (integer)</title>
208 This parameter can be used for defining a capture mode which can be used in
209 the sip_capture calls as a parameter. A capture mode has a name and some parameters.
210 It must be defined in the format: name=>param1=val1;param2=val2;...
211 The parameters are db_url, table_name, mt_mode and hash_source (optional).
212 Multiple capture modes can be defined by using this parameter multiple times.
213 After this, the capture modes can be used like:
214 sip_capture ("", "CAPTURE_MODE");
217 <title>capture_mode example</title>
218 <programlisting format="linespecific">
219 modparam("sipcapture", "capture_mode", "mode1=>db_url=mysql://user:passwd@host/dbname1;table_name=homer_capture1|homer_capture2;mt_mode=hash;hash_source=call_id;")
220 modparam("sipcapture", "capture_mode", "mode2=>db_url=mysql://user:passwd@host/dbname2;table_name=homer_capture3|homer_capture4;mt_mode=rand;")
224 <section id="sipcapture.p.hep_capture_on">
225 <title><varname>hep_capture_on</varname> (integer)</title>
227 Parameter to enable/disable capture of HEP (on(1)/off(0))
231 Default value is "0".
235 <title>Set <varname>hep_capture_on</varname> parameter</title>
236 <programlisting format="linespecific">
238 modparam("sipcapture", "hep_capture_on", 1)
243 <section id="sipcapture.p.raw_ipip_capture_on">
244 <title><varname>raw_ipip_capture_on</varname> (integer)</title>
246 Parameter to enable/disable IPIP capturing (on(1)/off(0))
250 Default value is "0".
254 <title>Set <varname>raw_ipip_capture_on</varname> parameter</title>
255 <programlisting format="linespecific">
257 modparam("sipcapture", "raw_ipip_capture_on", 1)
262 <section id="sipcapture.p.raw_moni_capture_on">
263 <title><varname>raw_moni_capture_on</varname> (integer)</title>
265 Parameter to enable/disable monitoring/mirroring port capturing (on(1)/off(0))
266 Only one mode on raw socket can be enabled! Monitoring port capturing currently
267 supported only on Linux.
271 Default value is "0".
275 <title>Set <varname>raw_moni_capture_on</varname> parameter</title>
276 <programlisting format="linespecific">
278 modparam("sipcapture", "raw_moni_capture_on", 1)
283 <section id="sipcapture.p.raw_socket_listen">
284 <title><varname>raw_socket_listen</varname> (string)</title>
286 Parameter indicate an listen IP address of RAW socket for IPIP capturing.
287 You can also define a port/portrange for IPIP/Mirroring mode, to capture
288 SIP messages in specific ports:
290 "10.0.0.1:5060" - the source/destination port of the SIP message must be equal 5060
293 "10.0.0.1:5060-5090" - the source/destination port of the SIP message must be
294 equal or be between 5060 and 5090.
297 The port/portrange must be defined if you are planning to
298 use mirroring capture! In this case, the part with IP address will be
299 ignored, but to make parser happy, use i.e. 10.0.0.0
308 <title>Set <varname>raw_socket_listen</varname> parameter</title>
309 <programlisting format="linespecific">
311 modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060-5090")
313 modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060")
318 <section id="sipcapture.p.raw_interface">
319 <title><varname>raw_interface</varname> (string)</title>
321 Name of the interface to bind on the raw socket.
329 <title>Set <varname>raw_interface</varname> parameter</title>
330 <programlisting format="linespecific">
332 modparam("sipcapture", "raw_interface", "eth0")
337 <section id="sipcapture.p.raw_sock_children">
338 <title><varname>raw_sock_children</varname> (integer)</title>
340 Parameter define how many children that must be created to listen the raw socket.
344 Default value is "1".
348 <title>Set <varname>raw_sock_children</varname> parameter</title>
349 <programlisting format="linespecific">
351 modparam("sipcapture", "raw_sock_children", 6)
356 <section id="sipcapture.p.promiscuous_on">
357 <title><varname>promiscuous_on</varname> (integer)</title>
359 Parameter to enable/disable promiscuous mode on the raw socket.
364 Default value is "0".
368 <title>Set <varname>promiscous_on</varname> parameter</title>
369 <programlisting format="linespecific">
371 modparam("sipcapture", "promiscuous_on", 1)
376 <section id="sipcapture.p.raw_moni_bpf_on">
377 <title><varname>raw_moni_bpf_on</varname> (integer)</title>
379 Activate Linux Socket Filter (LSF based on BPF) on the mirroring interface.
380 The structure is defined in linux/filter.h. The default LSF accept a port/portrange
381 from the raw_socket_listen param. Currently LSF supported only on Linux.
385 Default value is "0".
389 <title>Set <varname>raw_moni_bpf_on</varname> parameter</title>
390 <programlisting format="linespecific">
392 modparam("sipcapture", "raw_moni_bpf_on", 1)
397 <section id="sipcapture.p.capture_node">
398 <title><varname>capture_node</varname> (str)</title>
400 Name of the capture node.
404 Default value is "homer01".
408 <title>Set <varname>capture_node</varname> parameter</title>
409 <programlisting format="linespecific">
411 modparam("sipcapture", "capture_node", "homer03")
416 <section id="sipcapture.p.insert_retries">
417 <title><varname>insert_retries</varname> (integer)</title>
419 The number of times Kamailio should retry to write to the Homer database in case
420 the first attempt failed. The retry is also limited timewise by the
421 insert_retry_timeout parameter. Values allowed range from 0 to 500.
425 Default value is 0 (no retries).
429 <title>Set <varname>insert_retries</varname> parameter</title>
430 <programlisting format="linespecific">
432 modparam("sipcapture", "insert_retries", 5)
437 <section id="sipcapture.p.insert_retry_timeout">
438 <title><varname>insert_retry_timeout</varname> (integer)</title>
440 The time limit in seconds Kamailio retries to write to the Homer database in case
441 the first attempt failed. This parameter is only used together with the insert_retries
442 parameter. Values allowed range from 0 to 300.
446 Default value is 60 seconds.
450 <title>Set <varname>insert_retry_timeout</varname> parameter</title>
451 <programlisting format="linespecific">
453 modparam("sipcapture", "insert_retry_timeout", 10)
458 <section id="sipcapture.p.callid_aleg_header">
459 <title><varname>callid_aleg_header</varname> (str)</title>
461 Header name used to correlate A-leg with B-leg. It can take a list of headers,
462 separated by semicolon, e.g. "X-CID0;X-CID1". First match wins.
466 Default value is "X-CID".
470 <title>Set <varname>callid_aleg_header</varname> parameter</title>
471 <programlisting format="linespecific">
473 modparam("sipcapture", "callid_aleg_header", "X-CallIDALeg")
478 <section id="sipcapture.p.topoh_unmask">
479 <title><varname>topoh_unmask</varname> (int)</title>
481 If set to 1, call-id will be unmasked using topoh module api (topoh
482 module must be loaded in this case).
485 Default value is <emphasis>0</emphasis>.
488 <title>Set <varname>topoh_unmask</varname> parameter</title>
489 <programlisting format="linespecific">
491 modparam("sipcapture", "topoh_unmask", 1)
498 <title>Functions</title>
499 <section id="sipcapture.f.sip_capture">
501 <function moreinfo="none">sip_capture([table])</function>
504 Store the current processed HEP/IPIP SIP message in database. It is stored in the
505 form prior applying changes made to it.
507 <para>Meaning of the parameters is as follows:</para>
510 <para><emphasis>table</emphasis> - The table where HEP SIP message will be stored. Homer 5 use now tables with datestamp.
511 To generate an automatic table's name please use strftime parameters. I.e. $var(table) = "sip_capture_call_%Y%m%d" and set the variable
512 as an argument of the sip_capture function.
517 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
518 ONREPLY_ROUTE, BRANCH_ROUTE.
521 Default value is "NULL".
524 <title><function>sip_capture()</function> usage</title>
525 <programlisting format="linespecific">
529 sip_capture("sip_capture_call_20160124");
534 <section id="sipcapture.f.report_capture">
536 <function moreinfo="none">report_capture([table],[data])</function>
539 Store the current processed HEP REPORT message in database.
541 <para>Meaning of the parameters is as follows:</para>
544 <para><emphasis>table</emphasis> - The table where REPORT message will be stored.
546 <para><emphasis>data</emphasis> - The custom report data.
551 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
552 ONREPLY_ROUTE, BRANCH_ROUTE.
555 Default value is "NULL".
558 <title><function>report_capture()</function> usage</title>
559 <programlisting format="linespecific">
563 report_capture("report_data");
565 report_capture("report_data", "{\"MOS\":4.1,\"PACKET_LOST\":100"});
574 <title>RPC Commands</title>
575 <section id="sipcapture.r.sipcapture.status">
577 <function moreinfo="none">sipcapture.status param</function>
583 Name: <emphasis>sipcapture.status</emphasis>
585 <para>Parameters: </para>
587 <listitem><para>on or off: turns on/off SIP message capturing.
588 Possible values are:</para>
590 <listitem><para>on</para></listitem>
591 <listitem><para>off</para></listitem>
594 <listitem><para><quote>check</quote> does not change
595 sipcapture status, just reports the current status.</para>
601 <programlisting format="linespecific">
603 &kamcmd; sipcapture.status on
604 &kamcmd; sipcapture.status off
605 &kamcmd; sipcapture.status check
610 </section><!-- RPC commands -->
613 <title>Database setup</title>
615 Before running &kamailio; with the sipcapture module, you have to setup the database
616 tables where the module will store the data. For that, if the table were not
617 created by the installation script or you choose to install everything by
618 yourself you can use the homer_databases.sql, <acronym>SQL</acronym> script
619 in the sql folder of sipcapture module as template. You can also find the
620 complete database documentation on the project webpage, &kamailiodbdocslink;.
624 <title>Limitations</title>
627 1. Only one capturing mode on RAW socket is supported: IPIP or monitoring/mirroring port.
628 Don't activate both at the same time. Obsolete. Please use HEP mirroring now.
631 2. Mirroring port capturing works only on Linux.