%ents; ]>
Jingle File Transfer This specification defines a Jingle application type for transferring a file from one entity to another. The protocol provides a modular framework that enables the exchange of information about the file to be transferred as well as the negotiation of parameters such as the transport to be used. &LEGALNOTICE; 0234 Experimental 2017-12-12 Standards Track Standards XMPP Core XEP-0166 XEP-0261 XEP-0300 XEP-0096 jingle-ft &stpeter; &lance; 0.18.3 2017-08-24 ps

Make use of <hash-used/> from XEP-0300.

0.18.2 2017-08-23 editor (jwi)
  • Fix a date missing its timezone in examples. (egp)
  • Remove the mention of UTC, timestamps are already properly described in XEP-0082. (egp)
  • Add missing length attribute to XML schema. (ps)
  • Fix incorrect XML in examples. (ps)
0.18.1 2017-05-20 egp
  • Add missing anchor to the Received section.
  • Add missing received and desc elements in schema.
0.18.0 2017-01-30 ls
  • Update dependency on XEP-0300 to require the 'urn:xmpp:hashes:2' namespace that mandates base64 encoding.
  • Clarify that a <range/> element with a limit or offset value in a 'session-accept' should be honored by the file sender.
  • Namespace version bumped to ':5'.
0.17.2 2016-07-15 ph (XEP Editor: ssw)

Fix references to ICE-TCP.

0.17.1 2016-03-08 ls

Corrected some instances of transport-info to instead be session-info.

0.17 2015-09-08 ls/psa
  • Recast the document to match the registration procedure defined by XEP-0166 for new application types.
  • Explicitly defined the schema of the <file/> element instead of referencing XEP-0096.
  • Defined the use of a 'length' attribute on <range/> elements. This attribute was always there because the <file/> and <range/> elements had been defined as the same as the parallel elements in XEP-0096, but the 'length' attribute was not explicitly referenced in this document.
  • Clarified the need for the 'senders' attribute on Jingle <content/> elements to distinguish between File Offers and File Requests.
  • Added the <file-not-found/> and <file-too-large/> reason types.
  • Clarified how to abort a file transfer via 'content-remove' or 'session-terminate' actions.
  • Added <received/> element for indicating that a transfer was successful, particularly when there are multiple transfers.
  • Added SDP mapping.
0.16 2014-08-11 psa
  • Modified protocol to support sending only one file at a time (multi-file adds unnecessary complexity).
  • Removed <request/> flow in favor of a dedicated protocol similar to XEP-0137 ("jingle-pub").
  • Removed <offer/> wrapper since it is no longer necessary (with the removal of the request flow).
  • Removed the <abort/> element since it was related to the transfer of multiple files.
  • Changed <candidate-used/> to >remote-candidate/> for consistency with XEP-0176.
  • Added media-type child to <file/> element.
  • Added example for communicating empty <hash/> element in the session-initiate message.
  • Incremented namespace version from 3 to 4.
0.15 2012-02-08 psa

Updated to track revisions to XEP-0300.

0.14 2011-06-29 psa
  • Defined file description format separate from XEP-0096
  • Modified the checksum format to reuse the <hashes/> element from XEP-0300
  • Described the process of aborting a file transfer
  • Clarified the order of events (Jingle, then transport) when the session is terminated
  • Added section on determining spport, including service discovery feature for multi-file support
  • Removed the 'urn:xmpp:jingle:apps:file-transfer:info:2' namespace by putting all elements into the 'urn:xmpp:jingle:apps:file-transfer:4' namespace
  • Incremented namespace version from 2 to 3
0.13 2011-06-01 psa

Added multi-file use case; updated spec to reflect XEP-0260 and XEP-0261; added algorithm attribute from XEP-0096; increased namespace versions from 1 to 2.

0.12 2011-01-05 psa

Clarified usage of Jingle actions as well as several ambiguous points in the text, including use of the range feature from XEP-0096.

0.11 2010-02-19 psa

Added session-info message and namespace for communicating the file hash.

0.10 2010-02-11 psa

Described the file retrieval case; updated referenced namespaces.

