-
Notifications
You must be signed in to change notification settings - Fork 909
/
README
607 lines (444 loc) · 17 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
SipTrace Module
Daniel-Constantin Mierla
<miconda@gmail.com>
Edited by
Alexandr Dubovikov
<alexandr.dubovikov@gmail.com>
Daniel-Constantin Mierla
<miconda@gmail.com>
Giacomo Vacca
<giacomo.vacca@gmail.com>
Camille Oudot
<camille.oudot@orange.com>
Copyright © 2010 asipto.com
Copyright © 2006 voice-system.ro
__________________________________________________________________
Table of Contents
1. Admin Guide
1. Overview
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
3. Parameters
3.1. db_url (str)
3.2. table (str)
3.3. trace_flag (integer)
3.4. trace_on (integer)
3.5. traced_user_avp (str)
3.6. trace_table_avp (str)
3.7. duplicate_uri (str)
3.8. trace_to_database (integer)
3.9. trace_local_ip (str)
3.10. trace_sl_acks (integer)
3.11. xheaders_write (integer)
3.12. xheaders_read (integer)
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
3.16. trace_delayed (integer)
3.17. force_send_sock (str)
3.18. trace_mode (integer)
3.19. auth_key (integer)
4. Functions
4.1. sip_trace([address][,correlation_id][,mode])
4.2. sip_trace_mode(tmode)
4.3. hlog([correlation_id,] message)
5. RPC Commands
5.1. siptrace.status param
6. Database setup
7. Known issues
List of Examples
1.1. Set db_url parameter
1.2. Set table parameter
1.3. Set trace_flag parameter
1.4. Set trace_on parameter
1.5. Set traced_user_avp parameter
1.6. Set trace_table_avp parameter
1.7. Set duplicate_uri parameter
1.8. Set trace_to_database parameter
1.9. Set trace_local_ip parameter
1.10. Set trace_sl_acks parameter
1.11. Set xheaders_write parameter
1.12. Set xheaders_read parameter
1.13. Set hep_mode_on parameter
1.14. Set hep_version parameter
1.15. Set hep_capture_id parameter
1.16. Set trace_delayed parameter
1.17. Set force_send_sock parameter
1.18. Set trace_mode parameter
1.19. Set auth_key parameter
1.20. sip_trace() usage
1.21. sip_trace_mode() usage
1.22. hlog() usage
1.23. Send relayed ACK message
Chapter 1. Admin Guide
Table of Contents
1. Overview
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
3. Parameters
3.1. db_url (str)
3.2. table (str)
3.3. trace_flag (integer)
3.4. trace_on (integer)
3.5. traced_user_avp (str)
3.6. trace_table_avp (str)
3.7. duplicate_uri (str)
3.8. trace_to_database (integer)
3.9. trace_local_ip (str)
3.10. trace_sl_acks (integer)
3.11. xheaders_write (integer)
3.12. xheaders_read (integer)
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
3.16. trace_delayed (integer)
3.17. force_send_sock (str)
3.18. trace_mode (integer)
3.19. auth_key (integer)
4. Functions
4.1. sip_trace([address][,correlation_id][,mode])
4.2. sip_trace_mode(tmode)
4.3. hlog([correlation_id,] message)
5. RPC Commands
5.1. siptrace.status param
6. Database setup
7. Known issues
1. Overview
The SIPtrace module offer a possibility to store incoming and outgoing
SIP messages in a database and/or duplicate to the capturing server
(using HEP, the Homer encapsulation protocol, or plain SIP mode). Since
version 5.3.0 new levels of tracing are available. Transactions and
dialogs can be traced.
There are multiple ways of storing information:
* by calling the sip_trace() method explicitly in the Kamailio
configuration file. In this case the original message is processed
along with it's corresponding transaction/dialog if certain flags
are used.
* by setting “trace_mode” to mirror or store to db all traffic.
The tracing can be turned on/off using Kamailio RPC commands.
kamctl rpc siptrace.status on
kamctl rpc siptrace.status off
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
2.1. Kamailio Modules
The following modules must be conditionally loaded before this module:
* A database module - Mysql, Postgres, dbtext, unixODBC... Optional,
if tracing to DB is enabled.
* dialog, tm and sl modules - optional, only if you want to trace
messages forwarded by these modules.
2.2. External Libraries or Applications
The following libraries or applications must be installed before
running Kamailio with this module loaded:
* None.
3. Parameters
3.1. db_url (str)
3.2. table (str)
3.3. trace_flag (integer)
3.4. trace_on (integer)
3.5. traced_user_avp (str)
3.6. trace_table_avp (str)
3.7. duplicate_uri (str)
3.8. trace_to_database (integer)
3.9. trace_local_ip (str)
3.10. trace_sl_acks (integer)
3.11. xheaders_write (integer)
3.12. xheaders_read (integer)
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
3.16. trace_delayed (integer)
3.17. force_send_sock (str)
3.18. trace_mode (integer)
3.19. auth_key (integer)
3.1. db_url (str)
Database URL.
Default value is "mysql://kamailio:kamailiorw@localhost/kamailio".
Example 1.1. Set db_url parameter
...
modparam("siptrace", "db_url", "dbdriver://username:password@dbhost/dbname")
...
3.2. table (str)
Name of the table where to store the SIP messages.
Default value is “sip_trace”.
Example 1.2. Set table parameter
...
modparam("siptrace", "table", "strace")
...
3.3. trace_flag (integer)
Which flag is used to mark messages to trace without traced user.
Default value is "0".
Example 1.3. Set trace_flag parameter
...
modparam("siptrace", "trace_flag", 22)
...
3.4. trace_on (integer)
Parameter to enable/disable trace (on(1)/off(0))
Default value is "0".
Example 1.4. Set trace_on parameter
...
modparam("siptrace", "trace_on", 1)
...
3.5. traced_user_avp (str)
The name of the AVP storing the SIP URI of the traced user. If the AVP
is set, messages are stored in database table and the “traced_user”
column is filled with AVP's value. You can store the message many times
for many users by having multiple values for this AVP.
Default value is "NULL" (feature disabled).
Example 1.5. Set traced_user_avp parameter
...
modparam("siptrace", "traced_user_avp", "$avp(user)")
...
3.6. trace_table_avp (str)
The name of the AVP storing the name of the table where to store the
SIP messages. If it is not set, the value of “table” parameter is used.
In this way one can select dynamically where to store the traced
messages. The table must exist, and must have the same structure as the
“sip_trace” table.
Default value is "NULL" (feature disabled).
Example 1.6. Set trace_table_avp parameter
...
modparam("siptrace", "trace_table_avp", "$avp(i:345)")
modparam("siptrace", "trace_table_avp", "$avp(s:siptrace_table)")
...
3.7. duplicate_uri (str)
The address in form of a SIP URI where to send a duplicate of traced
message.
Default value is "NULL".
Example 1.7. Set duplicate_uri parameter
...
modparam("siptrace", "duplicate_uri", "sip:10.1.1.1:5888")
...
3.8. trace_to_database (integer)
Parameter to enable/disable inserts to the database from this Kamailio.
In case we only want to send the SIP messages to the “duplicate_uri”
and not store the information to the local database we can set this to
"0".
Default value is "1".
Example 1.8. Set trace_to_database parameter
...
modparam("siptrace", "trace_to_database", 0)
...
3.9. trace_local_ip (str)
The address to be used in “fromip” field for locally generated
messages. If not set, the module sets it to the address of the socket
that will be used to send the message.
Default value is "NULL".
Example 1.9. Set trace_local_ip parameter
...
modparam("siptrace", "trace_local_ip", "10.1.1.1:5064")
...
3.10. trace_sl_acks (integer)
Parameter to enable/disable tracing of SL-filtered ACKs (on=1 / off=0).
By default all ACKs to replies generated by SL module are traced. There
is no way to select among them. The SL module is able to run an event
route when such an ACK arrives (event_route[sl:filtered-ack]). You can
set this parameter to 0 and then execute sip_trace() in the event
route, accompanied by config rules to decide which ACK to trace.
Default value is "1".
Example 1.10. Set trace_sl_acks parameter
...
modparam("siptrace", "trace_sl_acks", 0)
...
3.11. xheaders_write (integer)
Parameter to enable/disable writing of x-headers.
Stores “fromip”, “toip”, “method” and “direction” in “X-Siptrace-*”
headers. This allows to transmit them to a second Kamailio server using
the “duplicate_uri” feature. Because the headers are added after the
data is written to the database, the headers only show up in the
packets sent by duplicate_uri.
See xheaders_read, it should be used on the receiving side.
Note: The headers are first read, then written. This allows relaying
the information over more than two Kamailio servers by setting both
xheaders_write and xheaders_read to "1" on the servers in the middle.
Default value is "0".
Example 1.11. Set xheaders_write parameter
...
modparam("siptrace", "xheaders_write", 0)
...
3.12. xheaders_read (integer)
Parameter to enable/disable reading of x-headers.
Reads and removes the “X-Siptrace-*” headers. Packets not containing
the headers are neither stored to the database nor relayed
(duplicate_uri). See xheaders_write for further information.
Default value is "0".
Example 1.12. Set xheaders_read parameter
...
modparam("siptrace", "xheaders_read", 0)
...
3.13. hep_mode_on (integer)
Parameter to enable/disable Homer encapsulate mode (on(1)/off(0))
Default value is "0".
Example 1.13. Set hep_mode_on parameter
...
modparam("siptrace", "hep_mode_on", 1)
...
3.14. hep_version (integer)
The parameter indicate the version of the HEP protocol. Can be “1”, “2”
or “3”. In HEPv2 and HEPv3 the timestamp and capture agent ID will be
included in the HEP header.
Default value is "1".
Example 1.14. Set hep_version parameter
...
modparam("siptrace", "hep_version", 3)
...
3.15. hep_capture_id (integer)
The parameter indicate the capture agent ID for the HEPv2 or HEPv3
protocol. Limitation: 16-bit integer for HEPv2, 32-bit for HEPv3.
Default value is "1".
Example 1.15. Set hep_capture_id parameter
...
modparam("siptrace", "hep_capture_id", 234)
...
3.16. trace_delayed (integer)
Use “INSERT DELAYED” to store to database when it is available, instead
of “INSERT”.
Default value is 0 (off).
Example 1.16. Set trace_delayed parameter
...
modparam("siptrace", "trace_delayed", 1)
...
3.17. force_send_sock (str)
The local interface in the form of SIP URI from where to send the
duplicated traffic. In the absence of this parameter Kamailio
automatically picks an interface.
Example 1.17. Set force_send_sock parameter
...
modparam("siptrace", "force_send_sock", "sip:10.1.1.2:5000")
...
3.18. trace_mode (integer)
If not set to 0, the module uses core events triggered when receiving
or sending SIP traffic to store it to database or mirror it to a SIP
capture server using HEP or UDP forwarding. It will automatically do
the handling of all SIP traffic. It is no longer needed to set the
siptrace flag per request or execute sip_trace(), if it is done, then
the storing and mirroring is duplicated.
The value of the parameter can be a combination of next values:
* 0 - no automatic mirroring or storing of SIP traffic.
* 1 (1st bit set) - mirror the traffic to HEP server.
* 2 (2nd bit set) - store the traffic to database server.
* 4 (3rd bit set) - mirro the traffic to the SIP URI specified by
duplicate_uri.
The trace_on parameter still has to be set, allowing also to control
this mode of mirroring via RPC commands.
Default value is 0.
Example 1.18. Set trace_mode parameter
...
modparam("siptrace", "trace_on", 1)
modparam("siptrace", "trace_mode", 1)
...
modparam("siptrace", "trace_mode", 3)
...
3.19. auth_key (integer)
A string with an authorization key. Supported on HEPv3 only.
Default value is empty.
Example 1.19. Set auth_key parameter
...
modparam("siptrace", "auth_key", "spoihepuirthpeuia")
...
4. Functions
4.1. sip_trace([address][,correlation_id][,mode])
4.2. sip_trace_mode(tmode)
4.3. hlog([correlation_id,] message)
4.1. sip_trace([address][,correlation_id][,mode])
Store or forward the current processed SIP message/transaction/dialog
in database. It is stored in the form prior applying changes made to
it. Based on mode, one can trace the current message('m' - default),
the current transaction('t') or the current dialog('d').
Meaning of the parameters is as follows:
* address - The address in form of SIP URI where to send a duplicate
of traced message. This parameter trumps duplicate_uri and allows
tracing to more than one server.
* correlation_id - A string with a correlation ID to be added to the
HEP header when using HEPv3. It's possible to use PVs.
* mode - SIP messages to be traced. One can trace the current message
(function can be called on either a reply or a request), the
current transaction(the route must belong to a request) or the
current dialog(the message has to be an invite).
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
ONREPLY_ROUTE, BRANCH_ROUTE.
Default value is "NULL".
Example 1.20. sip_trace() usage
...
sip_trace();
...
sip_trace("sip:10.1.1.2:5085");
...
sip_trace("sip:10.1.1.2:5085", "$ci-abc");
...
/* trace current dialog; needs to be done on initial INVITE and dialog has to be
loaded */
sip_trace("sip:10.1.1.2:5085", "$ci-abc", "d");
...
4.2. sip_trace_mode(tmode)
Set the tracing mode: message, transaction or dialog. Only the first
character of the parameter matters: m or M for message; t or T for
transaction; d or D for dialog.
In message tracing mode only the current message is stored or mirrored.
In transaction tracing mode, all the messages of the current
transaction are stored or mirrored. In dialog tracing mode, all the
messages of the current dialog are stored or mirrored.
This function can be used in ANY_ROUTE.
Example 1.21. sip_trace_mode() usage
...
sip_trace_mode("t");
...
4.3. hlog([correlation_id,] message)
Sends a log event as a HEP3 packet to the homer host configured in
duplicate_uri.
Meaning of the parameters is as follows:
* correlation_id (optional) - Homer correlation ID for this event. If
this parameter is not set, the current message's call-id will be
used. (This parameter may contain PVs)
* message - The text to send to Homer as log event. (This parameter
may contain PVs)
Example 1.22. hlog() usage
...
hlog("[cfg:$cfg(line)] This is a log from kamailio to Homer");
...
hlog("$hdr(P-MyID)", "Another one with a custom correlation ID");
...
5. RPC Commands
5.1. siptrace.status param
5.1. siptrace.status param
Name: siptrace.status
Parameters:
* on or off: turns on/off SIP message tracing. Possible values are:
+ on
+ off
* “check” does not change siptrace status, just reports the current
status.
RPC Command Format:
...
kamcmd siptrace.status on
kamcmd siptrace.status off
kamcmd siptrace.status check
...
6. Database setup
Before running Kamailio with siptrace, you have to setup the database
tables where the module will store the data. For that, if the table
were not created by the installation script or you choose to install
everything by yourself you can use the siptrace-create.sql SQL script
in the database directories in the kamailio/scripts folder as template.
You can also find the complete database documentation on the project
webpage,
https://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.
7. Known issues
Stateless forwarded messages (forward()) are not logged if you set the
flag, use sip_trace() inside onsend_route block.
If dialog level tracing is used internally generated BYE transaction(in
case of internal timeouts) won't be traced. At the moment kamailio
offers no posibility to trace those messages.
Trace_info xavp name is reserved by this module. Any use of xavp with
this name will result in overlapping internal avp used by the module
therefore causing unknown consequences.
Example 1.23. Send relayed ACK message
...
onsend_route {
if (is_method("ACK")) {
sip_trace();
}
}
...