No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0046.xml 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM "xep.ent">
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>DTCP</title>
  10. <abstract>Direct TCP connection between two Jabber entities.</abstract>
  11. &LEGALNOTICE;
  12. <number>0046</number>
  13. <status>Retracted</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies/>
  17. <supersedes/>
  18. <supersededby><spec>XEP-0065</spec></supersededby>
  19. <shortname>None</shortname>
  20. <author>
  21. <firstname>Justin</firstname>
  22. <surname>Karneges</surname>
  23. <email>justin@affinix.com</email>
  24. <jid>justin@andbit.net</jid>
  25. </author>
  26. <revision>
  27. <version>0.8</version>
  28. <date>2003-04-11</date>
  29. <initials>psa</initials>
  30. <remark>At the request of the author, changed status to Retracted.</remark>
  31. </revision>
  32. <revision>
  33. <version>0.7</version>
  34. <date>2002-12-10</date>
  35. <initials>jk</initials>
  36. <remark>Remove 'comment' block</remark>
  37. </revision>
  38. <revision>
  39. <version>0.6</version>
  40. <date>2002-12-02</date>
  41. <initials>jk</initials>
  42. <remark>Simplification of the document</remark>
  43. </revision>
  44. <revision>
  45. <version>0.5</version>
  46. <date>2002-11-19</date>
  47. <initials>jk</initials>
  48. <remark>Changed handshake and namespace, merged active/passive</remark>
  49. </revision>
  50. <revision>
  51. <version>0.4</version>
  52. <date>2002-10-10</date>
  53. <initials>jk</initials>
  54. <remark>Change to 'comment' block</remark>
  55. </revision>
  56. <revision>
  57. <version>0.3</version>
  58. <date>2002-09-18</date>
  59. <initials>jk</initials>
  60. <remark>Support for SSL</remark>
  61. </revision>
  62. <revision>
  63. <version>0.2</version>
  64. <date>2002-09-18</date>
  65. <initials>jk</initials>
  66. <remark>Simplified things.</remark>
  67. </revision>
  68. <revision>
  69. <version>0.1</version>
  70. <date>2002-09-12</date>
  71. <initials>jk</initials>
  72. <remark>Initial version.</remark>
  73. </revision>
  74. </header>
  75. <section1 topic='Introduction'>
  76. <p>There are cases where it would be more optimal for clients to exchange data directly with each other rather than through the server. DTCP specifies a method for establishing a direct TCP socket connection between two entities, so that a reliable bytestream can be created out-of-band.</p>
  77. </section1>
  78. <section1 topic='Requirements'>
  79. <p>The following design goals are considered:</p>
  80. <ul>
  81. <li>The protocol should be reasonably effective in scenarios involving NAT and/or firewalls.<note>DTCP works in situations where at least one client can accept incoming connections.</note></li>
  82. <li>It should be reasonably secure.</li>
  83. <li>Establishing a connection should be fast.</li>
  84. <li>The protocol should be simple.</li>
  85. </ul>
  86. </section1>
  87. <section1 topic='Implementation'>
  88. <section2 topic='Requesting a DTCP connection'>
  89. <p>Say you wish to initiate a DTCP session with Joe:</p>
  90. <example caption='Requesting a DTCP session'><![CDATA[
  91. <iq type="set" id="dtcp_1" to="joe@blow.com/Home">
  92. <query xmlns="http://jabber.org/protocol/dtcp">
  93. <key>c7b5ea3f</key>
  94. <host>192.168.0.32:8000</host>
  95. <host>63.110.44.12:8000</host>
  96. </query>
  97. </iq>
  98. ]]></example>
  99. <p>The 'key' given is a unique key for Joe to use when referencing this session with you. If a 'host' element is present, then you are indicating that you can be reached at the given "host:port". Multiple hosts may be specified, but Joe cannot be expected to act on more than three of them.</p>
  100. <example caption='Success response'><![CDATA[
  101. <iq type="result" id="dtcp_1" from="joe@blow.com/Home">
  102. <query xmlns="http://jabber.org/protocol/dtcp">
  103. <key>a1b2c3d4</key>
  104. <host>192.168.0.33:8000</host>
  105. </query>
  106. </iq>
  107. ]]></example>
  108. <p>The success response is in exactly the same format as the request. As before, Joe cannot expect you to act on more than three hosts. The 'key' is a unique key from Joe that you will use when referring to the session with him.</p>
  109. <example caption='Error response'><![CDATA[
  110. <iq type="error" id="dtcp_1" from="joe@blow.com/Home">
  111. <error code="501">DTCP not supported</error>
  112. </iq>
  113. ]]></example>
  114. <p>Or he may send an error.</p>
  115. </section2>
  116. <section2 topic='Establishing the TCP connection'>
  117. <p>If you received a success response, then the next step is to form the TCP connection. Each entity should have a list of hosts (between 0-3 inclusive) and key of the other. With this information, they should each try to establish a direct connection with the hosts provided. When these connections take place is implementation dependent. Clients may choose to connect to all provided hosts at once, and both clients may even end up connecting to each other simultaneously. Clients may delay between connections, etc. As such, clients that are listening for connections should be prepared for anything.</p>
  118. <p>The procedure ends when either a successful DTCP connection is formed (and all other TCP connections discarded), or when both entities have given up. An entity gives up when it is no longer trying to connect to any hosts. This is done by sending an additional iq-error packet, with the key of the other entity:</p>
  119. <example><![CDATA[
  120. <iq type="error" to="joe@blow.com/Home">
  121. <query xmlns="http://jabber.org/protocol/dtcp">
  122. <key>a1b2c3d4</key>
  123. </query>
  124. <error code="503">Could not connect to any of the hosts.</error>
  125. </iq>
  126. ]]></example>
  127. <p>If an entity was not provided any hosts, then it is assumed that he has given up and this packet need not be sent.</p>
  128. </section2>
  129. <section2 topic='The handshake'>
  130. <p>For a given host, a TCP socket connection is established. Once connected, the connecting client must send a command across the channel. Each command is a line of text terminated by the ASCII linefeed character (0x0A).</p>
  131. <example caption='Command format'>
  132. [command]:[argument]&lt;LF&gt;
  133. </example>
  134. <p>Some commands may have an argument, which is placed on the same line and separated by a colon character. If there is no argument, then the colon need not be present.</p>
  135. <p>The serving client should keep the connection open after responding to a command, even if it resulted in an error, in case the connecting client wishes to try another command.</p>
  136. <section3 topic='SSL/TLS'>
  137. <p>If you want an encrypted channel, then it must be requested using the 'starttls' command</p>
  138. <example>
  139. starttls&lt;LF&gt;
  140. </example>
  141. <p>If successful, the serving client should send back:</p>
  142. <example>
  143. ok&lt;LF&gt;
  144. </example>
  145. <p>This means that the serving client supports SSL and the connecting client should begin the SSL/TLS negotiation. After this, further data sent/received over the channel should be in encrypted form.</p>
  146. <p>Or the serving client might report an error:</p>
  147. <example>
  148. error&lt;LF&gt;
  149. </example>
  150. <p>This means SSL is not supported by the serving client.</p>
  151. </section3>
  152. <section3 topic='Authenticating'>
  153. <p>To complete the DTCP connection, the connecting client must authenticate with the serving client. This is done by exchanging keys. First, the connecting client sends the serving client's key:</p>
  154. <example>
  155. key:a1b2c3d4&lt;LF&gt;
  156. </example>
  157. <p>If the serving client recognizes the key, then it should respond by sending the connecting client's key:</p>
  158. <example>
  159. ok:c7b5ea3f&lt;LF&gt;
  160. </example>
  161. <p>Or the serving client might report an error:</p>
  162. <example>
  163. error&lt;LF&gt;
  164. </example>
  165. <p>On success, there may be one more step necessary. If the connecting client is also the original requestor of the DTCP connection (ie, he did the iq-set), then he must send the following "ack":</p>
  166. <example>
  167. ok&lt;LF&gt;
  168. </example>
  169. <p>This gives the final say to the requestor, to prevent any sort of race-condition due to the clients contacting each other at the same time. If the serving client is the requestor, then this extra "ack" is NOT needed and must NOT be sent.</p>
  170. <p>At this point, the channel is established. No further commands may be issued, as the TCP connection is now for application data only.</p>
  171. </section3>
  172. </section2>
  173. </section1>
  174. </xep>