0.9 2009-02-19 psa
  • Moved Jingle definitions of S5B and IBB transports to standalone documents.
  • Because the jingle-s5b and jingle-ibb transport methods are backward-incompatible, incremented protocol version number from 0 to 1 and changed namespace from urn:xmpp:jingle:apps:file-transfer:0 to urn:xmpp:jingle:apps:file-transfer:2.
  • Moved transport fallback scenario to XEP-0260.
0.8 2008-09-30 psa

Corrected fallback scenario to use transport-replace and transport-accept.

0.7 2008-09-25 psa
  • Deleted content-replace from session flows.
  • Modified namespaces to incorporate namespace versioning.
  • Cleaned up XML schemas.
0.6 2008-07-31 psa

Harmonized with XEP-0166; modified fallback to use transport-replace and transport-accept.

0.5 2008-06-05 psa

Modified fallback scenario to use content-replace action during pending state.

0.4 2008-06-04 psa

Harmonized negotiation flows with other Jingle application types.

0.3 2008-05-29 psa

Corrected and more clearly explained negotiation flows for consistency with XEP-0166 and other Jingle specifications.

0.2 2008-03-20 psa

Added transport negotiation scenario.

0.1 2008-03-05 psa

Initial published version.

0.0.3 2008-02-29 psa

Corrected use of content-replace action; specified that the In-Band Bytestreams transport method is mandatory-to-implement but must have the lowest preference order.

0.0.2 2008-02-28 psa

Modified negotiation flow to use new content-replace action.

0.0.1 2008-01-29 psa

First draft.

&xep0166; can be used to initiate and negotiate a wide range of peer-to-peer sessions. One session type of interest is file transfer. This document specifies an application format for negotiating Jingle file transfer sessions, where files are exchanged via any available reliable transport.

&xep0096; was the original XMPP protocol extension for file transfer negotiation. However, that protocol has several drawbacks, most related to the &xep0095; protocol on which it depends:

  1. It does not enable a true, bidirectional negotiation; instead, the initiator sets the terms for the file transfer and the responder either accepts the terms or cancels the negotiation.

  2. It is the only technology in the Jabber/XMPP protocol "stack" that uses XEP-0095: Stream Initiation. More modern technologies such as voice and video session negotiation use &xep0166;, and it would be helpful if implementors could re-use the same code for all negotiation use cases.

To overcome these drawbacks, this specification defines a file transfer negotiation method that meets the following requirements:

Note that Jingle file transfer is only as reliable as the transports on which it depends. In particular, SOCKS5 Bytestreams ("S5B") does not always result in NAT or firewall traversal. To work around that problem, this specification requires all implementations to support as a fallback mechanism In-Band Bytestreams ("IBB"), which usually results in a successful (if slow) file transfer. A more robust and adaptable option is ICE-TCP (RFC 6544); at the time of writing &xep0176; is being updated to include the ability to negotiate ICE-TCP candidates.

File Offer
A Jingle File Transfer Content is said to be a File Offer if the content creator is the same as the content sender (see Use of Jingle Content Senders).
File Request
A Jingle File Transfer Content is said to be a File Request if the content creator is the opposite of the content sender (see Use of Jingle Content Senders).
File Sender
The File Sender is the side of the Jingle session responsible for sending the file data. The File Sender is not necessarily the same entity as the Jingle session initiator, and an entity could be both a File Sender and File Receiver in the context of a single Jingle session with multiple files.
File Receiver
The File Receiver is the side of the Jingle session responsible for receiving the file data. The File Receiver is not necessarily the same entity as the Jingle session responder, and an entity could be both a File Receiver and File Sender in the context of a single Jingle session with multiple files.

In accordance with Section 12 of XEP-0166, this document specifies the following information related to the Jingle File Transfer ("Jingle FT") application type:

  1. The application format negotiation process is defined in the Negotiating a Jingle File Transfer Session section of this document.

  2. The semantics of the &DESCRIPTION; element are defined in the Application Format section of this document.

  3. A mapping of Jingle semantics to the Session Description Protocol is provided in the Mapping to Session Description Protocol section of this document.

  4. A Jingle File Transfer session SHOULD use a streaming transport method, not a datagram transport method.

  5. Transport components are not used in Jingle File Transfer.

  6. Content is to be sent and received as follows:

    For streaming transports, outbound content shall be encoded into packets (as defined by the transport mechanism) without any other framing mechanism and sent in succession over the transport. Incoming data received over the transport shall be processed as a stream of packets, where each packet's content payload is entirely composed of the next portion of file data to be processed.

