Browse code

lrkproxy:some features add to lrkproxy module

add 'gt' option for optimization port resource allocation
add 'custom_sdp_ip_avp' option for handling NAT client

Mojtaba Esfandiari.S authored on 03/12/2021 21:11:51
Showing 6 changed files
... ...
@@ -31,6 +31,8 @@ Mojtaba Esfandiari.S
31 31
                     4.3.5. lrkp_alg (integer)
32 32
                     4.3.6. hash_table_tout (integer)
33 33
                     4.3.7. hash_table_size (integer)
34
+                    4.3.8. custom_sdp_ip_avp (string)
35
+                    4.3.9. gt (integer)
34 36
 
35 37
               4.4. Functions
36 38
 
... ...
@@ -46,8 +48,10 @@ Mojtaba Esfandiari.S
46 48
    1.5. Set lrkp_alg parameter
47 49
    1.6. Set hash_table_tout parameter
48 50
    1.7. Set hash_table_size parameter
49
-   1.8. set_lrkproxy_set usage
50
-   1.9. lrkproxy_manage usage
51
+   1.8. Set custom_sdp_ip_avp parameter
52
+   1.9. Set gt parameter
53
+   1.10. set_lrkproxy_set usage
54
+   1.11. lrkproxy_manage usage
51 55
 
52 56
 Chapter 1. Admin Guide
53 57
 
... ...
@@ -73,6 +77,8 @@ Chapter 1. Admin Guide
73 77
               4.3.5. lrkp_alg (integer)
74 78
               4.3.6. hash_table_tout (integer)
75 79
               4.3.7. hash_table_size (integer)
80
+              4.3.8. custom_sdp_ip_avp (string)
81
+              4.3.9. gt (integer)
76 82
 
77 83
         4.4. Functions
78 84
 
... ...
@@ -142,6 +148,8 @@ Chapter 1. Admin Guide
142 148
         4.3.5. lrkp_alg (integer)
143 149
         4.3.6. hash_table_tout (integer)
144 150
         4.3.7. hash_table_size (integer)
151
+        4.3.8. custom_sdp_ip_avp (string)
152
+        4.3.9. gt (integer)
145 153
 
146 154
    4.4. Functions
147 155
 
... ...
@@ -172,15 +180,19 @@ Chapter 1. Admin Guide
172 180
    Default value is “NONE” (disabled).
173 181
 
174 182
    Example 1.1. Set lrkproxy_sock parameter
