rtpproxy_admin.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. This is a module that enables media streams to be proxied
  15. via an rtpproxy.
  16. </para>
  17. <para>
  18. Known devices that get along over &nat;s with rtpproxy are ATAs
  19. (as clients) and Cisco Gateways (since 12.2(T)) as servers. See <ulink
  20. url="http://www.cisco.com/en/US/products/sw/iosswrel/ps1839/products_feature_guide09186a0080110bf9.html">
  21. http://www.cisco.com/en/US/products/sw/iosswrel/ps1839/products_feature_guide09186a0080110bf9.html"></ulink>
  22. </para>
  23. </section>
  24. <section>
  25. <title>Multiple RTPProxy usage</title>
  26. <para>
  27. Currently, the rtpproxy module can support multiple rtpproxies for
  28. balancing/distribution and control/selection purposes.
  29. </para>
  30. <para>
  31. The module allows the definition of several sets of rtpproxies -
  32. load-balancing will be performed over a set and the user has the
  33. ability to choose what set should be used. The set is selected via
  34. its id - the id being defined along with the set. Refer to the
  35. <quote>rtpproxy_sock</quote> module parameter definition for syntax
  36. description.
  37. </para>
  38. <para>
  39. The balancing inside a set is done automatically by the module based on
  40. the weight of each rtpproxy from the set.
  41. </para>
  42. <para>
  43. The selection of the set is done from script prior using
  44. unforce_rtp_proxy(), rtpproxy_offer() or rtpproxy_answer()
  45. functions - see the set_rtp_proxy_set() function.
  46. </para>
  47. <para>
  48. For backward compatibility reasons, a set with no id take by default
  49. the id 0. Also if no set is explicitly set before
  50. unforce_rtp_proxy(), rtpproxy_offer() or rtpproxy_answer()
  51. the 0 id set will be used.
  52. </para>
  53. <para>
  54. IMPORTANT: if you use multiple sets, take care and use the same set for
  55. both rtpproxy_offer()/rtpproxy_answer() and unforce_rtpproxy()!!
  56. </para>
  57. </section>
  58. <section>
  59. <title>Dependencies</title>
  60. <section>
  61. <title>&kamailio; Modules</title>
  62. <para>
  63. The following modules must be loaded before this module:
  64. <itemizedlist>
  65. <listitem>
  66. <para>
  67. <emphasis>None</emphasis>
  68. </para>
  69. </listitem>
  70. </itemizedlist>
  71. </para>
  72. </section>
  73. <section>
  74. <title>External Libraries or Applications</title>
  75. <para>
  76. The following libraries or applications must be installed before
  77. running &kamailio; with this module loaded:
  78. <itemizedlist>
  79. <listitem>
  80. <para>
  81. <emphasis>None</emphasis>.
  82. </para>
  83. </listitem>
  84. </itemizedlist>
  85. </para>
  86. </section>
  87. </section>
  88. <section>
  89. <title>Exported Parameters</title>
  90. <section>
  91. <title><varname>rtpproxy_sock</varname> (string)</title>
  92. <para>
  93. Definition of socket(s) used to connect to (a set) RTPProxy. It may
  94. specify a UNIX socket or an IPv4/IPv6 UDP socket.
  95. </para>
  96. <para>
  97. <emphasis>
  98. Default value is <quote>NONE</quote> (disabled).
  99. </emphasis>
  100. </para>
  101. <example>
  102. <title>Set <varname>rtpproxy_sock</varname> parameter</title>
  103. <programlisting format="linespecific">
  104. ...
  105. # single rtproxy
  106. modparam("rtpproxy", "rtpproxy_sock", "udp:localhost:12221")
  107. # multiple rtproxies for LB
  108. modparam("rtpproxy", "rtpproxy_sock",
  109. "udp:localhost:12221 udp:localhost:12222")
  110. # multiple sets of multiple rtproxies
  111. modparam("rtpproxy", "rtpproxy_sock",
  112. "1 == udp:localhost:12221 udp:localhost:12222")
  113. modparam("rtpproxy", "rtpproxy_sock",
  114. "2 == udp:localhost:12225")
  115. ...
  116. </programlisting>
  117. </example>
  118. </section>
  119. <section>
  120. <title><varname>rtpproxy_disable_tout</varname> (integer)</title>
  121. <para>
  122. Once RTPProxy was found unreachable and marked as disable, rtpproxy
  123. will not attempt to establish communication to RTPProxy for
  124. rtpproxy_disable_tout seconds.
  125. </para>
  126. <para>
  127. <emphasis>
  128. Default value is <quote>60</quote>.
  129. </emphasis>
  130. </para>
  131. <example>
  132. <title>Set <varname>rtpproxy_disable_tout</varname> parameter</title>
  133. <programlisting format="linespecific">
  134. ...
  135. modparam("rtpproxy", "rtpproxy_disable_tout", 20)
  136. ...
  137. </programlisting>
  138. </example>
  139. </section>
  140. <section>
  141. <title><varname>rtpproxy_tout</varname> (integer)</title>
  142. <para>
  143. Timeout value in waiting for reply from RTPProxy.
  144. </para>
  145. <para>
  146. <emphasis>
  147. Default value is <quote>1</quote>.
  148. </emphasis>
  149. </para>
  150. <example>
  151. <title>Set <varname>rtpproxy_tout</varname> parameter</title>
  152. <programlisting format="linespecific">
  153. ...
  154. modparam("rtpproxy", "rtpproxy_tout", 2)
  155. ...
  156. </programlisting>
  157. </example>
  158. </section>
  159. <section>
  160. <title><varname>rtpproxy_retr</varname> (integer)</title>
  161. <para>
  162. How many times rtpproxy should retry to send and receive after
  163. timeout was generated.
  164. </para>
  165. <para>
  166. <emphasis>
  167. Default value is <quote>5</quote>.
  168. </emphasis>
  169. </para>
  170. <example>
  171. <title>Set <varname>rtpproxy_retr</varname> parameter</title>
  172. <programlisting format="linespecific">
  173. ...
  174. modparam("rtpproxy", "rtpproxy_retr", 2)
  175. ...
  176. </programlisting>
  177. </example>
  178. </section>
  179. <section>
  180. <title><varname>force_socket</varname> (string)</title>
  181. <para>
  182. Socket to be forced in communicating to RTPProxy. It makes sense only
  183. for UDP communication. If no one specified, the OS will choose.
  184. </para>
  185. <para>
  186. <emphasis>
  187. Default value is <quote>NULL</quote>.
  188. </emphasis>
  189. </para>
  190. <example>
  191. <title>Set <varname>force_socket</varname> parameter</title>
  192. <programlisting format="linespecific">
  193. ...
  194. modparam("rtpproxy", "force_socket", "localhost:33333")
  195. ...
  196. </programlisting>
  197. </example>
  198. </section>
  199. <section>
  200. <title><varname>nortpproxy_str</varname> (string)</title>
  201. <para>
  202. The parameter sets the SDP attribute used by rtpproxy to mark
  203. the packet SDP informations have already been mangled.
  204. </para>
  205. <para>
  206. If empty string, no marker will be added or checked.
  207. </para>
  208. <note><para>
  209. The string must be a complete SDP line, including the EOH (\r\n).
  210. </para></note>
  211. <para>
  212. <emphasis>
  213. Default value is <quote>a=nortpproxy:yes\r\n</quote>.
  214. </emphasis>
  215. </para>
  216. <example>
  217. <title>Set <varname>nortpproxy_str</varname> parameter</title>
  218. <programlisting format="linespecific">
  219. ...
  220. modparam("rtpproxy", "nortpproxy_str", "a=sdpmangled:yes\r\n")
  221. ...
  222. </programlisting>
  223. </example>
  224. </section>
  225. <section>
  226. <title><varname>timeout_socket</varname> (string)</title>
  227. <para>
  228. The parameter sets timeout socket, which is transmitted to the RTP-Proxy.
  229. </para>
  230. <para>
  231. If it is an empty string, no timeout socket will be transmitted to the RTP-Proxy.
  232. </para>
  233. <para>
  234. <emphasis>
  235. Default value is <quote></quote> (nothing).
  236. </emphasis>
  237. </para>
  238. <example>
  239. <title>Set <varname>timeout_socket</varname> parameter</title>
  240. <programlisting format="linespecific">
  241. ...
  242. modparam("nathelper", "timeout_socket", "xmlrpc:http://127.0.0.1:8000/RPC2")
  243. ...
  244. </programlisting>
  245. </example>
  246. </section>
  247. </section>
  248. <section>
  249. <title>Exported Functions</title>
  250. <section>
  251. <title>
  252. <function moreinfo="none">set_rtp_proxy_set()</function>
  253. </title>
  254. <para>
  255. Sets the Id of the rtpproxy set to be used for the next
  256. unforce_rtp_proxy(), rtpproxy_offer() or rtpproxy_answer()
  257. command.
  258. </para>
  259. <para>
  260. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  261. BRANCH_ROUTE.
  262. </para>
  263. <example>
  264. <title><function>fix_nated_contact</function> usage</title>
  265. <programlisting format="linespecific">
  266. ...
  267. set_rtp_proxy_set("2");
  268. rtpproxy_offer();
  269. ...
  270. </programlisting>
  271. </example>
  272. </section>
  273. <section>
  274. <title>
  275. <function moreinfo="none">rtpproxy_offer([flags [, ip_address]])</function>
  276. </title>
  277. <para>
  278. Rewrites &sdp; body to ensure that media is passed through
  279. an &rtp; proxy. To be invoked
  280. on INVITE for the cases the SDPs are in INVITE and 200 OK and on 200 OK
  281. when SDPs are in 200 OK and ACK.
  282. </para>
  283. <para>Meaning of the parameters is as follows:</para>
  284. <itemizedlist>
  285. <listitem>
  286. <para>
  287. <emphasis>flags</emphasis> - flags to turn on some features.
  288. </para>
  289. <itemizedlist>
  290. <listitem><para>
  291. <emphasis>a</emphasis> - flags that UA from which message is
  292. received doesn't support symmetric RTP. (automatically sets the 'r' flag)
  293. </para></listitem>
  294. <listitem><para>
  295. <emphasis>l</emphasis> - force <quote>lookup</quote>, that is,
  296. only rewrite SDP when corresponding session is already exists
  297. in the RTP proxy. By default is on when the session is to be
  298. completed.
  299. </para></listitem>
  300. <listitem><para>
  301. <emphasis>i, e</emphasis> - these flags specify the direction of the SIP
  302. message. These flags only make sense when rtpproxy is running in bridge mode.
  303. 'i' means internal network (LAN), 'e' means external network (WAN). 'i'
  304. corresponds to rtpproxy's first interface, 'e' corresponds to rtpproxy's
  305. second interface. You always have to specify two flags to define
  306. the incoming network and the outgoing network. For example, 'ie' should be
  307. used for SIP message received from the local interface and sent out on the
  308. external interface, and 'ei' vice versa. Other options are 'ii' and 'ee'.
  309. So, for example if a SIP requests is processed with 'ie' flags, the corresponding
  310. response must be processed with 'ie' flags.
  311. </para><para>
  312. Note: As rtpproxy is in bridge mode per default asymmetric, you have to specify
  313. the 'w' flag for clients behind NAT! See also above notes!
  314. </para></listitem>
  315. <listitem><para>
  316. <emphasis>f</emphasis> - instructs rtpproxy to ignore marks
  317. inserted by another rtpproxy in transit to indicate that the
  318. session is already goes through another proxy. Allows creating
  319. chain of proxies.
  320. </para></listitem>
  321. <listitem><para>
  322. <emphasis>r</emphasis> - flags that IP address in SDP should
  323. be trusted. Without this flag, rtpproxy ignores address in
  324. the SDP and uses source address of the SIP message as media
  325. address which is passed to the RTP proxy.
  326. </para></listitem>
  327. <listitem><para>
  328. <emphasis>o</emphasis> - flags that IP from the origin
  329. description (o=) should be also changed.
  330. </para></listitem>
  331. <listitem><para>
  332. <emphasis>c</emphasis> - flags to change the session-level
  333. SDP connection (c=) IP if media-description also includes
  334. connection information.
  335. </para></listitem>
  336. <listitem><para>
  337. <emphasis>w</emphasis> - flags that for the UA from which
  338. message is received, support symmetric RTP must be forced.
  339. </para></listitem>
  340. <listitem><para>
  341. <emphasis>zNN</emphasis> - requests the RTPproxy to perform
  342. re-packetization of RTP traffic coming from the UA which
  343. has sent the current message to increase or decrease payload
  344. size per each RTP packet forwarded if possible. The NN is the
  345. target payload size in ms, for the most codecs its value should
  346. be in 10ms increments, however for some codecs the increment
  347. could differ (e.g. 30ms for GSM or 20ms for G.723). The
  348. RTPproxy would select the closest value supported by the codec.
  349. This feature could be used for significantly reducing bandwith
  350. overhead for low bitrate codecs, for example with G.729 going
  351. from 10ms to 100ms saves two thirds of the network bandwith.
  352. </para></listitem>
  353. </itemizedlist>
  354. </listitem>
  355. <listitem><para>
  356. <emphasis>ip_address</emphasis> - new SDP IP address.
  357. </para></listitem>
  358. </itemizedlist>
  359. <para>
  360. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  361. FAILURE_ROUTE, BRANCH_ROUTE.
  362. </para>
  363. <example>
  364. <title><function>rtpproxy_offer</function> usage</title>
  365. <programlisting format="linespecific">
  366. route {
  367. ...
  368. if (is_method("INVITE")) {
  369. if (has_sdp()) {
  370. if (rtpproxy_offer())
  371. t_on_reply("1");
  372. } else {
  373. t_on_reply("2");
  374. }
  375. }
  376. if (is_method("ACK") &amp;&amp; has_sdp())
  377. rtpproxy_answer();
  378. ...
  379. }
  380. onreply_route[1]
  381. {
  382. ...
  383. if (has_sdp())
  384. rtpproxy_answer();
  385. ...
  386. }
  387. onreply_route[2]
  388. {
  389. ...
  390. if (has_sdp())
  391. rtpproxy_offer();
  392. ...
  393. }
  394. </programlisting>
  395. </example>
  396. </section>
  397. <section>
  398. <title>
  399. <function moreinfo="none">rtpproxy_answer([flags [, ip_address]])</function>
  400. </title>
  401. <para>
  402. Rewrites &sdp; body to ensure that media is passed through
  403. an &rtp; proxy. To be invoked
  404. on 200 OK for the cases the SDPs are in INVITE and 200 OK and on ACK
  405. when SDPs are in 200 OK and ACK.
  406. </para>
  407. <para>
  408. See rtpproxy_answer() function description above for the meaning of the
  409. parameters.
  410. </para>
  411. <para>
  412. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
  413. FAILURE_ROUTE, BRANCH_ROUTE.
  414. </para>
  415. <example>
  416. <title><function>rtpproxy_answer</function> usage</title>
  417. <para>
  418. See rtpproxy_offer() function example above for example.
  419. </para>
  420. </example>
  421. </section>
  422. <section>
  423. <title>
  424. <function moreinfo="none">unforce_rtp_proxy()</function>
  425. </title>
  426. <para>
  427. Tears down the RTPProxy session for the current call.
  428. </para>
  429. <para>
  430. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  431. </para>
  432. <example>
  433. <title><function>unforce_rtp_proxy</function> usage</title>
  434. <programlisting format="linespecific">
  435. ...
  436. unforce_rtp_proxy();
  437. ...
  438. </programlisting>
  439. </example>
  440. </section>
  441. <section id="rtpproxy_stream2xxx">
  442. <title>
  443. <function>rtpproxy_stream2uac(prompt_name, count)</function>,
  444. <function>rtpproxy_stream2uas(prompt_name, count)</function>
  445. </title>
  446. <para>
  447. Instruct the RTPproxy to stream prompt/announcement pre-encoded with
  448. the makeann command from the RTPproxy distribution. The uac/uas
  449. suffix selects who will hear the announcement relatively to the current
  450. transaction - UAC or UAS. For example invoking the
  451. <function>rtpproxy_stream2uac</function> in the request processing
  452. block on ACK transaction will play the prompt to the UA that has
  453. generated original INVITE and ACK while
  454. <function>rtpproxy_stop_stream2uas</function> on 183 in reply
  455. processing block will play the prompt to the UA that has generated 183.
  456. </para>
  457. <para>
  458. Apart from generating announcements, another possible application
  459. of this function is implementing music on hold (MOH) functionality.
  460. When count is -1, the streaming will be in loop indefinitely until
  461. the appropriate <function>rtpproxy_stop_stream2xxx</function> is issued.
  462. </para>
  463. <para>
  464. In order to work correctly, functions require that the session in the
  465. RTPproxy already exists. Also those functions don't alted SDP, so that
  466. they are not substitute for calling <function>rtpproxy_offer</function>
  467. or <function>rtpproxy_answer</function>.
  468. </para>
  469. <para>
  470. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE.
  471. </para>
  472. <para>Meaning of the parameters is as follows:</para>
  473. <itemizedlist>
  474. <listitem>
  475. <para>
  476. <emphasis>prompt_name</emphasis> - name of the prompt to
  477. stream. Should be either absolute pathname or pathname
  478. relative to the directory where RTPproxy runs.
  479. </para>
  480. </listitem>
  481. <listitem>
  482. <para>
  483. <emphasis>count</emphasis> - number of times the prompt
  484. should be repeated. The value of -1 means that it will
  485. be streaming in loop indefinitely, until appropriate
  486. <function>rtpproxy_stop_stream2xxx</function> is issued.
  487. </para>
  488. </listitem>
  489. </itemizedlist>
  490. <example>
  491. <title><function>rtpproxy_stream2xxx</function> usage</title>
  492. <programlisting>
  493. ...
  494. if (is_method("INVITE")) {
  495. rtpproxy_offer();
  496. if (detect_hold()) {
  497. rtpproxy_stream2uas("/var/rtpproxy/prompts/music_on_hold", "-1");
  498. } else {
  499. rtpproxy_stop_stream2uas();
  500. };
  501. };
  502. ...
  503. </programlisting>
  504. </example>
  505. </section>
  506. <section id="rtpproxy_stop_stream2xxx">
  507. <title>
  508. <function>rtpproxy_stop_stream2uac()</function>,
  509. <function>rtpproxy_stop_stream2uas()</function>
  510. </title>
  511. <para>
  512. Stop streaming of announcement/prompt/MOH started previously by the
  513. respective <function>rtpproxy_stream2xxx</function>. The uac/uas
  514. suffix selects whose announcement relatively to tha current
  515. transaction should be stopped - UAC or UAS.
  516. </para>
  517. <para>
  518. These functions can be used from REQUEST_ROUTE, ONREPLY_ROUTE.
  519. </para>
  520. </section>
  521. <section>
  522. <title>
  523. <function moreinfo="none">start_recording()</function>
  524. </title>
  525. <para>
  526. This command will send a signal to the RTP-Proxy to record
  527. the RTP stream on the RTP-Proxy.
  528. </para>
  529. <para>
  530. This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
  531. </para>
  532. <example>
  533. <title><function>start_recording</function> usage</title>
  534. <programlisting format="linespecific">
  535. ...
  536. start_recording();
  537. ...
  538. </programlisting>
  539. </example>
  540. </section>
  541. </section>
  542. <section>
  543. <title>Exported Pseudo Variables</title>
  544. <section>
  545. <title><function moreinfo="none">$rtpstart</function></title>
  546. <para>
  547. Returns the RTP-Statistics from the RTP-Proxy. The RTP-Statistics from the RTP-Proxy
  548. are provided as a string and it does contain several packet-counters. The statistics
  549. must be retrieved before the session is deleted (before unforce_rtpproxy).
  550. </para>
  551. <example>
  552. <title>$rtpstat-Usage</title>
  553. <programlisting format="linespecific">
  554. ...
  555. append_hf("X-RTP-Statistics: $rtpstat\r\n");
  556. ...
  557. </programlisting>
  558. </example>
  559. </section>
  560. </section>
  561. <section>
  562. <title><acronym>MI</acronym> Commands</title>
  563. <section>
  564. <title><function moreinfo="none">nh_enable_rtpp</function></title>
  565. <para>
  566. Enables a rtp proxy if parameter value is greater than 0.
  567. Disables it if a zero value is given.
  568. </para>
  569. <para>
  570. The first parameter is the rtp proxy url (exactly as defined in
  571. the config file).
  572. </para>
  573. <para>
  574. The second parameter value must be a number in decimal.
  575. </para>
  576. <para>
  577. NOTE: if a rtpproxy is defined multiple times (in the same or
  578. diferente sete), all its instances will be enables/disabled.
  579. </para>
  580. <example>
  581. <title>
  582. <function moreinfo="none">nh_enable_rtpp</function> usage</title>
  583. <programlisting format="linespecific">
  584. ...
  585. $ &ctltool; fifo nh_enable_rtpp udp:192.168.2.133:8081 0
  586. ...
  587. </programlisting>
  588. </example>
  589. </section>
  590. <section>
  591. <title><function moreinfo="none">nh_show_rtpp</function></title>
  592. <para>
  593. Displays all the rtp proxies and their information: set and
  594. status (disabled or not, weight and recheck_ticks).
  595. </para>
  596. <para>
  597. No parameter.
  598. </para>
  599. <example>
  600. <title>
  601. <function moreinfo="none">nh_show_rtpp</function> usage</title>
  602. <programlisting format="linespecific">
  603. ...
  604. $ &ctltool; fifo nh_show_rtpp
  605. ...
  606. </programlisting>
  607. </example>
  608. </section>
  609. </section>
  610. </chapter>