Debian Codegraph @

src/modules/sst/README

raw
1 SST Module (SIP Session Timer)
2
3 Ron Winacott
4
5 SOMA Networks, Inc.
6
7 Edited by
8
9 Ron Winacott
10
11 Copyright © 2006 SOMA Networks, Inc.
12 __________________________________________________________________
13
14 Table of Contents
15
16 1. Admin Guide
17
18 1. Overview
19 2. How it works
20 3. Dependencies
21
22 3.1. Kamailio Modules
23 3.2. External Libraries or Applications
24
25 4. Parameters
26
27 4.1. enable_stats (integer)
28 4.2. min_se (integer)
29 4.3. timeout_avp (string)
30 4.4. reject_to_small (integer)
31 4.5. sst_flag (integer)
32
33 5. Functions
34
35 5.1. sstCheckMin(send_reply_flag)
36
37 6. Statistics
38
39 6.1. expired_sst
40
41 7. Installation and Running
42
43 List of Examples
44
45 1.1. Session timer call flow
46 1.2. Set enable_stats parameter
47 1.3. Set min_se parameter
48 1.4. Set timeout_avp parameter
49 1.5. Set reject_to_small parameter
50 1.6. Set sst_flag parameter
51 1.7. sstCheckMin usage
52
53 Chapter 1. Admin Guide
54
55 Table of Contents
56
57 1. Overview
58 2. How it works
59 3. Dependencies
60
61 3.1. Kamailio Modules
62 3.2. External Libraries or Applications
63
64 4. Parameters
65
66 4.1. enable_stats (integer)
67 4.2. min_se (integer)
68 4.3. timeout_avp (string)
69 4.4. reject_to_small (integer)
70 4.5. sst_flag (integer)
71
72 5. Functions
73
74 5.1. sstCheckMin(send_reply_flag)
75
76 6. Statistics
77
78 6.1. expired_sst
79
80 7. Installation and Running
81
82 1. Overview
83
84 SIP session timers are used to make sure that a session (dialog) is
85 still alive, even though there may have been a long time since the last
86 in-dialog message. If the other end is not responding, the dialog will
87 be hung up automatically. SIP session timers need to be supported by
88 all end points for it to work. It's a SIP extension, standardized by
89 the IETF.
90
91 The sst module provides a way to update the dialog expiry timer based
92 on the SIP INVITE/200 OK Session-Expires header value. You can use the
93 sst module in a Kamailio proxy to allow freeing of local resources of
94 dead calls.
95
96 You can also use the sst module to validate the MIN_SE header value and
97 reply to any request with a "422 - Session Timer Too Small" if the
98 value is too small for your Kamailio configuration.
99
100 2. How it works
101
102 The sst module uses the “dialog module” to be notified of any new or
103 updated dialogs. It will then look for and extract the Session-Expires:
104 header value (if there is one) and override the dialog expire timer
105 value for the current context dialog by setting the avp value.
106
107 You flag any call setup INVITE that you want to cause a timed session
108 to be established. This will cause Kamailio to request the use of
109 session timers if the UAC does not request it.
110
111 All of this happens with a properly configured dialog and sst module.
112 You need to call the dlg_manage() function and set the sst flag at the
113 time any INVITE sip message is seen. There is no kamailio.cfg script
114 function call required to set the dialog expire timeout value. See the
115 “dialog module” users guide for more information.
116
117 The “sstCheckMin()” script function can be used to verify that the
118 Session-expires / MIN-SE header field values are not too small for your
119 server. If the SST min_se parameter value is smaller than the messages
120 Session-Expires / MIN-SE values, the test will return true. You can
121 also configure the function to send the 422 error response for you.
122
123 The following was taken from the RFC as a call flow example:
124
125 Example 1.1. Session timer call flow
126 +-------+ +-------+ +-------+
127 | UAC-1 | | PROXY | | UAC-2 |
128 +-------+ +-------+ +-------+
129 |(1) INVITE | |
130 |SE: 50 | |
131 |----------->| |
132 | |(2)sstCheckMin |
133 | |-----+ |
134 | | | |
135 | |<----+ |
136 |(3) 422 | |
137 |MSE:1800 | |
138 |<-----------| |
139 | | |
140 |(4)ACK | |
141 |----------->| |
142 | | |
143 |(5) INVITE | |
144 |SE: 1800 | |
145 |MSE: 1800 | |
146 |----------->| |
147 | |(6)sstCheckMin |
148 | |-----+ |
149 | | | |
150 | |<----+ |
151 | |(7)setflag |
152 | |Dialog flag |
153 | |Set expire |
154 | |-----+ |
155 | | | |
156 | |<----+ |
157 | | |
158 | |(8)INVITE |
159 | |SE: 1800 |
160 | |MSE: 1800 |
161 | |-------------->|
162 | | |
163 ...
164
165 3. Dependencies
166
167 3.1. Kamailio Modules
168 3.2. External Libraries or Applications
169
170 3.1. Kamailio Modules
171
172 The following modules must be loaded before this module:
173 * dialog or ims_dialog - dialog module and its dependencies. (tm)
174 * sl - stateless module.
175
176 3.2. External Libraries or Applications
177
178 The following libraries or applications must be installed before
179 running Kamailio with this module loaded:
180 * None.
181
182 4. Parameters
183
184 4.1. enable_stats (integer)
185 4.2. min_se (integer)
186 4.3. timeout_avp (string)
187 4.4. reject_to_small (integer)
188 4.5. sst_flag (integer)
189
190 4.1. enable_stats (integer)
191
192 If the statistics support should be enabled or not. Via statistic
193 variables, the module provides information about the dialog processing.
194 Set it to zero to disable or to non-zero to enable it.
195
196 Default value is “1” (enabled).
197
198 Example 1.2. Set enable_stats parameter
199 ...
200 modparam("sst", "enable_stats", 0)
201 ...
202
203 4.2. min_se (integer)
204
205 The value is used to set the proxies MIN-SE value and is used in the
206 422 error reply as the proxies MIN-SE: header value if the
207 “sstCheckMin()” flag is set to true and the check fails.
208
209 If not set and “sstCheckMin()” is called with the send-reply flag set
210 to true, the default 1800 seconds will be used as the compare and the
211 MIN-SE: header value if the 422 reply is sent.
212
213 Default value is “1800” seconds.
214
215 Example 1.3. Set min_se parameter
216 ...
217 modparam("sst", "min_se", 2400)
218 ...
219
220 4.3. timeout_avp (string)
221
222 This parameter must be set to the same value as the dialog module
223 parameter of the same name, when it is wanted to update dialog timeout
224 using Session-Expires header value. If this parameter is not set, the
225 sst module will not update dialog timeout.
226
227 With this parameter, the sst module knows which avp is expected by the
228 dialog module to change to a new expire value.
229
230 Note that the avp is set only for requests within dialog, not for the
231 initial INVITE. For this one, it can be done using script operations,
232 see the next example for such solution.
233
234 Default value is “NULL” (not set by default).
235
236 Example 1.4. Set timeout_avp parameter
237 ...
238 modparam("dialog", "timeout_avp", "$avp(dlgtimeout)")
239 # Set the sst modules timeout_avp to be the same value
240 modparam("sst", "timeout_avp", "$avp(dlgtimeout)")
241 ...
242 request_route {
243 ...
244 # when wanting to use Session-Expires value for initial INVITE
245 if(is_method("INVITE") and !has_totag()) {
246 if(is_present_hf("Session-Expires")) {
247 $avp(dlgtimeout) = $(hdr(Session-Expires){s.int});
248 }
249 }
250 ...
251 }
252 ...
253
254 4.4. reject_to_small (integer)
255
256 In the initial INVITE if the UAC has requested a Session-Expires: and
257 its value is smaller than our local policies Min-SE (see min_se above),
258 then the proxy has the right to reject the call by replying to the
259 message with a “422 Session Timer Too Small” and state our local
260 Min-SE: value. The INVITE is NOT forwarded on through the proxy.
261
262 If this flag is true, the SST module will reject the INVITE with a 422
263 response. If false, the INVITE is forwarded through the PROXY without
264 any modifications.
265
266 Default value is “1” (true/on).
267
268 Example 1.5. Set reject_to_small parameter
269 ...
270 modparam("sst", "reject_to_small", 0)
271 ...
272
273 4.5. sst_flag (integer)
274
275 Keeping with Kamailio, the module will not do anything to any message
276 unless instructed to do so via the kamailio.cfg script. You must set
277 the sst_flag value in the setflag() call of the INVITE you want the sst
278 module to process. But before you can do that, you need to tell the sst
279 module which flag value you are assigning to sst.
280
281 In most cases whenever you call dlg_manage() function you will want to
282 set the sst flag. If the dialog is not tracked and the sst flag is set,
283 it will not have any effect.
284
285 This parameter must be set or the module will not load.
286
287 Default value is “Not set!”.
288
289 Example 1.6. Set sst_flag parameter
290 ...
291 modparam("sst", "sst_flag", 6)
292 ...
293 route {
294 ...
295 if (method=="INVITE") {
296 dlg_manage(); # Track the dialog
297 setflag(6); # set the sst flag
298 }
299 ...
300 }
301
302 5. Functions
303
304 5.1. sstCheckMin(send_reply_flag)
305
306 5.1. sstCheckMin(send_reply_flag)
307
308 Check the current Session-Expires / MIN-SE values against the
309 sst_min_se parameter value. If the Session-Expires or MIN_SE header
310 value is less than the modules minimum value, this function will return
311 true.
312
313 If the function is called with the send_reply_flag set to true (1) and
314 the requested Session-Expires / MIN-SE values are too small, a 422
315 reply will be sent for you. The 422 will carry a MIN-SE: header with
316 the sst min_se parameter value set.
317
318 Meaning of the parameters is as follows:
319 * min_allowed - The value to compare the MIN_SE header value to.
320
321 Example 1.7. sstCheckMin usage
322 ...
323 modparam("dialog", "timeout_avp", "$avp(i:4242)")
324 ...
325 modparam("sst", "sst_flag", 6)
326 modparam("sst", "timeout_avp", "$avp(i:4242)")
327 modparam("sst", "min_se", 2400) # Must be >= 90
328 ...
329
330 route {
331 if (method=="INVITE") {
332 if (sstCheckMin("1")) {
333 xlog("L_ERR", "422 Session Timer Too Small reply sent.\n");
334 exit;
335 }
336 # track the session timers via the dialog module
337 dlg_manage();
338 setflag(6);
339 }
340 }
341
342 ... or ...
343
344 route {
345 if (method=="INVITE") {
346 if (sstCheckMin("0")) {
347 xlog("L_ERR", "Session Timer Too Small, dropping request\n");
348 exit;
349 }
350 # track the session timers via the dialog module
351 dlg_manage();
352 setflag(6);
353 }
354 }
355 ...
356
357 6. Statistics
358
359 6.1. expired_sst
360
361 6.1. expired_sst
362
363 Number of dialogs which got expired session timer.
364
365 7. Installation and Running
366
367 Just load the module and remember to set the timeout_avp and sst_flag
368 values.