Jingle File Transfer makes critical use of the 'senders' attribute of Jingle &CONTENT; elements in order to specify which party is responsible for sending the described file. As such, Jingle File Transfer content MUST include a 'senders' attribute, where the allowed values are "initiator" and "responder". The semantics of the values "both" and "none" are undefined in Jingle File Transfer and thus NOT RECOMMENDED for use with Jingle File Transfer content.

In general, a Jingle File Transfer content is said to be a "File Offer" if the 'senders' attribute is the same as the role of the party adding the content to the session, and a "File Request" if the 'senders' value is the opposite role of the party adding the content.

Note: The content 'creator' attribute does not specify who created or is sending the file, it only specifies which party to the session added the Jingle content to the session.

Jingle Session Role Content Senders File Transfer Type
initiator initiator File Offer
initiator responder File Request
responder initiator File Request
responder responder File Offer

A Jingle File Transfer session is described by a content type that contains one application format and one transport method. Each &CONTENT; element defines the details of a single file transfer. A Jingle negotiation MAY result in the establishment of multiple file transfers by including multiple &CONTENT; elements.

The application format consists of a file description contained within a &DESCRIPTION; element qualified by the "urn:xmpp:jingle:apps:file-transfer:5" namespace &VNOTE;. The file description is a <file/> element specifying metadata such as the name of the file, media type, etc., as illustrated in the following example.

text/plain test.txt 2015-07-26T21:46:00+01:00 6144 w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

The &DESCRIPTION; element is intended to be a child of a Jingle &CONTENT; element as specified in XEP-0166.

The child elements of the <file/> element are as follows:

Element Name Description Inclusion
date Timestamp specifying the last modified time of the file (which MUST conform to the DateTime profile of &xep0082;). OPTIONAL
desc A human readable description of the file. Multiple <desc/> elements MAY be included if different xml:lang values are specified. OPTIONAL
hash A hash of the file content, using the <hash/> element defined in &xep0300; and qualifed by the 'urn:xmpp:hashes:2' namespace. Multiple hashes MAY be included for hash agility. See <hash-used/>
hash-used Alternatively to a <hash/> element, the initiator can also include a <hash-used/> element. This avoids the need to read the file twice to calculate the hash. Either a <hash/> or a <hash-used/> element MUST be included when offering a file.
media-type The media type of the file content, which SHOULD be a valid MIME-TYPE as registered with &IANA; (specifically, as listed at <http://www.iana.org/assignments/media-types>). If not specified, the content is assumed to be "application/octet-stream". RECOMMENDED when offering a file, otherwise OPTIONAL
name The name of the file. The name SHOULD NOT contain characters or character sequences that would be interpreted as a directory structure by the local file system (e.g. "/", "\", "../", etc.). If any such characters or character sequences are present (possibly because the local and remote file systems use different syntax for directory structure), they SHOULD be escaped (e.g., via percent-encoding) before using the name as part of any file system operation. See Security Considerations. OPTIONAL
size The length of the file's content, in bytes. OPTIONAL, but SHOULD be present when offering a file.
range The presence of the <range/> element indicates support of ranged transfers, and can be used to control where a transfer starts. OPTIONAL

One or more <hash/> elements MUST be present when offering a file, but those elements MAY be empty if the hash has not yet been computed. If there is no computed hash value, the <hash/> element(s) MUST possess an 'algo' attribute specifying which hash algorithm will be used. Once a hash has been calculated by the File Sender, the File Sender SHOULD inform the File Receiver of the hash value as described in Checksum.

Additional elements MAY be included as children of the <file/> element to provide additional metadata about the file, such as &xep0264;.

The optional <range/> element MAY possess two attributes:

Attribute Description Inclusion
offset Specifies the position, in bytes, from which to start transferring file data. This defaults to zero (0) if not specified. OPTIONAL
length Specifies the number of bytes to retrieve starting at offset. This defaults to the length of the file from offset to the end. OPTIONAL

Inclusion of a <range/> element in a File Offer indicates support of ranged transfers for future File Requests if the transfer is interrupted and needs to be restarted.

A <range/> element MAY include an 'offset' attribute set to begin the transfer at a point other than the start of the file, and MAY include a 'length' attribute to request a portion of the file smaller than the remaining length of the file. If no 'offset' or 'length' attributes are present then it is the same as if no <range/> element was present, because the default values of the attributes would indicate a requested range of the entire file. In general, the first byte of data to be transferred is at the (zero-indexed) position specified by the 'offset' value, with a total of 'length' bytes sent.

In general, the process for negotiating a Jingle File Transfer session is as follows:

| | ack | |<----------------------------| | session-accept | |<----------------------------| | ack | |---------------------------->| | [optional further | | negotiation] | |<--------------------------->| | File Transfer | |============================>| | |]]>

