5 <alexandr.dubovikov@gmail.com>
11 <alexandr.dubovikov@gmail.com>
13 Copyright © 2011-15 SIPCAPTURE ORG
15 Copyright © 2011 QSC AG
17 Copyright © 2011 http://www.qsc.de
18 __________________________________________________________________
28 2.2. External Libraries or Applications
35 3.4. hash_source (str)
36 3.5. db_insert_mode (integer)
37 3.6. capture_on (integer)
38 3.7. capture_mode (integer)
39 3.8. hep_capture_on (integer)
40 3.9. raw_ipip_capture_on (integer)
41 3.10. raw_moni_capture_on (integer)
42 3.11. raw_socket_listen (string)
43 3.12. raw_interface (string)
44 3.13. raw_sock_children (integer)
45 3.14. promiscuous_on (integer)
46 3.15. raw_moni_bpf_on (integer)
47 3.16. capture_node (str)
48 3.17. insert_retries (integer)
49 3.18. insert_retry_timeout (integer)
50 3.19. callid_aleg_header (str)
51 3.20. topoh_unmask (int)
55 4.1. sip_capture([table])
56 4.2. report_capture([table],[data])
64 6.1. sipcapture.status param
71 1.1. Set db_url parameter
72 1.2. Set sip_capture parameter
73 1.3. Set mt_mode parameter
74 1.4. Set mt_mode parameter
75 1.5. db_insert_mode example
76 1.6. Set capture_on parameter
77 1.7. capture_mode example
78 1.8. Set hep_capture_on parameter
79 1.9. Set raw_ipip_capture_on parameter
80 1.10. Set raw_moni_capture_on parameter
81 1.11. Set raw_socket_listen parameter
82 1.12. Set raw_interface parameter
83 1.13. Set raw_sock_children parameter
84 1.14. Set promiscous_on parameter
85 1.15. Set raw_moni_bpf_on parameter
86 1.16. Set capture_node parameter
87 1.17. Set insert_retries parameter
88 1.18. Set insert_retry_timeout parameter
89 1.19. Set callid_aleg_header parameter
90 1.20. Set topoh_unmask parameter
91 1.21. sip_capture() usage
92 1.22. report_capture() usage
94 Chapter 1. Admin Guide
101 2.1. Kamailio Modules
102 2.2. External Libraries or Applications
107 3.2. table_name (str)
109 3.4. hash_source (str)
110 3.5. db_insert_mode (integer)
111 3.6. capture_on (integer)
112 3.7. capture_mode (integer)
113 3.8. hep_capture_on (integer)
114 3.9. raw_ipip_capture_on (integer)
115 3.10. raw_moni_capture_on (integer)
116 3.11. raw_socket_listen (string)
117 3.12. raw_interface (string)
118 3.13. raw_sock_children (integer)
119 3.14. promiscuous_on (integer)
120 3.15. raw_moni_bpf_on (integer)
121 3.16. capture_node (str)
122 3.17. insert_retries (integer)
123 3.18. insert_retry_timeout (integer)
124 3.19. callid_aleg_header (str)
125 3.20. topoh_unmask (int)
129 4.1. sip_capture([table])
130 4.2. report_capture([table],[data])
138 6.1. sipcapture.status param
145 The sipcapture module stores incoming/outgoing SIP messages in
148 Kamailio can capture SIP messages in three modes
149 * IPIP encapsulation. (ETHHDR+IPHDR+IPHDR+UDPHDR).
150 * Monitoring/mirroring port.
151 * Homer encapsulation protocol mode (HEP v1, v2, v3).
153 The capturing can be turned on/off using mi or rpc commands. Example:
155 kamctl fifo sip_capture on
157 kamctl fifo sip_capture off
161 2.1. Kamailio Modules
162 2.2. External Libraries or Applications
164 2.1. Kamailio Modules
166 The following modules must be loaded before this module:
167 * database module - mysql, postrgress, dbtext, unixodbc...
169 2.2. External Libraries or Applications
171 The following libraries or applications must be installed before
172 running Kamailio with this module loaded:
178 3.2. table_name (str)
180 3.4. hash_source (str)
181 3.5. db_insert_mode (integer)
182 3.6. capture_on (integer)
183 3.7. capture_mode (integer)
184 3.8. hep_capture_on (integer)
185 3.9. raw_ipip_capture_on (integer)
186 3.10. raw_moni_capture_on (integer)
187 3.11. raw_socket_listen (string)
188 3.12. raw_interface (string)
189 3.13. raw_sock_children (integer)
190 3.14. promiscuous_on (integer)
191 3.15. raw_moni_bpf_on (integer)
192 3.16. capture_node (str)
193 3.17. insert_retries (integer)
194 3.18. insert_retry_timeout (integer)
195 3.19. callid_aleg_header (str)
196 3.20. topoh_unmask (int)
204 Example 1.1. Set db_url parameter
206 modparam("sipcapture", "db_url", "mysql://user:passwd@host/dbname")
209 3.2. table_name (str)
211 Name of the table's name used to store the SIP messages. Can contain
212 multiple tables, separated by "|".
214 Default value is "sip_capture". Only for Homer 3. For Homer 5, please
215 use an argument for the sip_capture function.
217 Example 1.2. Set sip_capture parameter
219 modparam("sipcapture", "table_name", "homer_capture")
221 modparam("sipcapture", "table_name", "homer_capture1|homer_capture2");
226 Name of the mode used for storing data in multiple tables. Modes can be
227 "rand" (random), "round_robin" (use a round_robin algorithm) or "hash"
228 (use hashing to determine the table to store). These modes are only
229 triggered if there is more than one table specified in table_name
230 parameter, separated by "|".
232 Default value is "rand".
234 Example 1.3. Set mt_mode parameter
236 modparam("sipcapture", "mt_mode", "hash")
239 3.4. hash_source (str)
241 The field of the SIP message used for hashing, when mt_mode is set to
242 "hash". The value can be "call_id", "to_user" or "from_user".
244 Default value is "call_id".
246 Example 1.4. Set mt_mode parameter
248 modparam("sipcapture", "hash_source", "to_user")
251 3.5. db_insert_mode (integer)
253 If set to 1, use INSERT DELAYED to store sip message into capture table
254 when the DB driver has support for it. If no INSERT DELAYED support is
255 offered by DB driver, then standard INSERT is used.
257 If set to 2, use ASYNC INSERT to store sip message into capture table
258 when the DB driver has support for it. If no ASYNC INSERT support is
259 offered by DB driver, then standard INSERT is used.
261 Default value is 0 (no INSERT DELAYED).
263 Example 1.5. db_insert_mode example
264 modparam("sipcapture", "db_insert_mode", 1)
266 3.6. capture_on (integer)
268 Parameter to enable/disable capture globaly (on(1)/off(0))
270 Default value is "0".
272 Example 1.6. Set capture_on parameter
274 modparam("sipcapture", "capture_on", 1)
277 3.7. capture_mode (integer)
279 This parameter can be used for defining a capture mode which can be
280 used in the sip_capture calls as a parameter. A capture mode has a name
281 and some parameters. It must be defined in the format:
282 name=>param1=val1;param2=val2;... The parameters are db_url,
283 table_name, mt_mode and hash_source (optional). Multiple capture modes
284 can be defined by using this parameter multiple times. After this, the
285 capture modes can be used like: sip_capture ("", "CAPTURE_MODE");
287 Example 1.7. capture_mode example
288 modparam("sipcapture", "capture_mode", "mode1=>db_url=mysql://user:passwd@host/d
289 bname1;table_name=homer_capture1|homer_capture2;mt_mode=hash;hash_source=call_id
291 modparam("sipcapture", "capture_mode", "mode2=>db_url=mysql://user:passwd@host/d
292 bname2;table_name=homer_capture3|homer_capture4;mt_mode=rand;")
294 3.8. hep_capture_on (integer)
296 Parameter to enable/disable capture of HEP (on(1)/off(0))
298 Default value is "0".
300 Example 1.8. Set hep_capture_on parameter
302 modparam("sipcapture", "hep_capture_on", 1)
305 3.9. raw_ipip_capture_on (integer)
307 Parameter to enable/disable IPIP capturing (on(1)/off(0))
309 Default value is "0".
311 Example 1.9. Set raw_ipip_capture_on parameter
313 modparam("sipcapture", "raw_ipip_capture_on", 1)
316 3.10. raw_moni_capture_on (integer)
318 Parameter to enable/disable monitoring/mirroring port capturing
319 (on(1)/off(0)) Only one mode on raw socket can be enabled! Monitoring
320 port capturing currently supported only on Linux.
322 Default value is "0".
324 Example 1.10. Set raw_moni_capture_on parameter
326 modparam("sipcapture", "raw_moni_capture_on", 1)
329 3.11. raw_socket_listen (string)
331 Parameter indicate an listen IP address of RAW socket for IPIP
332 capturing. You can also define a port/portrange for IPIP/Mirroring
333 mode, to capture SIP messages in specific ports:
335 "10.0.0.1:5060" - the source/destination port of the SIP message must
338 "10.0.0.1:5060-5090" - the source/destination port of the SIP message
339 must be equal or be between 5060 and 5090.
341 The port/portrange must be defined if you are planning to use mirroring
342 capture! In this case, the part with IP address will be ignored, but to
343 make parser happy, use i.e. 10.0.0.0
347 Example 1.11. Set raw_socket_listen parameter
349 modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060-5090")
351 modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060")
354 3.12. raw_interface (string)
356 Name of the interface to bind on the raw socket.
360 Example 1.12. Set raw_interface parameter
362 modparam("sipcapture", "raw_interface", "eth0")
365 3.13. raw_sock_children (integer)
367 Parameter define how many children that must be created to listen the
370 Default value is "1".
372 Example 1.13. Set raw_sock_children parameter
374 modparam("sipcapture", "raw_sock_children", 6)
377 3.14. promiscuous_on (integer)
379 Parameter to enable/disable promiscuous mode on the raw socket. Linux
382 Default value is "0".
384 Example 1.14. Set promiscous_on parameter
386 modparam("sipcapture", "promiscuous_on", 1)
389 3.15. raw_moni_bpf_on (integer)
391 Activate Linux Socket Filter (LSF based on BPF) on the mirroring
392 interface. The structure is defined in linux/filter.h. The default LSF
393 accept a port/portrange from the raw_socket_listen param. Currently LSF
394 supported only on Linux.
396 Default value is "0".
398 Example 1.15. Set raw_moni_bpf_on parameter
400 modparam("sipcapture", "raw_moni_bpf_on", 1)
403 3.16. capture_node (str)
405 Name of the capture node.
407 Default value is "homer01".
409 Example 1.16. Set capture_node parameter
411 modparam("sipcapture", "capture_node", "homer03")
414 3.17. insert_retries (integer)
416 The number of times Kamailio should retry to write to the Homer
417 database in case the first attempt failed. The retry is also limited
418 timewise by the insert_retry_timeout parameter. Values allowed range
421 Default value is 0 (no retries).
423 Example 1.17. Set insert_retries parameter
425 modparam("sipcapture", "insert_retries", 5)
428 3.18. insert_retry_timeout (integer)
430 The time limit in seconds Kamailio retries to write to the Homer
431 database in case the first attempt failed. This parameter is only used
432 together with the insert_retries parameter. Values allowed range from 0
435 Default value is 60 seconds.
437 Example 1.18. Set insert_retry_timeout parameter
439 modparam("sipcapture", "insert_retry_timeout", 10)
442 3.19. callid_aleg_header (str)
444 Header name used to correlate A-leg with B-leg. It can take a list of
445 headers, separated by semicolon, e.g. "X-CID0;X-CID1". First match
448 Default value is "X-CID".
450 Example 1.19. Set callid_aleg_header parameter
452 modparam("sipcapture", "callid_aleg_header", "X-CallIDALeg")
455 3.20. topoh_unmask (int)
457 If set to 1, call-id will be unmasked using topoh module api (topoh
458 module must be loaded in this case).
462 Example 1.20. Set topoh_unmask parameter
464 modparam("sipcapture", "topoh_unmask", 1)
469 4.1. sip_capture([table])
470 4.2. report_capture([table],[data])
472 4.1. sip_capture([table])
474 Store the current processed HEP/IPIP SIP message in database. It is
475 stored in the form prior applying changes made to it.
477 Meaning of the parameters is as follows:
478 * table - The table where HEP SIP message will be stored. Homer 5 use
479 now tables with datestamp. To generate an automatic table's name
480 please use strftime parameters. I.e. $var(table) =
481 "sip_capture_call_%Y%m%d" and set the variable as an argument of
482 the sip_capture function.
484 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
485 ONREPLY_ROUTE, BRANCH_ROUTE.
486 Default value is "NULL".
488 Example 1.21. sip_capture() usage
492 sip_capture("sip_capture_call_20160124");
495 4.2. report_capture([table],[data])
497 Store the current processed HEP REPORT message in database.
499 Meaning of the parameters is as follows:
500 * table - The table where REPORT message will be stored.
501 data - The custom report data.
503 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
504 ONREPLY_ROUTE, BRANCH_ROUTE.
505 Default value is "NULL".
507 Example 1.22. report_capture() usage
511 report_capture("report_data");
513 report_capture("report_data", "{\"MOS\":4.1,\"PACKET_LOST\":100"});
525 * capture_mode : turns on/off SIP message capturing. Possible values
529 The parameter is optional - if missing, the command will return the
530 status of the SIP message capturing (as string “on” or “off” )
531 without changing anything.
533 MI FIFO Command Format:
534 :sip_capture:_reply_fifo_file_
540 6.1. sipcapture.status param
542 6.1. sipcapture.status param
544 Name: sipcapture.status
547 * on or off: turns on/off SIP message capturing. Possible values are:
550 * “check” does not change sipcapture status, just reports the current
555 Before running Kamailio with the sipcapture module, you have to setup
556 the database tables where the module will store the data. For that, if
557 the table were not created by the installation script or you choose to
558 install everything by yourself you can use the homer_databases.sql, SQL
559 script in the sql folder of sipcapture module as template. You can also
560 find the complete database documentation on the project webpage,
561 http://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.
565 * 1. Only one capturing mode on RAW socket is supported: IPIP or
566 monitoring/mirroring port. Don't activate both at the same time.
567 Obsolete. Please use HEP mirroring now.
568 * 2. Mirroring port capturing works only on Linux.