mediaproxy_admin.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. Mediaproxy is an &siprouter; module that is designed to allow automatic
  15. NAT traversal for the majority of existing SIP clients. This means
  16. that there will be no need to configure anything in particular on
  17. the NAT box to allow these clients to work behind NAT when using
  18. the mediaproxy module.
  19. </para>
  20. </section>
  21. <section>
  22. <title>Principle of operation</title>
  23. <para>
  24. This NAT traversal solution operates by placing a media relay in the
  25. middle between 2 SIP user-agents. It mangles the SDP messages for both
  26. of them in a way that will make the parties talk with the relay while
  27. they think they talk directly with each other.
  28. </para>
  29. <para>
  30. Mediaproxy consists of 2 components:
  31. <itemizedlist>
  32. <listitem>
  33. <para>The &siprouter; mediaproxy module</para>
  34. </listitem>
  35. <listitem>
  36. <para>
  37. An external application called MediaProxy which employs a
  38. dispatcher and multiple distributed media relays. This is
  39. available from http://ag-projects.com/MediaProxy.html
  40. (version 2.0.0 or newer is required by this module).
  41. </para>
  42. </listitem>
  43. </itemizedlist>
  44. </para>
  45. <para>
  46. The mediaproxy dispatcher runs on the same machine as &siprouter;
  47. and its purpose is to select a media relay for a call. The media
  48. relay may run on the same machine as the dispatcher or on multiple
  49. remote hosts and its purpose is to forward the streams between the
  50. calling parties. To find out more about the architecture of MediaProxy
  51. please read the documentation that comes with it.
  52. </para>
  53. <para>
  54. To be able to act as a relay between the 2 user agents, the machine(s)
  55. running the module/proxy server must have a public IP address.
  56. </para>
  57. <para>
  58. &siprouter; will ask the media relay to allocate as many ports as there are
  59. media streams in the SDP offer and answer. The media relay will send back
  60. to &siprouter; the IP address and port(s) for them. Then &siprouter; will
  61. replace the original contact IP and RTP ports from the SDP messages with
  62. the ones provided by the media relay. By doing this, both user agents will
  63. try to contact the media relay instead of communicating directly with each
  64. other. Once the user agents contact the media relay, it will record the
  65. addresses they came from and will know where to forward packets received
  66. from the other endpoint. This is needed because the address/port the NAT
  67. box will allocate for the media streams is not known before they actually
  68. leave the NAT box. However the address of the media relay is always known
  69. (being a public IP) so the 2 endpoints know where to connect. After they
  70. do so, the relay learns their addresses and can forward packets between
  71. them.
  72. </para>
  73. <para>
  74. The SIP clients that will work transparently behind NAT when using
  75. mediaproxy, are the so-called symmetric clients. The symmetric clients
  76. have the particularity that use the same port to send and receive data.
  77. This must be true for both signaling and media for a client to work
  78. transparently with mediaproxy without any configuration on the NAT box.
  79. </para>
  80. </section>
  81. <section>
  82. <title>Features</title>
  83. <para>
  84. <itemizedlist>
  85. <listitem>
  86. <para>
  87. make symmetric clients work behind NAT transparently, with no
  88. configuration needed on the client's NAT box.
  89. </para>
  90. </listitem>
  91. <listitem>
  92. <para>
  93. have the ability to distribute RTP traffic on multiple media relays
  94. running on multiple hosts.
  95. </para>
  96. </listitem>
  97. </itemizedlist>
  98. </para>
  99. </section>
  100. <section>
  101. <title>Dependencies</title>
  102. <section>
  103. <title>&siprouter; Modules</title>
  104. <para>
  105. The following modules must be loaded before this module:
  106. <itemizedlist>
  107. <listitem>
  108. <para>
  109. <emphasis>dialog</emphasis> module - if engage_media_proxy is used
  110. (see below the description of engage_media_proxy).
  111. </para>
  112. </listitem>
  113. </itemizedlist>
  114. </para>
  115. </section>
  116. <section>
  117. <title>External Libraries or Applications</title>
  118. <para>
  119. The following libraries or applications must be installed before
  120. running &siprouter; with this module loaded:
  121. <itemizedlist>
  122. <listitem>
  123. <para>
  124. <emphasis>Mediaproxy version 2.4.2 or higher (but not
  125. necessarily on the same host as &siprouter;)</emphasis>.
  126. </para>
  127. </listitem>
  128. </itemizedlist>
  129. </para>
  130. </section>
  131. </section>
  132. <section>
  133. <title>Exported parameters</title>
  134. <section>
  135. <title><varname>disable</varname> (int)</title>
  136. <para>
  137. Boolean flag that specifies if mediaproxy should be disabled. This
  138. is useful when you want to use the same openser configuration in
  139. two different context, one using mediaproxy, the other not. In the
  140. case mediaproxy is disabled, calls to its functions will have no
  141. effect, allowing you to use the same configuration without changes.
  142. </para>
  143. <para>
  144. <emphasis>
  145. Default value is <quote>0</quote>.
  146. </emphasis>
  147. </para>
  148. <example>
  149. <title>Setting the <varname>disable</varname> parameter</title>
  150. <programlisting format="linespecific">
  151. ...
  152. modparam("mediaproxy", "disable", 1)
  153. ...
  154. </programlisting>
  155. </example>
  156. </section>
  157. <section>
  158. <title><varname>mediaproxy_socket</varname> (string)</title>
  159. <para>
  160. It is the path to the filesystem socket where the mediaproxy dispatcher
  161. listens for commands from the module.
  162. </para>
  163. <para>
  164. <emphasis>
  165. Default value is
  166. <quote>/var/run/mediaproxy/dispatcher.sock</quote>.
  167. </emphasis>
  168. </para>
  169. <example>
  170. <title>Setting the <varname>mediaproxy_socket</varname> parameter</title>
  171. <programlisting format="linespecific">
  172. ...
  173. modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy/dispatcher.sock")
  174. ...
  175. </programlisting>
  176. </example>
  177. </section>
  178. <section>
  179. <title><varname>mediaproxy_timeout</varname> (int)</title>
  180. <para>
  181. How much time (in milliseconds) to wait for an answer from the
  182. mediaproxy dispatcher.
  183. </para>
  184. <para>
  185. <emphasis>
  186. Default value is <quote>500</quote>.
  187. </emphasis>
  188. </para>
  189. <example>
  190. <title>Setting the <varname>mediaproxy_timeout</varname> parameter</title>
  191. <programlisting format="linespecific">
  192. ...
  193. modparam("mediaproxy", "mediaproxy_timeout", 500)
  194. ...
  195. </programlisting>
  196. </example>
  197. </section>
  198. <section>
  199. <title><varname>signaling_ip_avp</varname> (string)</title>
  200. <para>
  201. Specification of the AVP which holds the IP address from where
  202. the SIP signaling originated. If this AVP is set it will be used
  203. to get the signaling IP address, else the source IP address
  204. from where the SIP message was received will be used.
  205. This AVP is meant to be used in cases where there are more than
  206. one proxy in the call setup path and the proxy that actually
  207. starts mediaproxy doesn't receive the SIP messages directly
  208. from the UA and it cannot determine the NAT IP address from
  209. where the signaling originated. In such a case attaching a
  210. SIP header at the first proxy and then copying that header's
  211. value into the signaling_ip_avp on the proxy that starts
  212. mediaproxy will allow it to get the correct NAT IP address
  213. from where the SIP signaling originated.
  214. </para>
  215. <para>
  216. <emphasis>
  217. Default value is <quote>$avp(signaling_ip)</quote>.
  218. </emphasis>
  219. </para>
  220. <example>
  221. <title>Setting the <varname>signaling_ip_avp</varname> parameter</title>
  222. <programlisting format="linespecific">
  223. ...
  224. modparam("mediaproxy", "signaling_ip_avp", "$avp(nat_ip)")
  225. ...
  226. </programlisting>
  227. </example>
  228. </section>
  229. <section>
  230. <title><varname>media_relay_avp</varname> (string)</title>
  231. <para>
  232. Specification of the AVP which holds an optional application
  233. defined media relay IP address of a particular media relay that
  234. is preferred to be used for the current call. If an IP address
  235. is written to this AVP before calling use_media_proxy(), it
  236. will be preferred by the dispatcher over the normal selection
  237. algorithm.
  238. </para>
  239. <para>
  240. <emphasis>
  241. Default value is <quote>$avp(media_relay)</quote>.
  242. </emphasis>
  243. </para>
  244. <example>
  245. <title>Setting the <varname>media_relay_avp</varname> parameter</title>
  246. <programlisting format="linespecific">
  247. ...
  248. modparam("mediaproxy", "media_relay_avp", "$avp(media_relay)")
  249. ...
  250. </programlisting>
  251. </example>
  252. </section>
  253. <section>
  254. <title><varname>ice_candidate</varname> (string)</title>
  255. <para>
  256. Indicates the type of ICE candidate that will be added to the SDP.
  257. It can take 3 values: 'none', 'low-priority' or 'high-priority'.
  258. If 'none' is selected no candidate will be adeed to the SDP. If
  259. 'low-priority' is selected then a low priority candidate will be
  260. added and if 'high-priority' is selected a high priority one.
  261. </para>
  262. <para>
  263. <emphasis>
  264. Default value is <quote>none</quote>.
  265. </emphasis>
  266. </para>
  267. <example>
  268. <title>Setting the <varname>ice_candidate</varname> parameter</title>
  269. <programlisting format="linespecific">
  270. ...
  271. modparam("mediaproxy", "ice_candidate", "low-priority")
  272. ...
  273. </programlisting>
  274. </example>
  275. </section>
  276. <section>
  277. <title><varname>ice_candidate_avp</varname> (string)</title>
  278. <para>
  279. Specification of the AVP which holds the ICE candidate that will be
  280. inserted in the SDP. The value specified in this AVP will override
  281. the value in ice_candidate module parameter. If the AVP
  282. is not set, the default value will be used.
  283. </para>
  284. <para>
  285. <emphasis>
  286. Default value is <quote>$avp(ice_candidate)</quote>.
  287. </emphasis>
  288. </para>
  289. <example>
  290. <title>Setting the <varname>ice_candidate_avp</varname> parameter</title>
  291. <programlisting format="linespecific">
  292. ...
  293. modparam("mediaproxy", "ice_candidate_avp", "$avp(ice_candidate)")
  294. ...
  295. </programlisting>
  296. </example>
  297. </section>
  298. </section>
  299. <section>
  300. <title>Functions</title>
  301. <section>
  302. <title><function moreinfo="none">engage_media_proxy()</function></title>
  303. <para>
  304. Trigger the use of MediaProxy for all the dialog requests and
  305. replies that have an SDP body. This needs to be called only
  306. once for the first INVITE in a dialog. After that it will use
  307. the dialog module to trace the dialog and automatically call
  308. use_media_proxy() on every request and reply that belongs to
  309. the dialog and has an SDP body. When the dialog ends it will
  310. also call automatically end_media_session(). All of these are
  311. called internally on dialog callbacks, so for this function to
  312. work, the dialog module must be loaded and configured.
  313. </para>
  314. <para>
  315. This function is an advanced mechanism to use a media relay
  316. without having to manually call a function on each message that
  317. belongs to the dialog. However this method is less flexible,
  318. because once things were set in motion by calling this function
  319. on the first INVITE, it cannot be stopped, not even by calling
  320. end_media_session(). It will only stop when the dialog ends.
  321. Until then it will modify the SDP content of every in-dialog
  322. message to make it use a media relay. If one needs more control
  323. over the process, like starting to use mediaproxy only later in
  324. the failure route, or stopping to use mediaproxy in the failure
  325. route, then the use_media_proxy and end_media_session functions
  326. should be used, and manually called as appropriate. Using this
  327. function should NOT be mixed with either of use_media_proxy()
  328. or end_media_session().
  329. </para>
  330. <para>
  331. This function can be used from REQUEST_ROUTE.
  332. </para>
  333. <example>
  334. <title>Using the <function>engage_media_proxy</function> function</title>
  335. <programlisting format="linespecific">
  336. ...
  337. if (method==INVITE &amp;&amp; !has_totag()) {
  338. # We can also use a specific media relay if we need to
  339. #$avp(media_relay) = "1.2.3.4";
  340. engage_media_proxy();
  341. }
  342. ...
  343. </programlisting>
  344. </example>
  345. </section>
  346. <section>
  347. <title><function moreinfo="none">use_media_proxy()</function></title>
  348. <para>
  349. Will make a call to the dispatcher and replace the IPs and ports
  350. in the SDP body with the ones returned by the media relay for
  351. each supported media stream in the SDP body. This will force the
  352. media streams to be routed through the media relay. If a mix of
  353. supported and unsupported streams are present in the SDP, only
  354. the supported streams will be modified, while the unsupported
  355. streams will be left alone.
  356. </para>
  357. <para>
  358. This function should NOT be mixed with engage_media_proxy().
  359. </para>
  360. <para>This function has the following return codes:</para>
  361. <para>
  362. <itemizedlist>
  363. <listitem><para>
  364. +1 - successfully modified message (true value)
  365. </para></listitem>
  366. <listitem><para>
  367. -1 - error in processing message (false value)
  368. </para></listitem>
  369. <listitem><para>
  370. -2 - missing SDP body, nothing to process (false value)
  371. </para></listitem>
  372. </itemizedlist>
  373. </para>
  374. <para>
  375. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  376. </para>
  377. <example>
  378. <title>Using the <function>use_media_proxy</function> function</title>
  379. <programlisting format="linespecific">
  380. ...
  381. if (method==INVITE) {
  382. # We can also use a specific media relay if we need to
  383. #$avp(media_relay) = "1.2.3.4";
  384. use_media_proxy();
  385. }
  386. ...
  387. </programlisting>
  388. </example>
  389. </section>
  390. <section>
  391. <title><function moreinfo="none">end_media_session()</function></title>
  392. <para>
  393. Will call on the dispatcher to inform the media relay to end the
  394. media session. This is done when a call ends, to instruct the media
  395. relay to release the resources allocated to that call as well as
  396. to save logging information about the media session. Called on BYE,
  397. CANCEL or failures.
  398. </para>
  399. <para>
  400. This function should NOT be mixed with engage_media_proxy().
  401. </para>
  402. <para>
  403. This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
  404. </para>
  405. <example>
  406. <title>Using the <function>end_media_session</function> function</title>
  407. <programlisting format="linespecific">
  408. ...
  409. if (method==BYE) {
  410. end_media_session();
  411. }
  412. ...
  413. </programlisting>
  414. </example>
  415. </section>
  416. </section>
  417. </chapter>