SIP SESSION TIMER module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”The sst module provides a way to update the dialog expire timer based on the SIP INVITE/200 OK Session-Expires header value. You can use the sst module in an OpenSIPS proxy to allow freeing of local resources of dead (expired) calls.
You can also use the sst module to validate the MIN_SE header value and reply to any request with a “422 - Session Timer Too Small” if the value is too small for your OpenSIPS configuration.
How it works
Section titled “How it works”The sst module uses the dialog module to be notified of any new or updated dialogs. It will then look for and extract the session-expire: header value (if there is one) and override the dialog expire timer value for the current context dialog by setting the avp value.
You flag any call setup INVITE that you want to cause a timed session to be established. This will cause OpenSIPS to request the use of session times if the UAC does not request it.
All of this happens with a properly configured dialog and sst module and setting the dialog flag and the sst flag at the time any INVITE sip message is seen. There is no opensips.cfg script function call required to set the dialog expire timeout value. See the dialog module users guide for more information.
The sstCheckMin() script function can be used to varify the Session-expires / MIN-SE header field values are not too small for a proxy. If the SST min_se parameter value is smaller then the messages Session-Expires / MIN-SE values, the test will return true. You can also configure the function to send the 422 response for you.
The following was taken from the RFC as a call flow example:
+-------+ +-------+ +-------+| UAC-1 | | PROXY | | UAC-2 |+-------+ +-------+ +-------+ |(1) INVITE | | |SE: 50 | | |----------->| | | |(2)sstCheckMin | | |-----+ | | | | | | |<----+ | |(3) 422 | | |MSE:1800 | | |<-----------| | | | | |(4)ACK | | |----------->| | | | | |(5) INVITE | | |SE: 1800 | | |MSE: 1800 | | |----------->| | | |(6)sstCheckMin | | |-----+ | | | | | | |<----+ | | |(7)setflag | | |Dialog flag | | |Set expire | | |-----+ | | | | | | |<----+ | | | | | |(8)INVITE | | |SE: 1800 | | |MSE: 1800 | | |-------------->| | | | ...Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “OpenSIPS Modules”The following modules must be loaded before this module:
- dialog - dialog module and its decencies. (tm)
- sl - stateless module.
External Libraries or Applications
Section titled “External Libraries or Applications”The following libraries or applications must be installed before running OpenSIPS with this module loaded:
- None.
Exported Parameters
Section titled “Exported Parameters”enable_stats (integer)
Section titled “enable_stats (integer)”If the statistics support should be enabled or not. Via statistic variables, the module provide information about the dialog processing. Set it to zero to disable or to non-zero to enable it.
Default value is “1” (enabled).
...modparam("sst", "enable_stats", 0)...min_se (integer)
Section titled “min_se (integer)”The value is used to set the proxies MIN-SE value and is used in the 422 reply as the proxies MIN-SE: header value if the sstCheckMin() flag is set to true and the check fails.
If not set and sstCheckMin() is called with the send-reply flag set to true, the default 1800 seconds will be used as the compare and the MIN-SE: header value if the 422 reply is sent.
Default value is “1800” seconds.
...modparam("sst", "min_se", 2400)...sst_interval (integer)
Section titled “sst_interval (integer)”The sst minimum interval in Session-Expires header if OpenSIPS request the use of session times. The used value will be the maximum value between OpenSIPS minSE, UAS minSE and this value.
Per default the interval used will be the min_se value
Default value is “0” seconds.
...modparam("sst", "sst_interval", 2400)...timeout_avp (string)
Section titled “timeout_avp (string)”This parameter MUST be set to the same value as the dialog parameter of the same name. If this parameter is NOT set, the sst module will not do anything!
This is how the sst module knows which avp in the dialog module to change with the new expire value.
Default value is “NULL!” it is not set by default.
...modparam("dialog", "timeout_avp", "$avp(10)")# Set the sst modules timeout_avp to be the same valuemodparam("sst", "timeout_avp", "$avp(10)")...reject_to_small (integer)
Section titled “reject_to_small (integer)”In the initial INVITE if the UAC has requested a Session-Expire: and it’s value is smaller then our local policies Min-SE (see min_se above), then the PROXY has the right to reject the call by replying to the message with a 422 Session Timer Too Small and state our local Min-SE: value. The INVITE is NOT forwarded on through the PROXY.
This flag if true will tell the SST module to reject the INVITE with a 422 response. If false, the INVITE is forwarded through the PROXY with out any modifications.
Default value is “1” (true/on).
...modparam("sst", "reject_to_small", 0)...sst_flag (string/integer)
Section titled “sst_flag (string/integer)”Keeping with OpenSIPS, the module will not do anything to any message unless instructed to do so via the opensips.cfg script. You must set the sst_flag value in the setflag() call of the INVITE you want the sst module to process. But before you can do that, you need to tell the sst module which flag value you are assigning to sst.
In most cases when ever you create a new dialog via create_dialog() function,you will want to set the sst flag. If create_dialog() is not called and the sst flag is set, it will not have any effect.
This parameter must be set of the module will not load.
*WARNING:*Setting INT flags is deprecated! Use quoted strings instead!
Default value is “Not set!”.
...modparam("sst", "sst_flag", "SST_FLAG")...route { ... if (method=="INVITE") { setflag(SST_FLAG); # Set the sst flag create_dialog(); # and then create the dialog } ...}Exported Functions
Section titled “Exported Functions”sstCheckMin(send_reply_flag)
Section titled “sstCheckMin(send_reply_flag)”Check the current Session-Expires / MIN-SE values against the sst_min_se parameter value. If the Session-Expires or MIN_SE header value is less then modules minimum value, this function will return true.
If the fuction is called with the send_reply_flag set to true (1) and the requested Session-Expires / MIN-SE values are too small, a 422 reply will be sent for you. The 422 will carry a MIN-SE: header with the sst min_se parameter value set.
Meaning of the parameters is as follows:
- min_allowed - The value to compare the MIN_SE header value to.
...modparam("dialog", "timeout_avp", "$avp(4242)")...modparam("sst", "sst_flag", 6)modparam("sst", "timeout_avp", "$avp(4242)")modparam("sst", "min_se", 2400) # Must be >= 90...
route { if (method=="INVITE") { if (sstCheckMin("1")) { xlog("L_ERR", "422 Session Timer Too Small reply sent.\n"); exit; } # track the session timers via the dialog module setflag(6); create_dialog(); }}
... or ...
route { if (method=="INVITE") { if (sstCheckMin("0")) { xlog("L_ERR", "Session Timer Too Small, dropping request\n"); exit; } # track the session timers via the dialog module setflag(5); setflag(6); }}...Exported Statistics
Section titled “Exported Statistics”expired_sst
Section titled “expired_sst”Number of dialogs which got expired session timer.
Installation and Running
Section titled “Installation and Running”just load the module and remember to set the timeout_avp value.
Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Ron Winacott | 29 | 5 | 2136 | 318 |
| 2. | Bogdan-Andrei Iancu (@bogdan-iancu) | 28 | 23 | 121 | 142 |
| 3. | Daniel-Constantin Mierla (@miconda) | 15 | 12 | 105 | 105 |
| 4. | Stefan Darius (@dariusstefan) | 10 | 4 | 454 | 79 |
| 5. | Ovidiu Sas (@ovidiusas) | 6 | 3 | 172 | 45 |
| 6. | Vlad Paiu (@vladpaiu) | 5 | 3 | 29 | 35 |
| 7. | Henning Westerholt (@henningw) | 5 | 3 | 16 | 19 |
| 8. | Anca Vamanu | 5 | 2 | 63 | 68 |
| 9. | Damien Sandras (@dsandras) | 4 | 2 | 41 | 15 |
| 10. | Razvan Crainea (@razvancrainea) | 4 | 2 | 6 | 6 |
All remaining contributors: Christophe Sollet (@csollet), Liviu Chircu (@liviuchircu), Konstantin Bokarius, Dan Pascu (@danpascu), Edson Gellert Schubert, Elena-Ramona Modroiu.
(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)
(2) including any documentation-related commits, excluding merge commits
(3) ignoring whitespace edits, renamed files and auto-generated files
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Bogdan-Andrei Iancu (@bogdan-iancu) | Oct 2006 - Jul 2026 |
| 2. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 3. | Razvan Crainea (@razvancrainea) | Jun 2011 - Jun 2026 |
| 4. | Vlad Paiu (@vladpaiu) | Jun 2011 - Aug 2013 |
| 5. | Damien Sandras (@dsandras) | Jul 2013 - Jul 2013 |
| 6. | Liviu Chircu (@liviuchircu) | Jan 2013 - Jan 2013 |
| 7. | Christophe Sollet (@csollet) | Dec 2009 - Dec 2009 |
| 8. | Anca Vamanu | Oct 2007 - Sep 2009 |
| 9. | Henning Westerholt (@henningw) | Dec 2007 - Jun 2008 |
| 10. | Ovidiu Sas (@ovidiusas) | Mar 2008 - Jun 2008 |
All remaining contributors: Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Dan Pascu (@danpascu), Elena-Ramona Modroiu, Ron Winacott.
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Liviu Chircu (@liviuchircu), Vlad Paiu (@vladpaiu), Christophe Sollet (@csollet), Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Elena-Ramona Modroiu, Ron Winacott.
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0