To start a File Offer, the initiator sends a Jingle session-initiation request to a potential responder. The request specifies three things:

  1. A content 'senders' attribute with the value of 'initiator' to indicate this is a File Offer.
  2. An application type of "urn:xmpp:jingle:apps:file-transfer:5". In particular, the <description/> element contains a <file/> elements describing the file to be sent.
  3. An appropriate transport method.

In this example, the initiator is <romeo@montague.example>, the responder is <juliet@capulet.example>, the application type is a File Offer, and the transport method is jingle-s5b (XEP-0260).

The flow is as follows.

First the initiator sends a Jingle session-initiate.

1969-07-21T02:56:15Z This is a test. If this were a real file... text/plain test.txt 6144 w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

Note: Inclusion of the <range/> child of the <file/> element indicates that the initiator supports ranged transfers as described below under Ranged Transfers.

Note: Computing the hash of the file before sending it can slow down the process of file transfer, because the sending application needs to process the file twice. The File Sender might prefer to send the hash after the file transfer has begun, using a session-info message as described under Checksum.

The responder immediately acknowledges receipt of the Jingle session-initiate.

]]>

The initiator then attempts to initiate a SOCKS5 Bytestream with the responder as described in XEP-0260 and XEP-0065. In the meantime, the responder returns a Jingle session-accept. In the session-accept message, the <file/> element MAY contain a <range/> element to indicate that the receiver also supports ranged transfers as described below under Ranged Transfers. If the responder includes a <range /> element with a limit or offset, the File Sender SHOULD respect the provided range settings.

1969-07-21T02:56:15Z This is a test. If this were a real file... text/plain test.txt 6144 w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

The initiator acknowledges the Jingle session-accept.

]]>

If the File Sender has advertised the existence of a file that it hosts, such as by &xep0358;, or if a previous file transfer attempt has failed and the File Receiver would like to initiate another attempt, the File Receiver can "pull" the file from the File Sender. This is done by sending a Jingle session-initiate to the File Sender which includes a <content/> with the 'senders' attribute set to the opposite Jingle session role of the party requesting the file (see Use of Jingle Content Senders) and a <description/> element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace and which includes a <file/> element with enough information included to form a "file selector" (see Section 5 of &rfc5547;) to identify the requested file.

w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

See File not Available for how to respond if the requester does not have permission to request the file, or if the file cannot be found.

While the Jingle File Transfer session is active, either party MAY choose to add additional files (both offers and requests) to the transfer session. To do so, a Jingle content-add action is used, as shown in the following examples.

second-file.txt text/plain 6144 w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

The other party then acks the content-add request.

]]>

At this point, the content-add request needs to be either accepted or rejected using Jingle content-accept or content-reject actions.

As in XEP-0096, a transfer can include only part of a file (e.g., to restart delivery of a truncated transfer session at a point other than the start of the file). This is done using the <range/> element. The usage is illustrated in the following examples.

