| 1 | |
|---|
| 2 | MediaProxy |
|---|
| 3 | ---------- |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 2008 AG Projects |
|---|
| 6 | http://ag-projects.com |
|---|
| 7 | |
|---|
| 8 | Authors: Ruud Klaver, Dan Pascu |
|---|
| 9 | |
|---|
| 10 | Home page: http://www.ag-projects.com/MediaProxy.html |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | License |
|---|
| 14 | ------- |
|---|
| 15 | |
|---|
| 16 | This software is licensed according to the GNU General Public License |
|---|
| 17 | version 2. See LICENSE file for more details. |
|---|
| 18 | |
|---|
| 19 | For other licensing options please contact sales-request@ag-projects.com |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | Description |
|---|
| 23 | ----------- |
|---|
| 24 | |
|---|
| 25 | MediaProxy is a media relay for RTP/RTCP and UDP streams that works in |
|---|
| 26 | tandem with OpenSIPS to provide NAT traversal capability for media streams |
|---|
| 27 | from SIP user agents located behind NAT. |
|---|
| 28 | |
|---|
| 29 | When using MediaProxy, NAT traversal for RTP media will work without any |
|---|
| 30 | settings in the SIP User Agents or the NAT router. |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | Features |
|---|
| 34 | -------- |
|---|
| 35 | |
|---|
| 36 | - Scalability of thousands of calls per server limited only by the Linux |
|---|
| 37 | kernel networking layer and network interface bandwidth |
|---|
| 38 | - Supports multiple chained relays as long as each has a public IP |
|---|
| 39 | - TLS encryption between the relays and dispatcher |
|---|
| 40 | - T.38 fax support |
|---|
| 41 | - Graceful shutdown capability |
|---|
| 42 | - Modular design for custom selection algorithms for the relay location |
|---|
| 43 | - Automatic load balancing and redundancy among all media relays |
|---|
| 44 | - Real-time sessions statistics |
|---|
| 45 | - Configurable IP and UDP port range |
|---|
| 46 | - Support for any combination of audio and video streams |
|---|
| 47 | - Ability to use OpenSIPS' MI interface to close a call that did timeout |
|---|
| 48 | - Radius accounting of IP network traffic |
|---|
| 49 | - Database accounting of complete media information including all streams, |
|---|
| 50 | their type, codecs and duration. |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | Background |
|---|
| 54 | ----------- |
|---|
| 55 | |
|---|
| 56 | MediaProxy 2.0 is the second generation media relay application which is |
|---|
| 57 | based on a completely new design that allows for major improvements in areas |
|---|
| 58 | such as scalability (an order of magnitude more scalable than previous |
|---|
| 59 | version) and security (communication between relay and dispatcher is |
|---|
| 60 | encrypted). |
|---|
| 61 | |
|---|
| 62 | New features have been added to support call flows related to user mobility |
|---|
| 63 | and fax transmission. |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | Architecture |
|---|
| 67 | ------------ |
|---|
| 68 | |
|---|
| 69 | MediaProxy consists of a dispatcher and one or more media relays. |
|---|
| 70 | |
|---|
| 71 | The dispatcher component always runs on the same host as OpenSIPS and |
|---|
| 72 | communicates with its mediaproxy module through a UNIX domain socket. The |
|---|
| 73 | relay(s) connect to the dispatcher using TLS. This relay component may be on |
|---|
| 74 | the same or on a different host as OpenSIPS. There may be several relays for |
|---|
| 75 | the dispatcher to choose from and a relay may service more than one |
|---|
| 76 | dispatcher. |
|---|
| 77 | |
|---|
| 78 | When OpenSIPS requests that a call be relayed, the dispatcher will forward |
|---|
| 79 | this request to one of its connected relays, along with some data from the |
|---|
| 80 | SDP. The relay will allocate a set of UDP ports for this session, depending |
|---|
| 81 | on the number of proposed streams. It will inform the dispatcher which ports |
|---|
| 82 | it has allocated so that it may in turn notify the mediaproxy module of |
|---|
| 83 | OpenSIPS, which will replace the relevant parts of the SDP. |
|---|
| 84 | |
|---|
| 85 | The same is done for any SIP messages from the callee, thus all the media |
|---|
| 86 | streams will be sent through the relay. When the session between caller and |
|---|
| 87 | callee has finished, either through a SIP BYE or because the media is no |
|---|
| 88 | longer flowing and has timed out, the relay will send session information to |
|---|
| 89 | the dispatcher, which can store this information using one or more accounting |
|---|
| 90 | modules. |
|---|
| 91 | |
|---|
| 92 | The session information may also be queried using a management interface on |
|---|
| 93 | the dispatcher. |
|---|
| 94 | |
|---|
| 95 | All of this is illustrated in the following diagram: |
|---|
| 96 | |
|---|
| 97 | +---+ +---+ |
|---|
| 98 | | | +---------------------+ | | |
|---|
| 99 | | | | SIP Proxy | | | |
|---|
| 100 | | | | +----------+ | SIP | | |
|---|
| 101 | | |<--+->| OpenSIPS |<------+------------------->| | |
|---|
| 102 | | | | +----------+ | | | |
|---|
| 103 | | | | ^ | | | |
|---|
| 104 | | | | | UNIX socket | | | |
|---|
| 105 | | C | | v | | C | |
|---|
| 106 | | A | | +------------+ | +------------+ | A | |
|---|
| 107 | | L | | | Dispatcher |<-----+-->| Management | | L | |
|---|
| 108 | | L | | +------------+ TCP | | client | | L | |
|---|
| 109 | | E | | ^ /TLS | +------------+ | E | |
|---|
| 110 | | R | | | | | E | |
|---|
| 111 | | | +---------+-----------+ | | |
|---|
| 112 | | | | | | |
|---|
| 113 | | | | TLS | | |
|---|
| 114 | | | v | | |
|---|
| 115 | | | +-------------+ UDP | | |
|---|
| 116 | | |<---->| Relay |<----------------------->| | |
|---|
| 117 | | | +-------------+ RTP / RTCP | | |
|---|
| 118 | +---+ +---+ |
|---|
| 119 | |
|---|
| 120 | Please note that the accounting modules are not shown. |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | Compatibility and pre-requisites |
|---|
| 124 | -------------------------------- |
|---|
| 125 | |
|---|
| 126 | To run the software, you will need a server running the Linux Operating |
|---|
| 127 | System using a kernel version 2.6.18 or higher that has been compiled with |
|---|
| 128 | connection tracking support (conntrack). Because of this dependency on |
|---|
| 129 | Linux, other operating systems are not supported. This dependency only |
|---|
| 130 | applies to the media relay component. The dispatcher component which runs on |
|---|
| 131 | the same host as OpenSIPS, can run on any platform that has a python |
|---|
| 132 | interpreter and supports the twisted framework. |
|---|
| 133 | |
|---|
| 134 | Communication between the dispatcher and the relays uses TLS encryption and |
|---|
| 135 | requires a set of X509 certificates to work. For more information about this |
|---|
| 136 | please read tls/README which contains information about the sample certificates |
|---|
| 137 | that are included as well as information about how to generate your own. |
|---|
| 138 | |
|---|
| 139 | MediaProxy is meant to be used together with OpenSIPS' mediaproxy module. |
|---|
| 140 | |
|---|
| 141 | This version of MediaProxy (2.0 or higher) cannot be used in combination |
|---|
| 142 | with any version of OpenSIPS older than 1.4 or any components of MediaProxy |
|---|
| 143 | older than 2.0. You must completely upgrade any previous installation of |
|---|
| 144 | OpenSER to OpenSIPS to use this version of MediaProxy. |
|---|
| 145 | |
|---|
| 146 | No STUN or TURN support are required in the clients. |
|---|
| 147 | |
|---|
| 148 | The SIP User Agents must work symmetrically (that is to send and receive |
|---|
| 149 | data on the same port for each stream), which is documented in RFC 4961. |
|---|
| 150 | |
|---|
| 151 | To display the history of the media streams CDRTool 6.5 or higher is |
|---|
| 152 | required. |
|---|
| 153 | |
|---|
| 154 | Some features that were present in the previous version have been removed: |
|---|
| 155 | |
|---|
| 156 | - Support for specifying media relays per domain has been discontinued |
|---|
| 157 | - Support for DNS records has been discontinued |
|---|
| 158 | - Support for asymmetric clients has been discontinued |
|---|
| 159 | - Support for other operating systems than Linux has been discontinued |
|---|
| 160 | (only for the media relay, as the dispatcher has no such limitation) |
|---|
| 161 | |
|---|
| 162 | For information of how to install MediaProxy, please consult the INSTALL |
|---|
| 163 | file. |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | Operation |
|---|
| 167 | --------- |
|---|
| 168 | |
|---|
| 169 | Before the relay is run, please make sure that /proc/sys/net/ipv4/ip_forward |
|---|
| 170 | is set to "1". |
|---|
| 171 | |
|---|
| 172 | Both the dispatcher and the relay should be executed with root privileges. |
|---|
| 173 | With no arguments, both applications will automatically fork into the |
|---|
| 174 | background and log to syslog. They can remain in the foreground and log to |
|---|
| 175 | console when given the --no-fork argument. |
|---|
| 176 | |
|---|
| 177 | The relay can be shut down in two ways. When receiving either an INT or TERM |
|---|
| 178 | signal, the relay will terminate all of its sessions immediately and inform |
|---|
| 179 | the dispatcher that those sessions have expired. When given the HUP signal, |
|---|
| 180 | it will not accept any new sessions from the dispatcher and wait for all of |
|---|
| 181 | the running sessions to expire, thus terminating gracefully. |
|---|
| 182 | |
|---|
| 183 | At the very least a set of TLS credentials is required. Sample certificates |
|---|
| 184 | for this are included in the tls/ subdirectory. |
|---|
| 185 | DO NOT USE THESE IN A PRODUCTION ENVIRONMENT, but only for testing purposes. |
|---|
| 186 | |
|---|
| 187 | For more information about TLS certificates and how to generate your own, |
|---|
| 188 | check the tls/README file. |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | Accounting |
|---|
| 192 | ---------- |
|---|
| 193 | |
|---|
| 194 | MediaProxy is capable to do additional per call accounting with information |
|---|
| 195 | related to the media streams used by the call. MediaProxy has a modular |
|---|
| 196 | interface to the accounting system, allowing for new modules to be easily |
|---|
| 197 | implemented. Currently it supports database and radius backends. Multiple |
|---|
| 198 | backends can be configured and used simultaneously. |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | Radius accounting |
|---|
| 202 | ----------------- |
|---|
| 203 | |
|---|
| 204 | The radius backend logs very basic information about the media streams. The |
|---|
| 205 | limited nature of the logged information is mainly given by the limitations |
|---|
| 206 | imposed by the radius protocol to the data size. |
|---|
| 207 | |
|---|
| 208 | The information sent in the radius packet is shown below: |
|---|
| 209 | |
|---|
| 210 | Acct-Status-Type = "Update" |
|---|
| 211 | User-Name = "mediaproxy@default" |
|---|
| 212 | Acct-Session-Id = call_id |
|---|
| 213 | Sip-From-Tag = from_tag |
|---|
| 214 | Sip-To-Tag = to_tag |
|---|
| 215 | Acct-Session-Time = call duration |
|---|
| 216 | Acct-Input-Octets = bytes received from caller |
|---|
| 217 | Acct-Output-Octets = bytes received from callee |
|---|
| 218 | NAS-IP-Address = media-relay address |
|---|
| 219 | Sip-User-Agents = caller + callee user agents |
|---|
| 220 | Sip-Applications = "Audio", "Video", ... |
|---|
| 221 | Media-Codecs = codecs used by streams (comma separated) |
|---|
| 222 | Media-Info = "timeout" or "" |
|---|
| 223 | Acct-Delay-Time = post dial delay (seconds from INVITE to 1st media packet) |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | Database accounting |
|---|
| 227 | ------------------- |
|---|
| 228 | |
|---|
| 229 | The database backend logs all the information related to the media streams that |
|---|
| 230 | were created/closed during the whole session. This information is stored as a |
|---|
| 231 | JSON encoded string in a BLOB column in the database, along with the call_id, |
|---|
| 232 | from_tag and to_tag columns that can be used to retrieve the media information |
|---|
| 233 | for a given call. The database table and column names are fully configurable |
|---|
| 234 | in the database section of the configuration file. |
|---|
| 235 | |
|---|
| 236 | The table used to store these records, is automatically created by the media |
|---|
| 237 | dispatcher on startup, if it's not present. For this to happen, the user that |
|---|
| 238 | is configured in the dburi option in the database section, must have the CREATE |
|---|
| 239 | and ALTER rights on the database specified in the same dburi. If this is not |
|---|
| 240 | possible, then the media dispatcher will log an error indicating why it could |
|---|
| 241 | not create the table and also output the table definition that can be used by |
|---|
| 242 | some human operator to manually create the table. However, the recommended |
|---|
| 243 | way is to grant the CREATE and ALTER privileges to the user in the dburi over |
|---|
| 244 | the database specified in the same dburi. |
|---|
| 245 | |
|---|
| 246 | The database module uses SQLObject to access the database, which means it can |
|---|
| 247 | work with a lot of databases, by simply changing the scheme in the dburi. |
|---|
| 248 | Currently the following databases are supported: mysql, postgres, sqlite, |
|---|
| 249 | firebird, maxdb, mssql and sybase. |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | Closing expired calls |
|---|
| 253 | --------------------- |
|---|
| 254 | |
|---|
| 255 | Starting with version 2.1.0, MediaProxy supports closing calls for which all |
|---|
| 256 | the media streams did timeout, but for which no BYE was received to close the |
|---|
| 257 | call in the standard way. |
|---|
| 258 | |
|---|
| 259 | This feature will only work, when the OpenSIPS mediaproxy module uses the |
|---|
| 260 | engage_media_proxy() command to start MediaProxy for a given call. In this |
|---|
| 261 | case the mediaproxy module uses the dialog module to keep track of the call |
|---|
| 262 | and can pass the dialog id to the media dispatcher. When a media session is |
|---|
| 263 | expired because all streams did timeout, but no closing request was received |
|---|
| 264 | from the proxy, the media dispatcher will use the dialog id that was received |
|---|
| 265 | from the mediaproxy module, to issue a dlg_end_dlg request into the OpenSIPS' |
|---|
| 266 | MI interface, instructing OpenSIPS to generate the BYEs for the call, closing |
|---|
| 267 | it in a clean way and generating the accounting records. |
|---|
| 268 | |
|---|
| 269 | To use this, the mi_datagram module must be loaded and configured to use a |
|---|
| 270 | UNIX filesystem socket which must also be configured into the OpenSIPS section |
|---|
| 271 | of the MediaProxy configuration as socket_path. |
|---|
| 272 | |
|---|
| 273 | This feature is not available when using the use_media_proxy/end_media_session |
|---|
| 274 | functions in the proxy configuration, because in that case there is no dialog |
|---|
| 275 | that is tracked by the proxy which could be terminated using dlg_end_dlg. |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | Management interface |
|---|
| 279 | -------------------- |
|---|
| 280 | |
|---|
| 281 | The management interface will accept commands terminated by \r\n. It will |
|---|
| 282 | return the results of the command, one per line, terminated by an empty |
|---|
| 283 | line (also \r\n terminated). |
|---|
| 284 | |
|---|
| 285 | Currently two commands are supported: |
|---|
| 286 | |
|---|
| 287 | sessions : This will have the dispatcher query all of its connected relays |
|---|
| 288 | for active sessions. For every sessions it finds it will return |
|---|
| 289 | one line with a JSON encoded dictionary containing session |
|---|
| 290 | information. |
|---|
| 291 | |
|---|
| 292 | summary : This will have the dispatcher present a summary of each of its |
|---|
| 293 | connected relays. The results are returned as a JSON encoded |
|---|
| 294 | dictionary, one line per relay. |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | Free support |
|---|
| 298 | ------------ |
|---|
| 299 | |
|---|
| 300 | MediaProxy is developed and supported by AG Projects. AG Projects offers |
|---|
| 301 | best-effort free support for MediaProxy. "best-effort" means that we try to |
|---|
| 302 | solve the bugs you report or help fix your problems as soon as we can, |
|---|
| 303 | subject to available resources. |
|---|
| 304 | |
|---|
| 305 | You may report bugs or feature request to: |
|---|
| 306 | |
|---|
| 307 | users@lists.opensips.org |
|---|
| 308 | |
|---|
| 309 | A mailing list archive is available at: |
|---|
| 310 | http://lists.opensips.org/cgi-bin/mailman/listinfo/users |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | Commercial support |
|---|
| 314 | ------------------ |
|---|
| 315 | |
|---|
| 316 | Commercial support options are available by purchasing: |
|---|
| 317 | |
|---|
| 318 | 1. Multimedia Service Platform: http://ag-projects.com/Products or |
|---|
| 319 | 2. MediaProxy and support: https://secure.dns-hosting.info/buyer_guide.phtml |
|---|