175
-...
176
-# single lrkproxy
177
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
183
+                                                ...
184
+                                                # single lrkproxy
185
+                                                modparam("lrkproxy", "lrkproxy_s
186
+ock", "udp:192.168.122.108:8080")
178 187
 
179
-# multiple lrkproxies for LB in diffenrent machine
180
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
181
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.109:8080")
188
+                                                # multiple lrkproxies for LB in
189
+diffenrent machine
190
+                                                modparam("lrkproxy", "lrkproxy_s
191
+ock", "udp:192.168.122.108:8080")
192
+                                                modparam("lrkproxy", "lrkproxy_s
193
+ock", "udp:192.168.122.109:8080")
182 194
 
183
-...
195
+                                                ...
184 196
 
185 197
 4.3.2. lrkproxy_disable_tout (integer)
186 198
 
... ...
@@ -191,9 +203,10 @@ modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.109:8080")
191 203
    Default value is “60”.
192 204
 
193 205
    Example 1.2. Set lrkproxy_disable_tout parameter
194
-...
195
-modparam("lrkproxy", "lrkproxy_disable_tout", 20)
196
-...
206
+                                                ...
207
+                                                modparam("lrkproxy", "lrkproxy_d
208
+isable_tout", 20)
209
+                                                ...
197 210
 
198 211
 4.3.3. lrkproxy_tout (integer)
199 212
 
... ...
@@ -202,9 +215,10 @@ modparam("lrkproxy", "lrkproxy_disable_tout", 20)
202 215
    Default value is “1”.
203 216
 
204 217
    Example 1.3. Set lrkproxy_tout parameter
205
-...
206
-modparam("lrkproxy", "lrkproxy_tout", 2)
207
-...
218
+                                                ...
219
+                                                modparam("lrkproxy", "lrkproxy_t
220
+out", 2)
221
+                                                ...
208 222
 
209 223
 4.3.4. lrkproxy_retr (integer)
210 224
 
... ...
@@ -214,9 +228,10 @@ modparam("lrkproxy", "lrkproxy_tout", 2)
214 228
    Default value is “5”.
215 229
 
216 230
    Example 1.4. Set lrkproxy_retr parameter
217
-...
218
-modparam("lrkproxy", "lrkproxy_retr", 2)
219
-...
231
+                                                ...
232
+                                                modparam("lrkproxy", "lrkproxy_r
233
+etr", 2)
234
+                                                ...
220 235
 
221 236
 4.3.5. lrkp_alg (integer)
222 237
 
... ...
@@ -226,9 +241,10 @@ modparam("lrkproxy", "lrkproxy_retr", 2)
226 241
    Default value is “0”.
227 242
 
228 243
    Example 1.5. Set lrkp_alg parameter
229
-...
230
-modparam("lrkproxy", "lrkp_alg", 1)
231
-...
244
+                                                ...
245
+                                                modparam("lrkproxy", "lrkp_alg",
246
+ 1)
247
+                                                ...
232 248
 
233 249
 4.3.6. hash_table_tout (integer)
234 250
 
... ...
@@ -251,9 +267,10 @@ modparam("lrkproxy", "lrkp_alg", 1)
251 267
    Default value is “3600”.
252 268
 
253 269
    Example 1.6. Set hash_table_tout parameter
254
-...
255
-modparam("lrkproxy", "hash_table_tout", "3600")
256
-...
270
+                                                ...
271
+                                                modparam("lrkproxy", "hash_table
272
+_tout", "3600")
273
+                                                ...
257 274
 
258 275
 4.3.7. hash_table_size (integer)
259 276
 
... ...
@@ -262,9 +279,36 @@ modparam("lrkproxy", "hash_table_tout", "3600")
262 279
    Default value is “128”.
263 280
 
264 281
    Example 1.7. Set hash_table_size parameter
265
-...
266
-modparam("lrkproxy", "hash_table_size", 256)
267
-...
282
+                                                ...
283
+                                                modparam("lrkproxy", "hash_table
284
+_size", 256)
285
+                                                ...
286
+
287
+4.3.8. custom_sdp_ip_avp (string)
288
+
289
+   This option useful for solving STUN and help UDP packets make it across
290
+   NAT devices safe and sound. In this way, it should be set by clients's
291
+   ip public manually.
292
+
293
+   Default value is “NULL”.
294
+
295
+   Example 1.8. Set custom_sdp_ip_avp parameter
296
+                                                ...
297
+                                                modparam("lrkproxy", "custom_sdp
298
+_ip_avp", "$avp(RR_CUSTOM_SDP_IP_AVP)")
299
+                                                ...
300
+
301
+4.3.9. gt (integer)
302
+
303
+   This option useful for optimization in allocation port resource in
304
+   lrkproxy service.
305
+
306
+   Default value is “0”.
307
+
308
+   Example 1.9. Set gt parameter
309
+                                                ...
310
+                                                modparam("lrkproxy", "gt", "1")
311
+                                                ...
268 312
 
269 313
 4.4. Functions
270 314
 
... ...
@@ -277,11 +321,11 @@ modparam("lrkproxy", "hash_table_size", 256)
277 321
    This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
278 322
    BRANCH_ROUTE.
279 323
 
280
-   Example 1.8. set_lrkproxy_set usage
281
-...
282
-set_lrkproxy_set("0");
283
-lrkproxy_manage();
284
-...
324
+   Example 1.10. set_lrkproxy_set usage
325
+                                                ...
326
+                                                set_lrkproxy_set("0");
327
+                                                lrkproxy_manage();
328
+                                                ...
285 329
 
286 330
 4.4.2.  lrkproxy_manage([flags [, ip_address]])
287 331
 
... ...
@@ -307,12 +351,12 @@ lrkproxy_manage();
307 351
 
308 352
    This function can be used from ANY_ROUTE.
309 353
 
310
-   Example 1.9. lrkproxy_manage usage
311
-...
312
-lrkproxy_manage();
313
-//or
314
-lrkproxy_manage("ie");
315
-//or
316
-lrkproxy_manage("ei");
354
+   Example 1.11. lrkproxy_manage usage
355
+                                                ...
356
+                                                lrkproxy_manage();
357
+                                                //or
358
+                                                lrkproxy_manage("ie");
359
+                                                //or
360
+                                                lrkproxy_manage("ei");
317 361
 
318
-...
362
+                                                ...
... ...
@@ -1,12 +1,12 @@
1 1
 <?xml version="1.0" encoding='ISO-8859-1'?>
2 2
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
-"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
3
+		"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4 4
 
5
-<!-- Include general documentation entities -->
6
-<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
7
-%docentities;
5
+		<!-- Include general documentation entities -->
6
+		<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
7
+		%docentities;
8 8
 
9
-]>
9
+		]>
10 10
 
11 11
 <!-- Module User's Guide -->
12 12
 
... ...
@@ -15,352 +15,401 @@
15 15
 	<title>&adminguide;</title>
16 16
 
17 17
 	<section>
18
-	<title>Overview</title>
19
-	<para>
20
-		This is a module that enables media streams to be relayed via
21
- 		pylrkproxy engine that exist in:
22
-		https://github.com/mojtabaesfandiari/pylrkproxy
23
-		It does relaying audio streams between peers in
24
-		PREROUTING netfilter-hooking section in kernel-space linux.
25
-		The LRKProxy architecture is composed of two
26
-		different layers. These layers are independent of each
27
-		other.
28
-		For more information about LRKProxy architecture, please visit our paper in ieeexplore:
29
-		https://ieeexplore.ieee.org/document/9303608
30
-	</para>
31
-	</section>
32
-
33
-	<section>
34
-	<title>LRKProxy Architecture</title>
35
-	<section>
36
-		<title>LRKP_Controlling Layer (LRKP_CL)</title>
18
+		<title>Overview</title>
37 19
 		<para>
38
-			The first layer is developed as User-Space
39
-			application that allows User-Space to directly
40
-			access and manipulate cache data
41
-			buffer and packet buffer in Kernel-Space. This layer
42
-			gets all information about creating new sessions,
43
-			active sessions and teardown sessions which is
44
-	       		gotten from SDP body during signaling plan and relay
45
-			them to the LRKP-Transport Stateful Layer (LRKP-
46
-			TSL).
20
+			This is a module that enables media streams to be relayed via
21
+			pylrkproxy engine that exist in:
22
+			https://github.com/mojtabaesfandiari/pylrkproxy
23
+			It does relaying audio streams between peers in
24
+			PREROUTING netfilter-hooking section in kernel-space linux.
25
+			The LRKProxy architecture is composed of two
26
+			different layers. These layers are independent of each
27
+			other.
28
+			For more information about LRKProxy architecture, please visit our paper in ieeexplore:
29
+			https://ieeexplore.ieee.org/document/9303608
47 30
 		</para>
48 31
 	</section>
49
-	<section>
50
-		<title>LRKP_Transport Stateful Layer (LRKP_TSL)</title>
51
-		<para>
52
-			The second layer is developed in Kernel-Space as
53
-        		a main decision point for RTP admission controller
54
-        		and Quickpath selector to where a received packet
55
-        		should be forwarded with power of packet mangling
56
-        		framework in the network stack.
57
-		</para>
58
-	</section>
59
-	<para>
60
-		The LRKP_CL and LRKP-TSL could be run as
61
-		independence functions on different machines. We
62
-		could have one LRKP_CL with multiple LRKP-TSL
63
-		on different machines. The LRKP_CL could works
64
-		with all LRKP-TSL with different strategies(lrkp_alg parameter).
65
-	</para>
66
-	</section>
67
-	<section>
68
-	<title>Multiple LRKProxy usage</title>
69
-	<para>
70
-		The LRKP_CL Layer can support multiple LRKP_TSL Layer
71
-    		for balancing/distribution and control/selection purposes.
72
-	</para>
73
-	<para>
74
-		The module allows definition of several sets of LRKP_TSL.
75
-		Load-balancing will be performed over predefine algorithm by setting lrkp_alg parameter.
76 32
 
77
-	</para>
78
-	<para>
79
-		IMPORTANT: This module does not support balancing inside a set like as is done RTPProxy module based on
80
-		the weight of each rtpproxy from the set. The balancing would be run on different machine
81
-	</para>
82
-	</section>
83
-	
84 33
 	<section>
85
-	<title>Dependencies</title>
86
-	<section>
87
-		<title>&kamailio; Modules</title>
88
-		<para>
89
-		The following modules must be loaded before this module:
90
-			<itemizedlist>
91
-			<listitem>
34
+		<title>LRKProxy Architecture</title>
35
+		<section>
36
+			<title>LRKP_Controlling Layer (LRKP_CL)</title>
92 37
 			<para>
93
-				<emphasis>tm module</emphasis> - (optional) if you want to
94
-				have lrkproxy_manage() fully functional
38
+				The first layer is developed as User-Space
39
+				application that allows User-Space to directly
40
+				access and manipulate cache data
41
+				buffer and packet buffer in Kernel-Space. This layer
42
+				gets all information about creating new sessions,
43
+				active sessions and teardown sessions which is
44
+				gotten from SDP body during signaling plan and relay
45
+				them to the LRKP-Transport Stateful Layer (LRKP-
46
+				TSL).
95 47
 			</para>
96
-			</listitem>
97
-			</itemizedlist>
98
-		</para>
99
-	</section>
100
-	<section>
101
-		<title>External Libraries or Applications</title>
102
-		<para>
103
-		The following libraries or applications must be installed before
104
-		running &kamailio; with this module loaded:
105
-			<itemizedlist>
106
-			<listitem>
48
+		</section>
49
+		<section>
50
+			<title>LRKP_Transport Stateful Layer (LRKP_TSL)</title>
107 51
 			<para>
108
-				<emphasis>None</emphasis>.
52
+				The second layer is developed in Kernel-Space as
53
+				a main decision point for RTP admission controller
54
+				and Quickpath selector to where a received packet
55
+				should be forwarded with power of packet mangling
56
+				framework in the network stack.
109 57
 			</para>
110
-			</listitem>
111
-			</itemizedlist>
112
-		</para>
113
-	</section>
114
-	<section>
115
-	<title>Parameters</title>
116
-	<section id="lrkproxy.p.lrkproxy_sock">
117
-	<title><varname>lrkproxy_sock</varname> (string)</title>
118
-			<para>
119
-			Used to define the list of LRKP_TSL instances to connect to. These can
120
-			be UNIX sockets or IPv4/IPv6 UDP sockets. Each modparam entry will
121
-   			insert sockets into a single set with default value set ID '0'.
122
-   			To define multiple LRKP_TSL, just add the instances in each modparam.
123
-			</para>
124
-			<para>
125
-			<emphasis>
126
-				Default value is <quote>NONE</quote> (disabled).
127
-			</emphasis>
128
-			</para>
129
-			<example>
130
-			<title>Set <varname>lrkproxy_sock</varname> parameter</title>
131
-			<programlisting format="linespecific">
132
-...
133
-# single lrkproxy
134
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
135
-
136
-# multiple lrkproxies for LB in diffenrent machine
137
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
138
-modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.109:8080")
139
-
140
-...
141
-</programlisting>
142
-		</example>
143
-	</section>
144
-	<section id="lrkproxy.p.lrkproxy_disable_tout">
145
-		<title><varname>lrkproxy_disable_tout</varname> (integer)</title>
146
-		<para>
147
-		Once LRKP_TSL was found unreachable and marked as disabled, the
148
-   		LRKP_CL module will not attempt to establish communication to LRKP_TSL
149
-   		for lrkproxy_disable_tout seconds.
150
-		</para>
151
-		<para>
152
-		<emphasis>
153
-			Default value is <quote>60</quote>.
154
-		</emphasis>
155
-		</para>
156
-		<example>
157
-		<title>Set <varname>lrkproxy_disable_tout</varname> parameter</title>
158
-		<programlisting format="linespecific">
159
-...
160
-modparam("lrkproxy", "lrkproxy_disable_tout", 20)
161
-...
162
-</programlisting>
163
-		</example>
164
-	</section>
165
-	<section id="lrkproxy.p.lrkproxy_tout">
166
-		<title><varname>lrkproxy_tout</varname> (integer)</title>
167
-		<para>
168
-		Timeout value in waiting for reply from LRKP_TSL.
169
-		</para>
170
-		<para>
171
-		<emphasis>
172
-			Default value is <quote>1</quote>.
173
-		</emphasis>
174
-		</para>
175
-		<example>
176
-		<title>Set <varname>lrkproxy_tout</varname> parameter</title>
177
-		<programlisting format="linespecific">
178
-...
179
-modparam("lrkproxy", "lrkproxy_tout", 2)
180
-...
181
-</programlisting>
182
-		</example>
183
-	</section>
184
-	<section id="lrkproxy.p.lrkproxy_retr">
185
-		<title><varname>lrkproxy_retr</varname> (integer)</title>
186
-		<para>
187
-		How many times the LRKP_CL should retry to send and receive after
188
-		timeout was generated.
189
-		</para>
58
+		</section>
190 59
 		<para>
191
-		<emphasis>
192
-			Default value is <quote>5</quote>.
193
-		</emphasis>
60
+			The LRKP_CL and LRKP-TSL could be run as
61
+			independence functions on different machines. We
62
+			could have one LRKP_CL with multiple LRKP-TSL
63
+			on different machines. The LRKP_CL could works
64
+			with all LRKP-TSL with different strategies(lrkp_alg parameter).
194 65
 		</para>
195
-		<example>
196
-		<title>Set <varname>lrkproxy_retr</varname> parameter</title>
197
-		<programlisting format="linespecific">
198
-...
199
-modparam("lrkproxy", "lrkproxy_retr", 2)
200
-...
201
-</programlisting>
202
-		</example>
203 66
 	</section>
204
-	<section id="lrkproxy.p.lrkp_alg">
205
-		<title><varname>lrkp_alg</varname> (integer)</title>
67
+	<section>
68
+		<title>Multiple LRKProxy usage</title>
206 69
 		<para>
207
-		This parameter set the algorithm of LRKP_TSL selection.
208
-    		lrk_LINER=0,
209
-    		lrk_RR=1
70
+			The LRKP_CL Layer can support multiple LRKP_TSL Layer
71
+			for balancing/distribution and control/selection purposes.
210 72
 		</para>
211 73
 		<para>
212
-		<emphasis>
213
-			Default value is <quote>0</quote>.
214
-		</emphasis>
215
-		</para>
216
-		<example>
217
-		<title>Set <varname>lrkp_alg</varname> parameter</title>
218
-		<programlisting format="linespecific">
219
-...
220
-modparam("lrkproxy", "lrkp_alg", 1)
221
-...
222
-</programlisting>
223
-		</example>
224
-	</section>
74
+			The module allows definition of several sets of LRKP_TSL.
75
+			Load-balancing will be performed over predefine algorithm by setting lrkp_alg parameter.
225 76
 
226
-	<section id="lrkproxy.p.hash_table_tout">
227
-		<title><varname>hash_table_tout</varname> (integer)</title>
228
-		<para>
229
-		Number of seconds after an lrkproxy hash table entry is marked for
230
-   		deletion. By default, this parameter is set to 3600 (seconds).
231
-		</para>
232
-		<para>
233
-		To maintain information about a selected rtp machine node, for a given
234
-		call, entries are added in a hashtable of (callid, viabranch) pairs. When
235
-   		command comes, lookup callid, viabranch pairs. If found, return chosen node. If not
236
-   		found, choose a new node, insert it in the hastable and return the
237
-   		chosen node.
238
-		</para>
239
-		<para>
240
-		NOTE: In the current implementation, the actual deletion happens on the
241
-		fly, while insert/remove/lookup the hastable, only for the entries in
242
-		the insert/remove/lookup path.
243
-		</para>
244
-		<para>
245
-		NOTE: When configuring this parameter, one should consider maximum call
246
-		time VS share memory for unfinished calls.
247
-		</para>
248
-		<para>
249
-		<emphasis>
250
-			Default value is <quote>3600</quote>.
251
-		</emphasis>
252
-		</para>
253
-		<example>
254
-		<title>Set <varname>hash_table_tout</varname> parameter</title>
255
-		<programlisting format="linespecific">
256
-...
257
-modparam("lrkproxy", "hash_table_tout", "3600")
258
-...
259
-</programlisting>
260
-		</example>
261
-	</section>
262
-	<section id="lrkproxy.p.hash_table_size">
263
-		<title><varname>hash_table_size</varname> (integer)</title>
264
-		<para>
265
-		Size of the hash table. Default value is 128.
266 77
 		</para>
267 78
 		<para>
268
-		<emphasis>
269
-			Default value is <quote>128</quote>.
270
-		</emphasis>
79
+			IMPORTANT: This module does not support balancing inside a set like as is done RTPProxy module based on
80
+			the weight of each rtpproxy from the set. The balancing would be run on different machine
271 81
 		</para>
272
-		<example>
273
-		<title>Set <varname>hash_table_size</varname> parameter</title>
274
-		<programlisting format="linespecific">
275
-...
276
-modparam("lrkproxy", "hash_table_size", 256)
277
-...
278
-</programlisting>
279
-		</example>
280
-	</section>
281 82
 	</section>
83
+
282 84
 	<section>
283
-	<title>Functions</title>
284
-	<section id="lrkproxy.f.set_lrkproxy_set">
285
-		<title>
286
-		<function moreinfo="none">set_lrkproxy_set(setid)</function>
287
-		</title>
288
-		<para>
289
-		Sets the Id of the lrkproxy set to be used for the next
290
-   		lrkproxy_manage() command. The parameter can be an integer or a config
291
-   		variable holding an integer.
292
-		</para>
293
-		<para>
294
-		This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
295
-		BRANCH_ROUTE.
296
-		</para>
297
-		<example>
298
-		<title><function>set_lrkproxy_set</function> usage</title>
299
-		<programlisting format="linespecific">
300
-...
301
-set_lrkproxy_set("0");
302
-lrkproxy_manage();
303
-...
304
-</programlisting>
305
-		</example>
306
-	</section>
307
-        <section id="lrkproxy.f.lrkproxy_manage">
308
-                <title>
309
-                <function moreinfo="none">lrkproxy_manage([flags [, ip_address]])</function>
310
-                </title>
311
-                <para>
312
-                Manage the LRKProxy session - it combines the functionality of
313
-   		lrkproxy_offer(), lrkproxy_answer() and unforce_lrkproxy(), detecting
314
-   		internally based on message type and method which one to execute.
315
-                </para>
316
-		<para>
317
-		   IMPORTANT:The LRKProxy just has one function relating rtp packets. 
318
-		   It does not support combination of functionality of lrkproxy_offer(),
319
-		   lrkproxy_answer() and unforce_lrkproxy() and other etc.
320
-		   So you have to just use lrkproxy_manage.
321
-		</para>
322
-		<para>Meaning of the parameters is as follows:</para>
323
-		<itemizedlist>
324
-		<listitem>
85
+		<title>Dependencies</title>
86
+		<section>
87
+			<title>&kamailio; Modules</title>
325 88
 			<para>
326
-			<emphasis>flags</emphasis> - flags to turn on some features.
89
+				The following modules must be loaded before this module:
90
+				<itemizedlist>
91
+					<listitem>
92
+						<para>
93
+							<emphasis>tm module</emphasis> - (optional) if you want to
94
+							have lrkproxy_manage() fully functional
95
+						</para>
96
+					</listitem>
97
+				</itemizedlist>
327 98
 			</para>
328
-			<itemizedlist>
329
-				<listitem><para>
330
-				<emphasis>internal,external</emphasis> - The shorthand of this flag is "ie".
331
-				This can be used to relay media sessions between two different NIC from internal to external path.
332
-				</para></listitem>
333
-			</itemizedlist>
334
-			<itemizedlist>
335
-				<listitem><para>
336
-				<emphasis>external,internal</emphasis> - The shorthand of this flag is "ei".
337
-				This can be used to relay media sessions between two different NIC from external to internal path.
338
-				</para></listitem>
339
-			</itemizedlist>
340
-		</listitem>
341
-		<listitem><para>
342
-		<emphasis>ip_address</emphasis> - new SDP IP address.This optional parameter is under development.
343
-		</para></listitem>
344
-		</itemizedlist>
345
-		<para>
346
-		This function can be used from ANY_ROUTE.
347
-                </para>
348
-		<example>
349
-		<title><function>lrkproxy_manage</function> usage</title>
350
-		<programlisting format="linespecific">
351
-...
352
-lrkproxy_manage();
353
-//or
354
-lrkproxy_manage("ie");
355
-//or
356
-lrkproxy_manage("ei");
99
+		</section>
100
+		<section>
101
+			<title>External Libraries or Applications</title>
102
+			<para>
103
+				The following libraries or applications must be installed before
104
+				running &kamailio; with this module loaded:
105
+				<itemizedlist>
106
+					<listitem>
107
+						<para>
108
+							<emphasis>None</emphasis>.
109
+						</para>
110
+					</listitem>
111
+				</itemizedlist>
112
+			</para>
113
+		</section>
114
+		<section>
115
+			<title>Parameters</title>
116
+			<section id="lrkproxy.p.lrkproxy_sock">
117
+				<title><varname>lrkproxy_sock</varname> (string)</title>
118
+				<para>
119
+					Used to define the list of LRKP_TSL instances to connect to. These can
120
+					be UNIX sockets or IPv4/IPv6 UDP sockets. Each modparam entry will
121
+					insert sockets into a single set with default value set ID '0'.
122
+					To define multiple LRKP_TSL, just add the instances in each modparam.
123
+				</para>
124
+				<para>
125
+					<emphasis>
126
+						Default value is <quote>NONE</quote> (disabled).
127
+					</emphasis>
128
+				</para>
129
+				<example>
130
+					<title>Set <varname>lrkproxy_sock</varname> parameter</title>
131
+					<programlisting format="linespecific">
132
+						...
133
+						# single lrkproxy
134
+						modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
357 135
 
358
-...
359
-</programlisting>
360
-                </example>
361
-	</section>
136
+						# multiple lrkproxies for LB in diffenrent machine
137
+						modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.108:8080")
138
+						modparam("lrkproxy", "lrkproxy_sock", "udp:192.168.122.109:8080")
362 139
 
140
+						...
141
+					</programlisting>
142
+				</example>
143
+			</section>
144
+			<section id="lrkproxy.p.lrkproxy_disable_tout">
145
+				<title><varname>lrkproxy_disable_tout</varname> (integer)</title>
146
+				<para>
147
+					Once LRKP_TSL was found unreachable and marked as disabled, the
148
+					LRKP_CL module will not attempt to establish communication to LRKP_TSL
149
+					for lrkproxy_disable_tout seconds.
150
+				</para>
151
+				<para>
152
+					<emphasis>
153
+						Default value is <quote>60</quote>.
154
+					</emphasis>
155
+				</para>
156
+				<example>
157
+					<title>Set <varname>lrkproxy_disable_tout</varname> parameter</title>
158
+					<programlisting format="linespecific">
159
+						...
160
+						modparam("lrkproxy", "lrkproxy_disable_tout", 20)
161
+						...
162
+					</programlisting>
163
+				</example>
164
+			</section>
165
+			<section id="lrkproxy.p.lrkproxy_tout">
166
+				<title><varname>lrkproxy_tout</varname> (integer)</title>
167
+				<para>
168
+					Timeout value in waiting for reply from LRKP_TSL.
169
+				</para>
170
+				<para>
171
+					<emphasis>
172
+						Default value is <quote>1</quote>.
173
+					</emphasis>
174
+				</para>
175
+				<example>
176
+					<title>Set <varname>lrkproxy_tout</varname> parameter</title>
177
+					<programlisting format="linespecific">
178
+						...
179
+						modparam("lrkproxy", "lrkproxy_tout", 2)
180
+						...
181
+					</programlisting>
182
+				</example>
183
+			</section>
184
+			<section id="lrkproxy.p.lrkproxy_retr">
185
+				<title><varname>lrkproxy_retr</varname> (integer)</title>
186
+				<para>
187
+					How many times the LRKP_CL should retry to send and receive after
188
+					timeout was generated.
189
+				</para>
190
+				<para>
191
+					<emphasis>
192
+						Default value is <quote>5</quote>.
193
+					</emphasis>
194
+				</para>
195
+				<example>
196
+					<title>Set <varname>lrkproxy_retr</varname> parameter</title>
197
+					<programlisting format="linespecific">
198
+						...
199
+						modparam("lrkproxy", "lrkproxy_retr", 2)
200
+						...
201
+					</programlisting>
202
+				</example>
203
+			</section>
204
+			<section id="lrkproxy.p.lrkp_alg">
205
+				<title><varname>lrkp_alg</varname> (integer)</title>
206
+				<para>
207
+					This parameter set the algorithm of LRKP_TSL selection.
208
+					lrk_LINER=0,
209
+					lrk_RR=1
210
+				</para>
211
+				<para>
212
+					<emphasis>
213
+						Default value is <quote>0</quote>.
214
+					</emphasis>
215
+				</para>
216
+				<example>
217
+					<title>Set <varname>lrkp_alg</varname> parameter</title>
218
+					<programlisting format="linespecific">
219
+						...
220
+						modparam("lrkproxy", "lrkp_alg", 1)
221
+						...
222
+					</programlisting>
223
+				</example>
224
+			</section>
363 225
 
226
+			<section id="lrkproxy.p.hash_table_tout">
227
+				<title><varname>hash_table_tout</varname> (integer)</title>
228
+				<para>
229
+					Number of seconds after an lrkproxy hash table entry is marked for
230
+					deletion. By default, this parameter is set to 3600 (seconds).
231
+				</para>
232
+				<para>
233
+					To maintain information about a selected rtp machine node, for a given
234
+					call, entries are added in a hashtable of (callid, viabranch) pairs. When
235
+					command comes, lookup callid, viabranch pairs. If found, return chosen node. If not
236
+					found, choose a new node, insert it in the hastable and return the
237
+					chosen node.
238
+				</para>
239
+				<para>
240
+					NOTE: In the current implementation, the actual deletion happens on the
241
+					fly, while insert/remove/lookup the hastable, only for the entries in
242
+					the insert/remove/lookup path.
243
+				</para>
244
+				<para>
245
+					NOTE: When configuring this parameter, one should consider maximum call
246
+					time VS share memory for unfinished calls.
247
+				</para>
248
+				<para>
249
+					<emphasis>
250
+						Default value is <quote>3600</quote>.
251
+					</emphasis>
252
+				</para>
253
+				<example>
254
+					<title>Set <varname>hash_table_tout</varname> parameter</title>
255
+					<programlisting format="linespecific">
256
+						...
257
+						modparam("lrkproxy", "hash_table_tout", "3600")
258
+						...
259
+					</programlisting>
260
+				</example>
261
+			</section>
262
+
263
+
264
+
265
+			<section id="lrkproxy.p.hash_table_size">
266
+				<title><varname>hash_table_size</varname> (integer)</title>
267
+				<para>
268
+					Size of the hash table. Default value is 128.
269
+				</para>
270
+				<para>
271
+					<emphasis>
272
+						Default value is <quote>128</quote>.
273
+					</emphasis>
274
+				</para>
275
+				<example>
276
+					<title>Set <varname>hash_table_size</varname> parameter</title>
277
+					<programlisting format="linespecific">
278
+						...
279
+						modparam("lrkproxy", "hash_table_size", 256)
280
+						...
281
+					</programlisting>
282
+				</example>
283
+			</section>
284
+
285
+			<section id="lrkproxy.p.custom_sdp_ip_avp">
286
+				<title><varname>custom_sdp_ip_avp</varname> (string)</title>
287
+				<para>
288
+					This option useful for solving STUN and help UDP packets make it across NAT devices safe and sound.
289
+					In this way, it should be set by clients's ip public manually.
290
+				</para>
291
+				<para>
292
+					<emphasis>
293
+						Default value is <quote>NULL</quote>.
294
+					</emphasis>
295
+				</para>
296
+				<example>
297
+					<title>Set <varname>custom_sdp_ip_avp</varname> parameter</title>
298
+					<programlisting format="linespecific">
299
+						...
300
+						modparam("lrkproxy", "custom_sdp_ip_avp", "$avp(RR_CUSTOM_SDP_IP_AVP)")
301
+						...
302
+					</programlisting>
303
+				</example>
304
+			</section>
305
+
306
+			<section id="lrkproxy.p.gt">
307
+				<title><varname>gt</varname> (integer)</title>
308
+				<para>
309
+					This option useful for optimization in allocation port resource in lrkproxy service.
310
+				</para>
311
+				<para>
312
+					<emphasis>
313
+						Default value is <quote>0</quote>.
314
+					</emphasis>
315
+				</para>
316
+				<example>
317
+					<title>Set <varname>gt</varname> parameter</title>
318
+					<programlisting format="linespecific">
319
+						...
320
+						modparam("lrkproxy", "gt", "1")
321
+						...
322
+					</programlisting>
323
+				</example>
324
+			</section>
325
+
326
+
327
+
328
+
329
+
330
+		</section>
331
+		<section>
332
+			<title>Functions</title>
333
+			<section id="lrkproxy.f.set_lrkproxy_set">
334
+				<title>
335
+					<function moreinfo="none">set_lrkproxy_set(setid)</function>
336
+				</title>
337
+				<para>
338
+					Sets the Id of the lrkproxy set to be used for the next
339
+					lrkproxy_manage() command. The parameter can be an integer or a config
340
+					variable holding an integer.
341
+				</para>
342
+				<para>
343
+					This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
344
+					BRANCH_ROUTE.
345
+				</para>
346
+				<example>
347
+					<title><function>set_lrkproxy_set</function> usage</title>
348
+					<programlisting format="linespecific">
349
+						...
350
+						set_lrkproxy_set("0");
351
+						lrkproxy_manage();
352
+						...
353
+					</programlisting>
354
+				</example>
355
+			</section>
356
+			<section id="lrkproxy.f.lrkproxy_manage">
357
+				<title>
358
+					<function moreinfo="none">lrkproxy_manage([flags [, ip_address]])</function>
359
+				</title>
360
+				<para>
361
+					Manage the LRKProxy session - it combines the functionality of
362
+					lrkproxy_offer(), lrkproxy_answer() and unforce_lrkproxy(), detecting
363
+					internally based on message type and method which one to execute.
364
+				</para>
365
+				<para>
366
+					IMPORTANT:The LRKProxy just has one function relating rtp packets.
367
+					It does not support combination of functionality of lrkproxy_offer(),
368
+					lrkproxy_answer() and unforce_lrkproxy() and other etc.
369
+					So you have to just use lrkproxy_manage.
370
+				</para>
371
+				<para>Meaning of the parameters is as follows:</para>
372
+				<itemizedlist>
373
+					<listitem>
374
+						<para>
375
+							<emphasis>flags</emphasis> - flags to turn on some features.
376
+						</para>
377
+						<itemizedlist>
378
+							<listitem><para>
379
+								<emphasis>internal,external</emphasis> - The shorthand of this flag is "ie".
380
+								This can be used to relay media sessions between two different NIC from internal to external path.
381
+							</para></listitem>
382
+						</itemizedlist>
383
+						<itemizedlist>
384
+							<listitem><para>
385
+								<emphasis>external,internal</emphasis> - The shorthand of this flag is "ei".
386
+								This can be used to relay media sessions between two different NIC from external to internal path.
387
+							</para></listitem>
388
+						</itemizedlist>
389
+					</listitem>
390
+					<listitem><para>
391
+						<emphasis>ip_address</emphasis> - new SDP IP address.This optional parameter is under development.
392
+					</para></listitem>
393
+				</itemizedlist>
394
+				<para>
395
+					This function can be used from ANY_ROUTE.
396
+				</para>
397
+				<example>
398
+					<title><function>lrkproxy_manage</function> usage</title>
399
+					<programlisting format="linespecific">
400
+						...
401
+						lrkproxy_manage();
402
+						//or
403
+						lrkproxy_manage("ie");
404
+						//or
405
+						lrkproxy_manage("ei");
406
+
407
+						...
408
+					</programlisting>
409
+				</example>
410
+			</section>
411
+
412
+
413
+		</section>
364 414
 	</section>
365
-	</section>
366
-</chapter>
415
+</chapter>
367 416
\ No newline at end of file
... ...
@@ -169,6 +169,18 @@ int lrkp_algorithm = LRK_LINER;
169 169
 static int hash_table_size = 0;
170 170
 static int hash_table_tout = 3600;
171 171
 
172
+/*!< The gt is game-theory variable, It could be set 0:disable and 1:enable
173
+ * default is 0.
174
+ */
175
+int gt = 0;
176
+
177
+/*
178
+ * the custom_sdp_ip_spec variable is used for specific SDP information based $si (source address)
179
+ * */
180
+static str custom_sdp_ip_spec = {NULL, 0};
181
+pv_spec_t custom_sdp_ip_avp;
182
+
183
+
172 184
 
173 185
 
174 186
 //static char *ice_candidate_priority_avp_param = NULL;
... ...
@@ -220,6 +232,8 @@ static param_export_t params[] = {
220 232
         {"lrkp_alg",         INT_PARAM, &lrkp_algorithm         },
221 233
         {"hash_table_tout",       INT_PARAM, &hash_table_tout        },
222 234
         {"hash_table_size",       INT_PARAM, &hash_table_size        },
235
+        {"custom_sdp_ip_avp",     PARAM_STR, &custom_sdp_ip_spec},
236
+        {"gt",   INT_PARAM  , &gt},
223 237
 
224 238
         {0, 0, 0}
225 239
 };
... ...
@@ -609,6 +623,18 @@ mod_init(void)
609 623
         memset(&tmb, 0, sizeof(struct tm_binds));
610 624
     }
611 625
 
626
+    if (custom_sdp_ip_spec.s) {
627
+        if (pv_parse_spec(&custom_sdp_ip_spec, &custom_sdp_ip_avp) == 0
628
+            && (custom_sdp_ip_avp.type != PVT_AVP)) {
629
+                    LM_ERR("malformed or non AVP custom_sdp_ip "
630
+                                   "AVP definition in '%.*s'\n", custom_sdp_ip_spec.len,custom_sdp_ip_spec.s);
631
+            return -1;
632
+        }
633
+    }
634
+
635
+    init_custom_sdp_ip(custom_sdp_ip_spec.s ? &custom_sdp_ip_avp : 0);
636
+
637
+
612 638
     return 0;
613 639
 }
614 640
 
... ...
@@ -1261,7 +1287,10 @@ static int change_media_sdp(sip_msg_t *msg, struct lrkproxy_hash_entry *e, const
1261 1287
         unsigned int snat_port;
1262 1288
 
1263 1289
         str2int(&e->dst_port, &snat_port);
1264
-        snat_port += 2;
1290
+
1291
+        /*check if gt is enable or not*/
1292
+        if (!gt)
1293
+            snat_port += 2;
1265 1294
 
1266 1295
         current_port.s = int2str(snat_port, &current_port.len);
1267 1296
 
... ...
@@ -1555,6 +1584,7 @@ static int lrkproxy_force(struct sip_msg *msg, const char *flags, enum lrk_opera
1555 1584
 
1556 1585
         //fill src_ipv4 and src_port for entry.
1557 1586
         str src_ipv4;
1587
+
1558 1588
         if (get_sdp_ipaddr_media(msg, &src_ipv4) == -1) {
1559 1589
                     LM_ERR("can't get media src_ipv4 from sdp field\n");
1560 1590
             return -1;
... ...
@@ -1618,9 +1648,12 @@ static int lrkproxy_force(struct sip_msg *msg, const char *flags, enum lrk_opera
1618 1648
 
1619 1649
         if (node->lrkp_n_c->current_port >= node->lrkp_n_c->end_port)
1620 1650
             node->lrkp_n_c->current_port = node->lrkp_n_c->start_port;
1621
-        else
1622
-            node->lrkp_n_c->current_port += 4;
1623
-
1651
+        else {
1652
+            if (gt)
1653
+                node->lrkp_n_c->current_port += 2;
1654
+            else
1655
+                node->lrkp_n_c->current_port += 4;
1656
+        }
1624 1657
     } else if (op == OP_ANSWER) {
1625 1658
                 LM_INFO ("Here is SIP_REPLY of METHOD_INVITE\n");
1626 1659
 
... ...
@@ -42,6 +42,9 @@
42 42
 #include "../../core/parser/parser_f.h"
43 43
 #include "../../core/parser/sdp/sdp_helpr_funcs.h"
44 44
 
45
+static pv_spec_t *custom_sdp_ip_avp;		/*!< AVP for custom_sdp_ip setting */
46
+
47
+
45 48
 #define READ(val) \
46 49
 	(*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
47 50
 #define advance(_ptr,_n,_str,_error) \
... ...
@@ -407,6 +410,25 @@ int get_sdp_ipaddr_media(struct sip_msg *msg, str *ip_addr) {
407 410
         return -1;
408 411
     }
409 412
 
413
+    char *s = ip_addr2a(&msg->rcv.src_ip);
414
+            LM_INFO("=========>msg->rcv.src_ip:%s\n", s);
415
+//            LM_INFO("=========>msg->contact-body:%.*s\n", msg->contact->body.len, msg->contact->body.s);
416
+//            LM_INFO("=========>msg->contact-name:%.*s\n", msg->contact->name.len, msg->contact->name.s);
417
+
418
+    pv_value_t pv_val;
419
+    if (custom_sdp_ip_avp) {
420
+        if ((pv_get_spec_value(msg, custom_sdp_ip_avp, &pv_val) == 0)
421
+            && (pv_val.flags & PV_VAL_STR) && (pv_val.rs.len > 0)) {
422
+            ip_addr->s = pv_val.rs.s;
423
+            ip_addr->len = pv_val.rs.len;
424
+                    LM_INFO("=========>custom_sdp_ip_avp:%.*s\n",   ip_addr->len,   ip_addr->s);
425
+
426
+            return 0;
427
+        }
428
+        else
429
+                LM_DBG("invalid AVP value, using default user from RURI\n");
430
+    }
431
+
410 432
 
411 433
     int sdp_session_num = 0;
412 434
     sdp_session = get_sdp_session(msg, sdp_session_num);
... ...
@@ -418,9 +440,11 @@ int get_sdp_ipaddr_media(struct sip_msg *msg, str *ip_addr) {
418 440
 
419 441
     if (sdp_session->ip_addr.s && sdp_session->ip_addr.len > 0) {
420 442
                 LM_INFO("sdp_session->ip_addr:%.*s\n", sdp_session->ip_addr.len, sdp_session->ip_addr.s);
443
+
421 444
         ip_addr->s = sdp_session->ip_addr.s;
422 445
         ip_addr->len = sdp_session->ip_addr.len;
423 446
         trim(ip_addr);
447
+
424 448
     }
425 449
     else {
426 450
         int sdp_stream_num = 0;
... ...
@@ -477,3 +501,8 @@ int get_sdp_port_media(struct sip_msg *msg, str *port){
477 501
 
478 502
 }
479 503
 
504
+void init_custom_sdp_ip(pv_spec_t *custom_sdp_ip_avp_p)
505
+{
506
+    custom_sdp_ip_avp = custom_sdp_ip_avp_p;
507
+
508
+}
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 
26 26
 #include "../../core/str.h"
27
+#include "../../core/pvar.h"
27 28
 #include "../../core/parser/msg_parser.h"
28 29
 #include "../../core/parser/contact/contact.h"
29 30
 
... ...
@@ -36,6 +37,7 @@ int get_contact_uri(struct sip_msg *, struct sip_uri *, contact_t **);
36 37
 int get_via_branch(struct sip_msg *, int, str *);
37 38
 int get_sdp_ipaddr_media(struct sip_msg *msg, str *ip_addr);
38 39
 int get_sdp_port_media(struct sip_msg *msg, str *port);
40
+void init_custom_sdp_ip(pv_spec_t *custom_sdp_ip_avp_p);
39 41
 
40 42
 
41 43
 #endif //_LRKPROXY_FUNCS_H
... ...
@@ -365,7 +365,12 @@ int lrkproxy_hash_table_remove(str callid, str viabranch, enum lrk_operation op)
365 365
     while (entry) {
366 366
         // if callid found, delete entry
367 367
         if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) ||
368
-            (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) {
368
+            (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE) ||
369
+            str_equal(entry->callid, callid)){
370
+            //if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) ||
371
+            //    (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) {
372
+            // set pointers; exclude entry
373
+
369 374
             // set pointers; exclude entry
370 375
             last_entry->next = entry->next;
371 376