Let us imagine that the parties negotiate a file transfer session using, say, In-Band Bytestreams. During the transfer, the recipient goes offline unexpectedly and IBB stanzas from the File Sender to the File Receiver begin to bounce. When the recipient comes back online, the File Sender could initiate a new Jingle session and specify that it wants to send all chunks after byte 270336 (which might be the 66th chunk of size 4096).

w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

At any point, either party MAY choose to abort the transfer of a single file, or end the session entirely to abort all active transfers.

When there is only a single Jingle content or if a party wishes to abort the transfer of all files in the session, a session-terminate including a Jingle reason of <cancel /> is sent.

]]>

If a party chooses to abort the transfer of a single file out of several active transfers, a Jingle content-remove action is used, which MAY include a Jingle reason of <cancel/>, as shown in the following example.

]]>

The other party then acks the content-remove request.

]]>

If after removing the content there are no other Jingle contents the session MUST be terminated as described in the next section.

Once all file content in the session has been transfered, either party MAY acknowledge receipt of the received files (see Received) or, if there are no other active file transfers, terminate the Jingle session with a Jingle session of <success/>. Preferably, sending the session-terminate is done by the last entity to finish receiving a file to ensure that all offered or requested files by either party have been completely received (up to the advertised sizes).

]]>

&rfc5547; defines the general process for including file transfer information in SDP.

The SDP media type for Jingle File Transfer can be "message" (e.g. when used with &rfc4975;) or "application"; however, this media value is not reflected in the Jingle File Transfer application format.

Any combination of <name/>, <size/>, <media-type/>and <hash/> values MAY be used to form a "file selector" (see Section 5 of &rfc5547;), which would be mapped to SDP as follows:

"] [size:] [type:] [hash::]]]>

(The hash value MUST be encoded as hexadecimal with each byte separated by a colon.)

The <date/> value is the last modified time of the file, and thus is mapped as follows:

"]]>

Note: the format used here for <date> is the date-time format defined in &rfc5322;.

If a range is specified, the SDP mapping requires both a start and stop offset. If no length was specified for the range, the stop offset is "*". If a length was specified, the stop offset is the <range/> offset value plus the length.

-<(offset + length) | *>]]>

As a full example, given the following Jingle File Transfer content description:

text/plain test.txt 2015-07-26T21:46:00+01:00 6144 w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

The equivalent SDP would be:

Once a file has been successfully received, the recipient MAY send a Jingle session-info message indicating receipt of the complete file, which consists of a <received/> element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace. The <received/> element SHOULD contain 'creator' and 'name' attributes sufficient to identify the content that was received.

]]>

At any time during the lifetime of the file transfer session, the File Sender can communicate the checksum of the file to the File Receiver.

This can be done in the session-initiate message if the File Sender already knows the checksum, as shown above in Example 3.

After the session-initiate message, this can also be done by sending a session-info message containing a <checksum/> element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace. In such a case however, the session-initiate message MUST contain a <hash-used/> element. The <checksum/> element SHOULD contain 'creator' and 'name' attributes sufficient to identitfy the content the checksum belongs to. Additionally, the <checksum/> element MUST contain a <file/> element which MUST contain at least one <hash/> or <hash-used/> element qualified by the 'urn:xmpp:hashes:2' namespace. Each <hash/> element contains a checksum of the file data produced in accordance with the hashing function specified by the 'algo' attribute, which MUST be one of the functions listed in the &ianahashes;.

w0mcJylzCn+AfvuGdqkty2+KP48= ]]>

If a ranged transfer was requested, the <file/> element inside the <checksum/> element MAY include a <range/> element specifying the offset and length of the requested range, which in turn includes <hash/> element(s) with hashes of the data that was transferred for that range.

kHp5RSzW/h7Gm1etSf90Mr5PC/k= ]]>

If the initiator wishes to communicate only the hashing algorithm at the beginning of the session (e.g., because it has not yet calculated the checksum), it can send an empty <hash/> element (without a checksum in the XML character data as shown in the previous examples) in the session-initiate message; this enables the recipient to check the file during the transfer session (which can be helpful in the case of transfers that are truncated or fail mid-stream).

1969-07-21T02:56:15Z This is a test. If this were a real file... text/plain test.txt 6144 ]]>

