XEP-0046: DTCP

Direct TCP connection between two Jabber entities.


WARNING: This document has been retracted by the author(s). Implementation of the protocol described herein is not recommended. Developers desiring similar functionality should implement the protocol that supersedes this one (if any).


Document Information

Series: XEP
Number: 0046
Publisher: XMPP Standards Foundation
Status: Retracted
Type: Standards Track
Version: 0.8
Last Updated: 2003-04-11
Approving Body: XMPP Council
Dependencies: None
Supersedes: None
Superseded By: None
Short Name: None
Wiki Page: <http://wiki.jabber.org/index.php/DTCP (XEP-0046)>


Author Information

Justin Karneges

Email: justin@affinix.com
JabberID: justin@andbit.net


Legal Notices

Copyright

This XMPP Extension Protocol is copyright (c) 1999 - 2008 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising out of the use or inability to use the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Discussion Venue

The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.

Errata may be sent to <editor@xmpp.org>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Conformance Terms

The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Table of Contents


1. Introduction
2. Requirements
3. Implementation
    3.1. Requesting a DTCP connection
    3.2. Establishing the TCP connection
    3.3. The handshake
       3.3.1. SSL/TLS
       3.3.2. Authenticating
Notes
Revision History


1. Introduction

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.

2. Requirements

The following design goals are considered:

3. Implementation

3.1 Requesting a DTCP connection

Say you wish to initiate a DTCP session with Joe:

Example 1. Requesting a DTCP session

<iq type="set" id="dtcp_1" to="joe@blow.com/Home">
  <query xmlns="http://jabber.org/protocol/dtcp">
    <key>c7b5ea3f</key>
    <host>192.168.0.32:8000</host>
    <host>63.110.44.12:8000</host>
  </query>
</iq>

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.

Example 2. Success response

<iq type="result" id="dtcp_1" from="joe@blow.com/Home">
  <query xmlns="http://jabber.org/protocol/dtcp">
    <key>a1b2c3d4</key>
    <host>192.168.0.33:8000</host>
  </query>
</iq>

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.

Example 3. Error response

<iq type="error" id="dtcp_1" from="joe@blow.com/Home">
  <error code="501">DTCP not supported</error>
</iq>

Or he may send an error.

3.2 Establishing the TCP connection

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.

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:

Example 4.

<iq type="error" to="joe@blow.com/Home">
  <query xmlns="http://jabber.org/protocol/dtcp">
    <key>a1b2c3d4</key>
  </query>
  <error code="503">Could not connect to any of the hosts.</error>
</iq>

If an entity was not provided any hosts, then it is assumed that he has given up and this packet need not be sent.

3.3 The handshake

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).

Example 5. Command format

    [command]:[argument]<LF>

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.

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.

3.3.1 SSL/TLS

If you want an encrypted channel, then it must be requested using the 'starttls' command

Example 6.

    starttls<LF>

If successful, the serving client should send back:

Example 7.

    ok<LF>

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.

Or the serving client might report an error:

Example 8.

    error<LF>

This means SSL is not supported by the serving client.

3.3.2 Authenticating

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:

Example 9.

    key:a1b2c3d4<LF>

If the serving client recognizes the key, then it should respond by sending the connecting client's key:

Example 10.

    ok:c7b5ea3f<LF>

Or the serving client might report an error:

Example 11.

    error<LF>

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":

Example 12.

    ok<LF>

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.

At this point, the channel is established. No further commands may be issued, as the TCP connection is now for application data only.


Notes

1. DTCP works in situations where at least one client can accept incoming connections.


Revision History

Version 0.8 (2003-04-11)

At the request of the author, changed status to Retracted. (psa)

Version 0.7 (2002-12-10)

Remove 'comment' block (jk)

Version 0.6 (2002-12-02)

Simplification of the document (jk)

Version 0.5 (2002-11-19)

Changed handshake and namespace, merged active/passive (jk)

Version 0.4 (2002-10-10)

Change to 'comment' block (jk)

Version 0.3 (2002-09-18)

Support for SSL (jk)

Version 0.2 (2002-09-18)

Simplified things. (jk)

Version 0.1 (2002-09-12)

Initial version. (jk)

END