Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/tcpops: new module to tweak TCP options
This module adds the ability to control TCP options (currently only keepalive) through the kamailio cfg, on demand, and on a per-socket basis.
- Loading branch information
1 parent
ff11428
commit 5193ff2
Showing
9 changed files
with
709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# TCP keepelive module | ||
# | ||
# | ||
# WARNING: do not run this directly, it should be run by the master Makefile | ||
|
||
include ../../Makefile.defs | ||
auto_gen= | ||
NAME=tcpops.so | ||
LIBS= | ||
|
||
DEFS+=-DKAMAILIO_MOD_INTERFACE | ||
|
||
include ../../Makefile.modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
TCP Ops module | ||
|
||
Camille Oudot | ||
|
||
Orange | ||
|
||
Copyright © 2015 Orange | ||
__________________________________________________________________ | ||
|
||
Table of Contents | ||
|
||
1. Admin Guide | ||
|
||
1. Overview | ||
2. Parameters | ||
3. Functions | ||
|
||
3.1. tcp_keepalive_enable([conid], idle, count, interval) | ||
3.2. tcp_keepalive_disable([conid]) | ||
|
||
List of Examples | ||
|
||
1.1. tcp_keepalive_enable usage | ||
1.2. tcp_keepalive_disable usage | ||
|
||
Chapter 1. Admin Guide | ||
|
||
Table of Contents | ||
|
||
1. Overview | ||
2. Parameters | ||
3. Functions | ||
|
||
3.1. tcp_keepalive_enable([conid], idle, count, interval) | ||
3.2. tcp_keepalive_disable([conid]) | ||
|
||
1. Overview | ||
|
||
This modules allows kamailio to control the TCP options (such as the | ||
keepalive mechanism), on demand, and on a per-socket basis. | ||
|
||
Note: the keepalive functions only work on systems with the | ||
HAVE_TCP_KEEPIDLE, HAVE_TCP_KEEPCNT and HAVE_TCP_KEEPINTVL macros | ||
defined (currently only Linux). | ||
|
||
2. Parameters | ||
|
||
3. Functions | ||
|
||
3.1. tcp_keepalive_enable([conid], idle, count, interval) | ||
3.2. tcp_keepalive_disable([conid]) | ||
|
||
3.1. tcp_keepalive_enable([conid], idle, count, interval) | ||
|
||
Enables keepalive on a TCP connection. | ||
|
||
Meaning of the parameters is as follows: | ||
* conid (optionnal): the kamailio internal connection id on which TCP | ||
keepalive will be enabled. If no parameter is given, the keepalive | ||
mechanism will be enabled on the current message source connection. | ||
* idle (seconds): the time before the first keepalive packet is sent | ||
out. | ||
* count: number of non-acked keepalive before reseting the | ||
connection. | ||
* interval (seconds): time between two keepalive probes. | ||
|
||
Retuns 1 on success, -1 on failure. | ||
|
||
Example 1.1. tcp_keepalive_enable usage | ||
request_route { | ||
if (is_method("INVITE")) { | ||
$avp(caller_conid) = $conid; | ||
} | ||
... | ||
} | ||
|
||
onreply_route { | ||
if (is_method("INVITE") && status == 200) { | ||
# enable on callee's connection | ||
tcp_keepalive_enable("60", "5", "5"); | ||
# enable on caller's connection | ||
tcp_keepalive_enable("$avp(caller_conid)", "60", "5", "2"); | ||
} | ||
... | ||
} | ||
|
||
3.2. tcp_keepalive_disable([conid]) | ||
|
||
Disables keepalive on a TCP connection. | ||
|
||
Meaning of the parameters is as follows: | ||
* conid (optionnal): the kamailio internal connection id on which TCP | ||
keepalive will be disabled. If no parameter is given, the keepalive | ||
mechanism will be disabled on the current message source | ||
connection. | ||
|
||
Retuns 1 on success, -1 on failure. | ||
|
||
Example 1.2. tcp_keepalive_disable usage | ||
request_route { | ||
... | ||
if (is_method("BYE")) { | ||
$avp(bye_conid) = $conid; | ||
} | ||
... | ||
} | ||
|
||
onreply_route { | ||
... | ||
if (is_method("BYE") && status == 200) { | ||
tcp_keepalive_disable(); | ||
tcp_keepalive_disable("$avp(bye_conid)"); | ||
} | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
docs = tcpops.xml | ||
|
||
docbook_dir=../../../docbook | ||
include $(docbook_dir)/Makefile.module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | ||
|
||
<section id="print.functions" xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<sectioninfo> | ||
</sectioninfo> | ||
|
||
<title>Functions</title> | ||
|
||
<section id="tcpops.f.tcp_keepalive_enable"> | ||
<title> | ||
<function>tcp_keepalive_enable([conid], idle, count, interval)</function> | ||
</title> | ||
<para> | ||
Enables keepalive on a TCP connection. | ||
</para> | ||
<para>Meaning of the parameters is as follows:</para> | ||
<itemizedlist> | ||
<listitem> | ||
<para><emphasis>conid</emphasis> (optionnal): the kamailio internal | ||
connection id on which TCP keepalive will be enabled. If no parameter | ||
is given, the keepalive mechanism will be enabled on the current message | ||
source connection. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para><emphasis>idle</emphasis> (seconds): the time before the first | ||
keepalive packet is sent out. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para><emphasis>count</emphasis>: number of non-acked keepalive before | ||
reseting the connection. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para><emphasis>interval</emphasis> (seconds): time between two keepalive | ||
probes. | ||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
<para>Retuns 1 on success, -1 on failure.</para> | ||
<example> | ||
<title><function>tcp_keepalive_enable</function> usage</title> | ||
<programlisting><![CDATA[ | ||
request_route { | ||
if (is_method("INVITE")) { | ||
$avp(caller_conid) = $conid; | ||
} | ||
... | ||
} | ||
onreply_route { | ||
if (is_method("INVITE") && status == 200) { | ||
# enable on callee's connection | ||
tcp_keepalive_enable("60", "5", "5"); | ||
# enable on caller's connection | ||
tcp_keepalive_enable("$avp(caller_conid)", "60", "5", "2"); | ||
} | ||
... | ||
} | ||
]]></programlisting> | ||
</example> | ||
</section> | ||
|
||
<section id="tcpops.f.tcp_keepalive_disable"> | ||
<title> | ||
<function>tcp_keepalive_disable([conid])</function> | ||
</title> | ||
<para> | ||
Disables keepalive on a TCP connection. | ||
</para> | ||
<para>Meaning of the parameters is as follows:</para> | ||
<itemizedlist> | ||
<listitem> | ||
<para><emphasis>conid</emphasis> (optionnal): the kamailio internal | ||
connection id on which TCP keepalive will be disabled. If no parameter | ||
is given, the keepalive mechanism will be disabled on the current message | ||
source connection. | ||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
<para>Retuns 1 on success, -1 on failure.</para> | ||
<example> | ||
<title><function>tcp_keepalive_disable</function> usage</title> | ||
<programlisting><![CDATA[ | ||
request_route { | ||
... | ||
if (is_method("BYE")) { | ||
$avp(bye_conid) = $conid; | ||
} | ||
... | ||
} | ||
onreply_route { | ||
... | ||
if (is_method("BYE") && status == 200) { | ||
tcp_keepalive_disable(); | ||
tcp_keepalive_disable("$avp(bye_conid)"); | ||
} | ||
... | ||
} | ||
]]></programlisting> | ||
</example> | ||
</section> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | ||
|
||
<section id="print.parameters" xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<sectioninfo> | ||
</sectioninfo> | ||
|
||
<title>Parameters</title> | ||
|
||
|
||
|
||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | ||
|
||
<book id="print" xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<bookinfo> | ||
<title>TCP Ops module</title> | ||
<authorgroup> | ||
<author> | ||
<firstname>Camille</firstname> | ||
<surname>Oudot</surname> | ||
<affiliation><orgname>Orange</orgname></affiliation> | ||
<address> | ||
<email>camille.oudot@orange.com</email> | ||
</address> | ||
</author> | ||
</authorgroup> | ||
<copyright> | ||
<year>2015</year> | ||
<holder>Orange</holder> | ||
</copyright> | ||
</bookinfo> | ||
<toc></toc> | ||
|
||
<chapter> | ||
<title>Admin Guide</title> | ||
<section id="tcpops.overview"> | ||
<title>Overview</title> | ||
<para> | ||
This modules allows kamailio to control the TCP options (such as the keepalive | ||
mechanism), on demand, and on a per-socket basis. | ||
</para> | ||
<para> | ||
<emphasis>Note</emphasis>: the keepalive functions only work on systems with the | ||
HAVE_TCP_KEEPIDLE, HAVE_TCP_KEEPCNT and HAVE_TCP_KEEPINTVL macros defined | ||
(currently only Linux). | ||
</para> | ||
</section> | ||
|
||
<xi:include href="params.xml"/> | ||
<xi:include href="functions.xml"/> | ||
</chapter> | ||
</book> | ||
|
Oops, something went wrong.