Debian Codegraph @

Xpjproject/pjnath/docs/doc_turn.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 /**
21 @defgroup PJNATH_TURN TURN: Traversal Using Relays around NAT
22 @brief TURN protocol implementation
23 @ingroup PJNATH
24
25 \section turn_intro_sec Introduction to TURN
26
27 When a direct communication path cannot be found, it is necessary to
28 use the services of an intermediate host that acts as a relay for the
29 packets. This relay typically sits in the public Internet and relays
30 packets between two hosts that both sit behind NATs.
31
32 TURN allows a host behind a NAT (called the TURN client) to request that
33 another host (called the TURN server) act as a relay. The client can
34 arrange for the server to relay packets to and from certain other hosts
35 (called peers) and can control aspects of how the relaying is done.
36 The client does this by obtaining an IP address and port on the
37 server, called the relayed-transport-address. When a peer sends a
38 packet to the relayed-transport-address, the server relays the packet
39 to the client. When the client sends a data packet to the server,
40 the server relays it to the appropriate peer using the relayed-
41 transport-address as the source.
42
43
44 \section turn_op_sec Overview of TURN operations
45
46 <b>Discovering TURN server</b>.\n
47 Client learns the IP address of the TURN
48 server either through some privisioning or by querying DNS SRV records
49 for TURN service for the specified domain. Client may use UDP or TCP (or
50 TLS) to connect to the TURN server.
51
52 <b>Authentication</b>.\n
53 All TURN operations requires the use of authentication
54 (it uses STUN long term autentication method), hence client must be
55 configured with the correct credential to use the service.
56
57 <b>Allocation</b>.\n
58 Client creates one "relay port" (or called <b>relayed-transport-address</b>
59 in TURN terminology) in the TURN server by sending TURN \a Allocate request,
60 hence this process is called creating allocation. Once the allocation is
61 successful, client will be given the IP address and port of the "relay
62 port" in the Allocate response.
63
64 <b>Sending data through the relay</b>.\n
65 Once allocation has been created, client may send data to any remote
66 endpoints (called peers in TURN terminology) via the "relay port". It does
67 so by sending Send Indication to the TURN server, giving the peer address
68 in the indication message. But note that at this point peers are not allowed
69 to send data towards the client (via the "relay port") before permission is
70 installed for that peer.
71
72 <b>Creating permissions</b>.\n
73 Permission needs to be created in the TURN server so that a peer can send
74 data to the client via the relay port (a peer in this case is identified by
75 its IP address). Without this, when the TURN server receives data from the
76 peer in the "relay port", it will drop this data.
77
78 <b>Receiving data from peers</b>.\n
79 Once permission has been installed for the peer, any data received by the
80 TURN server (from that peer) in the "relay port" will be relayed back to
81 client by using Data Indication.
82
83 <b>Using ChannelData</b>.\n
84 TURN provides optimized framing to the data by using ChannelData
85 packetization. The client activates this format by sending ChannelBind
86 request to the TURN server, which provides (channel) binding which maps a
87 particular peer address with a channel number. Data sent or received to/for
88 this peer will then use ChannelData format instead of Send or Data
89 Indications.
90
91 <b>Refreshing the allocation, permissions, and channel bindings</b>.\n
92 Allocations, permissions, and channel bindings need to be refreshed
93 periodically by client, or otherwise they will expire.
94
95 <b>Destroying the allocation</b>.\n
96 Once the "relay port" is no longer needed, client destroys the allocation
97 by sending Refresh request with LIFETIME attribute set to zero.
98
99
100 \section turn_org_sec Library organizations
101
102 The TURN functionalities in PJNATH primarily consist of
103 \ref PJNATH_TURN_SOCK and \ref PJNATH_TURN_SESSION. Please see more
104 below.
105
106
107 \section turn_using_sec Using TURN transport
108
109 The \ref PJNATH_TURN_SOCK is a ready to use object for relaying
110 application data via a TURN server, by managing all the operations
111 above.
112
113 Among other things it provides the following features:
114 - resolution of the TURN server with DNS SRV
115 - interface to create allocation, permissions, and channel
116 bindings
117 - interface to send and receive packets through the relay
118 - provides callback to notify the application about incoming data
119 - managing the allocation, permissions, and channel bindings
120
121 Please see \ref PJNATH_TURN_SOCK for more documentation about and
122 on how to use this object.
123
124
125 \section turn_owntransport_sec Creating custom TURN transport
126
127 The \ref PJNATH_TURN_SESSION is a transport-independent object to
128 manage a client TURN session. It contains the core logic for managing
129 the TURN client session as listed in TURN operations above, but
130 in transport-independent manner (i.e. it doesn't have a socket), so
131 that developer can integrate TURN client functionality into existing
132 framework that already has its own means to send and receive data,
133 or to support new transport types to TURN, such as TLS.
134
135 You can create your own (custom) TURN transport by wrapping this
136 into your own object, and provide it with the means to send and
137 receive packets.
138
139 Please see \ref PJNATH_TURN_SESSION for more information.
140
141
142 \section turn_samples_sec Samples
143
144 The \ref turn_client_sample is a sample application to use the
145 \ref PJNATH_TURN_SOCK. Also there is a sample TURN server in
146 the distribution as well.
147
148 Also see <b>\ref samples_page</b> for other samples.
149
150 */
151
152
153 /**
154 * @defgroup PJNATH_TURN_SOCK TURN client transport
155 * @brief Client transport utilizing TURN relay
156 * @ingroup PJNATH_TURN
157 */
158
159 /**
160 * @defgroup PJNATH_TURN_SESSION TURN client session
161 * @brief Transport independent TURN client session
162 * @ingroup PJNATH_TURN
163 */