If a requested file cannot be found (or the requester does not have permission to request or know about the existence of the file in question), then the File Sender SHOULD send either a session-terminate or content-reject action in response to the session-initiate or content-add request, and SHOULD include a Jingle reason of <failed-application/> and MAY include an application specific reason of a <file-not-available/> element qualified by the 'urn:xmpp:jingle:apps:file-transfer:errors:0' namespace.

]]>

There are several situations where a File Receiver might wish to abort a transfer due to an excess of file data, for example:

  • The File Receiver has reached a file system storage quota or other hard limit that prevents continuing to receive file data.
  • The File Sender has continued sending data past the initially specified size of the file.

In such cases, the File Receiver MAY abort the transfer by sending a Jingle session-terminate (or content-remove as appropriate) which includes a Jingle reason of <media-error/> and MAY include an application specific reason of a <file-too-large/> element qualified by the 'urn:xmpp:jingle:apps:file-transfer:errors:0' namespace.

]]>

To prevent denial of service and other attacks, the File Receiver is fully within its rights to drop received data or not send a session-terminate message.

All implementations MUST support the Jingle In-Band Bytestreams Transport Method (XEP-0261) as a reliable method of last resort. An implementation SHOULD support other transport methods as well, especially ICE-TCP (RFC 6544) and the Jingle SOCKS5 Bytestreams Transport Method (XEP-0260).

An application MAY present transport methods in any order, except that the Jingle In-Band Bytestreams Transport Method MUST be the lowest preference.

Support for Jingle file transfer can be determined through discovery of the 'urn:xmpp:jingle:apps:file-transfer:5' namespace &VNOTE;, via either service discovery (XEP-0030) or entity capabilities (XEP-0115). If the initiator knows that the responder supports Jingle file transfer, it SHOULD first attempt negotiation using Jingle rather than Stream Initiation.

To advertise its support for the Jingle File Transfer, when replying to service discovery information ("disco#info") requests an entity MUST return URNs for any version of this protocol that the entity supports -- e.g., "urn:xmpp:jingle:apps:file-transfer:5" for this version &VNOTE;.

]]> ]]>

In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.

Caution needs to be exercised when using the <name/> of a file offer or request to control any interaction with a file system. For example, a malicious user could request a file with <name>/etc/passwd</name> or include file system specific control patterns such as <name>../../private.txt</name> to try and access a sensitive file outside of the set of files intended to be shared. Or a malicious user could offer a file named "/etc/passwd" to try and trick the receiver into overwriting that or other sensitive files. Therefore, implementations SHOULD escape any file system path separators in the <name/> before using that value in any file system calls.

It is RECOMMENDED for implementations to use the strongest hashing algorithm available to both parties. See XEP-0300 for further discussion.

In order to secure the data stream, implementations SHOULD use encryption methods appropriate to the transport method being used. For example, end-to-end encryption can be negotiated over either SOCKS5 Bytestreams or In-Band Bytestreams as described in XEP-0260 and XEP-0261.

Refer to XEP-0047, XEP-0065, XEP-0096, XEP-0176, XEP-0260, XEP-0261, and RFC 6544 for related security considerations.

No interaction with &IANA; is required as a result of this document.

The XML character data of the <media-type/> element SHOULD be a value registered with the IANA in the &ianamedia;.

This specification defines the following XML namespace:

  • urn:xmpp:jingle:apps:file-transfer:5

Upon advancement of this specification from a status of Experimental to a status of Draft, the ®ISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.

&NSVER;

The XMPP Registrar shall include "file-transfer" in its registry of Jingle application formats. The registry submission is as follows:

file-transfer Jingle sessions for the transfer of a file streaming XEP-0234 ]]>
]]> ]]>

Thanks to Diana Cionoiu, Olivier Crête, Viktor Fast, Philipp Hancke, Waqas Hussain, Justin Karneges, Steffen Larsen, Yann Leboulanger, Marcus Lundblad, Robert McQueen, Joe Maissel, Glenn Maynard, Ali Sabil, Sjoerd Simons, Will Thompson, Matthew Wild, Paul Schaub and Jiří Zárevúcky for their feedback.