mirror of
https://github.com/moparisthebest/xeps
synced 2024-11-21 08:45:04 -05:00
0.5
git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@2290 4b5297f7-1745-476d-ba37-a9c6900126ab
This commit is contained in:
parent
9dbff18958
commit
6f15ad8258
97
xep-0198.xml
97
xep-0198.xml
@ -22,6 +22,12 @@
|
||||
&infiniti;
|
||||
&hildjj;
|
||||
&stpeter;
|
||||
<revision>
|
||||
<version>0.5</version>
|
||||
<date>2008-09-29</date>
|
||||
<initials>psa</initials>
|
||||
<remark><p>Removed recommendation to use namespace prefixes; modified namespace to incorporate namespace versioning.</p></remark>
|
||||
</revision>
|
||||
<revision>
|
||||
<version>0.4</version>
|
||||
<date>2008-09-08</date>
|
||||
@ -67,14 +73,14 @@
|
||||
</header>
|
||||
|
||||
<section1 topic='Introduction' anchor='intro'>
|
||||
<p>&xmppcore; defines the fundamental streaming XML technology used by XMPP (i.e., stream establishment and termination including authentication and encryption). However, the core XMPP specification does not provide tools for actively managing a "live" XML stream. In particular, the following management features might improve network reliability and the end-user experience (especially when connectivity is infrequent or power consumption is a key consideration):</p>
|
||||
<p>&xmppcore; defines the fundamental streaming XML technology used by XMPP (i.e., stream establishment and termination including authentication and encryption). However, the core XMPP specification does not provide tools for actively managing a "live" XML stream. In particular, the following management features might improve network reliability and the end-user experience (especially when connectivity is infrequent):</p>
|
||||
<ul>
|
||||
<li>Acknowledgements -- the ability to know if a particular stanza (or a series of stanzas) has in fact been received and processed by either of the endpoints.</li>
|
||||
<li>Pings -- the ability to test the connectivity of the XML stream at any time.</li>
|
||||
<li>Pings -- the ability to test the connectivity of the XML stream.</li>
|
||||
<li>Resume -- the ability to quickly resume a stream that has been terminated.</li>
|
||||
</ul>
|
||||
<p>Detailed descriptions of these features are provided in the remainder of this specification.</p>
|
||||
<p>The facilities provided by this specification are different from those provided by &xep0079;, &xep0184;, and &xep0199;. The other specifications cover end-to-end and multi-hop acks and pings, which are useful in special scenarios, but unnecessary for checking of a single-hop stream. It is also expected that this protocol will revive interest in Advanced Message Processing (AMP), because single-hop acks are necessary for AMP delivery receipts to function properly.</p>
|
||||
<p>The facilities provided by this specification are different from those provided by &xep0079;, &xep0184;, and &xep0199;. Those specifications cover end-to-end and multi-hop acks and pings, which are useful in special scenarios, but unnecessary for checking of a single-hop stream. It is also expected that this protocol will revive interest in Advanced Message Processing (AMP), because single-hop acks are necessary for AMP delivery receipts to function properly.</p>
|
||||
<p>The basic concept behind stream management is that the initiating entity (either a client or a server) and the receiving entity (a server) can exchange commands for active management of the stream. In particular, instead of using XMPP IQ, message, or presence stanzas (which are relatively verbose), stream management uses a series of short XML elements at the root stream level.</p>
|
||||
<p>The benefits to be gained from stream management include the following:</p>
|
||||
<ul>
|
||||
@ -86,18 +92,17 @@
|
||||
</section1>
|
||||
|
||||
<section1 topic='Stream Feature' anchor='feature'>
|
||||
<p>After negotiating use of TLS and authenticating via SASL, the receiving entity returns a new stream header to the intiating entity (including a namespace declaration for its preferred namespace prefix) along with new stream features, including an <sm/> element qualified by the 'urn:xmpp:tmp:sm' namespace &NSNOTE;.</p>
|
||||
<p>After negotiating use of TLS and authenticating via SASL, the receiving entity returns a new stream header to the intiating entity along with new stream features, where the features include an <sm/> element qualified by the 'urn:xmpp:sm:0' namespace &VNOTE;.</p>
|
||||
<p>Note: The stream management feature MUST NOT be offered unless the initiating entity has been authenticated.</p>
|
||||
<example caption='Server sends new stream header along with stream features'><![CDATA[
|
||||
S: <stream:stream
|
||||
to='example.com'
|
||||
xmlns='jabber:client'
|
||||
xmlns:stream='http://etherx.jabber.org/streams'
|
||||
xmlns:sm='urn:xmpp:tmp:sm'
|
||||
version='1.0'>
|
||||
|
||||
S: <stream:features>
|
||||
<sm xmlns='urn:xmpp:tmp:sm'>
|
||||
<sm xmlns='urn:xmpp:sm:0'>
|
||||
<optional/>
|
||||
</sm>
|
||||
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
||||
@ -108,7 +113,7 @@ S: <stream:features>
|
||||
<p>If the receiving entity offers stream resumption, the <sm/> element MUST include an 'id' attribute (a unique identifier for the session) and SHOULD include a 'max' attribute that specifies the longest allowable time period for session resumption (in minutes).</p>
|
||||
<example caption='Stream features for resumption'><![CDATA[
|
||||
S: <stream:features>
|
||||
<sm xmlns='urn:xmpp:tmp:sm' id='some-long-sm-id' max='15'>
|
||||
<sm xmlns='urn:xmpp:sm:0' id='some-long-sm-id' max='15'>
|
||||
<optional/>
|
||||
</sm>
|
||||
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
|
||||
@ -121,93 +126,85 @@ S: <stream:features>
|
||||
<section1 topic='Enabling a Stream Management Session' anchor='feature'>
|
||||
<p>To enable use of stream management, the client sends an <enable/> command to the server. If it wants to be allowed to resume the stream, it includes a boolean 'resume' attribute, which defaults to false &BOOLEANNOTE;.</p>
|
||||
<example caption='Client enables stream management'><![CDATA[
|
||||
C: <sm:enable/>
|
||||
C: <enable xmlns='urn:xmpp:sm:0'/>
|
||||
]]></example>
|
||||
<p>For information about enabling stream management when resuming a previous session, see the <link url='#resumption'>Stream Resumption</link> section of this document.</p>
|
||||
<p>Upon receiving the enable request, the receiving entity MUST reply with an <enabled/> element or an <error/> element qualified by the 'urn:xmpp:tmp:sm' namespace. The <error/> element indicates that there was a problem enabling the acknowledgement session. The <enabled/> element indicates successful enabling of the acknowledgement session.</p>
|
||||
<p>Upon receiving the enable request, the receiving entity MUST reply with an <enabled/> element or an <error/> element qualified by the 'urn:xmpp:sm:0' namespace. The <error/> element indicates that there was a problem enabling the stream management "session". The <enabled/> element indicates successful enabling of the stream management session.</p>
|
||||
<p>If session resumption is allowed, the receiving entity MUST include a 'resume' attribute set to a value of "true" or "1".</p>
|
||||
<example caption='Server enables stream management'><![CDATA[
|
||||
S: <sm:enabled resume='1'/>
|
||||
S: <enabled xmlns='urn:xmpp:sm:0' resume='1'/>
|
||||
]]></example>
|
||||
<p>The parties can then the use stream management features defined below.</p>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Stream Acknowledgements' anchor='acking'>
|
||||
<p>After enabling the feature, the initiating or receiving entity can send acknowledgement elements at any time over the stream. An acknowledgement element is either an <r/> element ("request ack") or an <a/> element ("gratuitous ack"), qualified by the 'urn:xmpp:tmp:sm' namespace. Both elements are referred to here as "ack elements". The syntax is as follows.</p>
|
||||
<p>After enabling the feature, the initiating or receiving entity can send acknowledgement elements at any time over the stream. An acknowledgement element is either an <r/> element ("request ack") or an <a/> element ("gratuitous ack"), qualified by the 'urn:xmpp:sm:0' namespace. Both elements are referred to here as "ack elements". The syntax is as follows.</p>
|
||||
<ul>
|
||||
<li>An <r/> element MUST contain a 'c' attribute and MAY contain a 'b' attribute.</li>
|
||||
<li>An <a/> element MAY contain a 'c' attribute and/or a 'b' attribute.</li>
|
||||
<li>The 'c' attribute is used to indicate a sequence number. It is an integer value generated by the sender, and MUST be strictly increasing. However, the sender MAY choose to reset the integer to a lower value if all stanzas sent have been acknowledged.</li>
|
||||
<li>The 'b' attribute acknowledges a previously-received sequence number from the other entity.</li>
|
||||
</ul>
|
||||
<p>Therefore an ack element is used to indicate a sequence number (contains 'c'), to acknowledge a sequence number (contains 'b'), or to do both at once (contains 'c' and contains 'b'). Acknowledging a previously-received ack element indicates stanza acceptance, in that all stanzas received up to that point are now safe in the receiver's hands and that the receiver will take care of them. Acks do not indicate successful delivery to a remote entity beyond the receiver.</p>
|
||||
<p>Therefore an ack element is used to indicate a sequence number (contains 'c'), to acknowledge a sequence number (contains 'b'), or to do both at once (contains 'c' and contains 'b'). Acknowledging a previously-received ack element indicates stanza acceptance, in that all stanzas received until then are now safely in the receiver's hands and that the receiver will take care of them. Acks do not indicate successful delivery to a remote entity beyond the receiver.</p>
|
||||
<example caption='A message with an ack request'><![CDATA[
|
||||
C: <message from='laurence@example.net/churchyard'
|
||||
to='juliet@example.com'
|
||||
xml:lang='en'>
|
||||
<body>I'll send a friar with speed, to Mantua, with my letters to thy lord.</body>
|
||||
<body>
|
||||
I'll send a friar with speed, to Mantua,
|
||||
with my letters to thy lord.
|
||||
</body>
|
||||
</message>
|
||||
C: <sm:r c='1'/>
|
||||
<r xmlns='urn:xmpp:sm:0' c='1'/>
|
||||
]]></example>
|
||||
<p>Note: The ack request SHOULD be sent in the same TCP packet as the XMPP stanza.</p>
|
||||
<p>When an <r/> element ("request ack") is received, the recipient MUST acknowledge it by sending an ack element back to the sender. The sender does not have to wait for an ack to continue sending stanzas. The response ack MUST contain a value of 'b' that is greater than or equal to the 'c' value given in the request ack. Acks SHOULD be sent as soon as possible, and MUST NOT be withheld for any condition other than a timeout. For example, a client with a slow connection might want to collect many stanzas over a period of time before acking, and a server might want to throttle incoming stanzas. Because acks indicate stanza acceptance, a server that is throttling stanzas MUST defer the acks until the client is no longer being penalized.</p>
|
||||
<p>When a sequence number is received (via the 'c' attribute), the recipient SHOULD keep a record of this value as the last received sequence number for the current stream. Every time a new sequence number is received, the previous number SHOULD be discarded. If a stream ends and it is not resumed within the time specified in the acknowledgement feature element, then the sequence number and any associated state MAY be discarded. Before the session state is discarded, implementations SHOULD take alternative action with any unacknowledged stanzas (e.g. stanzas sent after the latest sequence number reported by 'b'). A server implementation SHOULD treat unacknowledged stanzas in the same way that it would treat a stanza sent to an unavailable resource, by either returning an error to the sender or committing the stanza to offline storage. A user-oriented client implementation SHOULD inform the user of the failure via appropriate user-interface elements.</p>
|
||||
<example caption='An ack'><![CDATA[
|
||||
S: <a xmlns='urn:xmpp:tmp:sm' b='1'/>
|
||||
S: <a xmlns='urn:xmpp:sm:0' b='1'/>
|
||||
]]></example>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Stream Pings' anchor='pings'>
|
||||
<p>Either entity can also ping the other, useful for ensuring that the TCP connection is still up and working, and also determining latency. The procedure is intended to replace the legacy behavior of sending whitespace. Pinging is done by sending a 'ping' element:</p>
|
||||
<p>Either entity can also ping the other. This is useful for ensuring that the TCP connection is still up and working, and also for determining latency. The procedure is intended to replace the legacy behavior of sending whitespace. Pinging is done by sending a 'ping' element:</p>
|
||||
<example caption='Pinging the Peer'><![CDATA[
|
||||
<sm:ping/>
|
||||
<ping xmlns='urn:xmpp:sm:0'/>
|
||||
]]></example>
|
||||
<p>The peer then MUST reply immediately with a 'pong' element.</p>
|
||||
<example caption='Replying to a Ping'><![CDATA[
|
||||
<sm:pong/>
|
||||
<pong xmlns='urn:xmpp:sm:0'/>
|
||||
]]></example>
|
||||
<p>A server that is throttling stanzas (and thus withholding acks until later) SHOULD still immediately reply to pings.</p>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Stream Resumption' anchor='resumption'>
|
||||
<p>It can happen that an XML stream is terminated temporarily and involuntarily (e.g., because of network outages). In this case, it is desirable to quickly resume the former stream rather than complete the tedious process of stream establishment..</p>
|
||||
<p>The <enable/> element MAY contain a 'resume' attribute with value 'yes', to request that the acknowledgement session be made resumable. The <enable/> element MAY also contain a 'previd' attribute and a 'b' attribute, if the initiating entity wishes to resume a previously known acknowledgement session. The value of the 'previd' attribute is set to the same value as the 'id' attribute of the acknowledgement feature element in the previous session. The value of the 'b' attribute, if applicable, is set to the last received sequence number (discussed below) by the initiating entity. If the initiating entity is not resuming a past session, the 'previd' and 'b' attributes MUST NOT be included.</p>
|
||||
<p>It can happen that an XML stream is terminated temporarily and involuntarily (e.g., because of network outages). In this case, it is desirable to quickly resume the former stream rather than complete the tedious process of stream establishment.</p>
|
||||
<p>The <enable/> element MAY contain a 'resume' attribute with value "true" or "1", to request that the stream management session be made resumable. The <enable/> element MAY also contain a 'previd' attribute and a 'b' attribute, if the initiating entity wishes to resume a previously known stream management session. The value of the 'previd' attribute is set to the same value as the 'id' attribute of the acknowledgement feature element in the previous session. The value of the 'b' attribute, if applicable, is set to the last received sequence number (discussed below) by the initiating entity. If the initiating entity is not resuming a past session, the 'previd' and 'b' attributes MUST NOT be included.</p>
|
||||
<example caption='Client enables stream management with stream resumption'><![CDATA[
|
||||
C: <sm:enable resume='true'/>
|
||||
C: <enable xmlns='urn:xmpp:sm:0' resume='true'/>
|
||||
]]></example>
|
||||
<example caption='Session Resumption Request'><![CDATA[
|
||||
<sm:resume/>
|
||||
<resume xmlns='urn:xmpp:sm:0'/>
|
||||
]]></example>
|
||||
<p>If the initiating entity provided a 'resume' attribute in the <enable/> element, and the receiving entity supports session resumption, then the receiving entity MAY provide a 'resume' attribute (with value 'yes') in the <enabled/> element to indicate that the session shall be resumable. If the initiating entity provided a 'previd' attribute in the <enable/> element, and the receiving entity supports session resumption, then the receiving entity MAY provide a 'b' attribute in the <enabled/> element. The value of this attribute is set to the last received sequence number (discussed below) by the receiving entity in the previous session. If the receiving entity does not support session resumption, or does not recognize the 'previd' as an earlier session, or there is no known last received sequence number for the session, then the attribute MUST NOT be included. If session resumption is used, and the receiving entity still has the stream for the previously-identified session open at this time, the old stream SHOULD be terminated.</p>
|
||||
<p>If the initiating entity provided a 'resume' attribute in the <enable/> element, and the receiving entity supports session resumption, then the receiving entity MAY provide a 'resume' attribute (with value "true" or "1") in the <enabled/> element to indicate that the session shall be resumable. If the initiating entity provided a 'previd' attribute in the <enable/> element, and the receiving entity supports session resumption, then the receiving entity MAY provide a 'b' attribute in the <enabled/> element. The value of this attribute is set to the last received sequence number (discussed below) by the receiving entity in the previous session. If the receiving entity does not support session resumption, or does not recognize the 'previd' as an earlier session, or there is no known last received sequence number for the session, then the attribute MUST NOT be included. If session resumption is used, and the receiving entity still has the stream for the previously-identified session open at this time, the old stream SHOULD be terminated.</p>
|
||||
<example caption='Session Resumed'><![CDATA[
|
||||
<sm:resumed/>
|
||||
<resumed xmlns='urn:xmpp:sm:0'/>
|
||||
]]></example>
|
||||
<p>Note: When performing session resumption and also utilizing TLS, it is RECOMMENDED to take advantage of TLS session resumption to further optimize the resumption of the XML stream.</p>
|
||||
<p>We then assume that the client gets disconnected (e.g., because it has roamed into an area without connectivity). When the client once again has network connectivity, it attempts to resume its session.</p>
|
||||
<example caption='Client attempt to resume a previous session:'><![CDATA[
|
||||
<sm:resume previd='some-long-sm-id'/>
|
||||
<resume xmlns='urn:xmpp:sm:0' previd='some-long-sm-id'/>
|
||||
]]></example>
|
||||
<example caption='Server informs client that session is resumed:'><![CDATA[
|
||||
<sm:resume b='7'/>
|
||||
<resume xmlns='urn:xmpp:sm:0' b='7'/>
|
||||
]]></example>
|
||||
<p>When a session is resumed, and resource binding is completed (if required), both the initiating entity and the receiving entity SHOULD retransmit any stanzas that were not accepted during the previous session, each based on the last received sequence number reported by the other. A client SHOULD NOT request the roster after resumption, because any changes to the roster while the client was disconnected will be sent to the client after it resumes. Similarly, the client SHOULD NOT resend presence stanzas in an act to restore its original presence state, as this state will have been retained by the server.</p>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Implementation Notes' anchor='impl'>
|
||||
<p>To save bandwidth, it is RECOMMENDED that implementations specify an XML namespace prefix assignment in the initial <stream> element for the 'urn:xmpp:tmp:sm' namespace, and that this prefix be as brief as possible.</p>
|
||||
<example caption='Setting a Namespace Prefix'><![CDATA[
|
||||
<stream:stream
|
||||
to='example.com'
|
||||
xmlns='jabber:client'
|
||||
xmlns:stream='http://etherx.jabber.org/streams'
|
||||
xmlns:sm='urn:xmpp:tmp:sm'
|
||||
version='1.0'>
|
||||
]]></example>
|
||||
<example caption='Acking'><![CDATA[
|
||||
<sm:a/>
|
||||
]]></example>
|
||||
<p>Stream management elements SHOULD be sent in the same TCP packet as XMPP stanzas, to reduce the number of total packets sent. In particular, if a request ack is received, an applications MAY wait a short period for something else to send before responding, so that the response ack can share a TCP packet with the other data.</p>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Minimal Implementation Guideline' anchor='guideline'>
|
||||
<p>The Stream Management protocol has a complex appearance, and indeed it is complex to implement if you want to perform all of the optimizations allowed. However, a basic implementation is not very difficult, if you just want simple acking and don't care about sequence numbers too much. Here is what a basic implementation would do:</p>
|
||||
<ul>
|
||||
@ -216,7 +213,7 @@ C: <sm:enable resume='true'/>
|
||||
<li>When receiving an <r/> or <a/> element with a 'c' attribute, immediately respond with an <a/> element with a value of 'b' equal to the value of 'c' received.</li>
|
||||
<li>Keep an integer X for this stream session, initially set to zero. When you are about to send a stanza, first put the stanza (paired with the current value of X) in an "unacknowleged" queue. Then send the stanza over the wire followed by <r c='[value of X]'/>, and increment X by 1. When receiving an <r/> or <a/> element with a 'b' attribute, all stanzas whose paired value (X at the time of queuing) is less than or equal to the value of 'b' can be removed from the queue.</li>
|
||||
</ul>
|
||||
<p>This is enough of an implementation to minimally satisfy the remote entity, and allows basic tracking of your own stanzas sent. If the stream connection is broken, you have a queue of unacknowledged stanzas that you can choose to do something with.</p>
|
||||
<p>This is enough of an implementation to minimally satisfy the remote entity, and allows basic tracking of your own stanzas sent. If the stream connection is broken, you have a queue of unacknowledged stanzas that you can choose to handle appropriately (e.g., warned the sending user or send on reconnect).</p>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Security Considerations' anchor='security'>
|
||||
@ -228,12 +225,18 @@ C: <sm:enable resume='true'/>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Jabber Registrar Considerations' anchor='registrar'>
|
||||
<section2 topic='Protocol Namespaces' anchor='ns'>
|
||||
<p>Until this specification advances to a status of Draft, its associated namespace shall be "urn:xmpp:tmp:sm"; upon advancement of this specification, the ®ISTRAR; shall issue a permanent namespace in accordance with the process defined in Section 4 of &xep0053;.</p>
|
||||
<p>The namespace 'urn:xmpp:sm' is requested, and is thought to be unique per the XMPP Registrar's requirements.</p>
|
||||
<section2 topic='Protocol Namespaces' anchor='registrar-ns'>
|
||||
<p>This specification defines the following XML namespace:</p>
|
||||
<ul>
|
||||
<li>urn:xmpp:sm:0</li>
|
||||
</ul>
|
||||
<p>Upon advancement of this specification from a status of Experimental to a status of Draft, the ®ISTRAR; shall add the foregoing namespaces to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
|
||||
</section2>
|
||||
<section2 topic='Protocol Versioning' anchor='registrar-versioning'>
|
||||
<p>If the protocol defined in this specification undergoes a major revision that is not fully backward-compatible with an older version, or that contains significant new features, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of <cite>XEP-0053</cite>.</p>
|
||||
</section2>
|
||||
<section2 topic='Stream Features' anchor='registrar-stream'>
|
||||
<p>Upon approval of this specification, the XMPP Registrar shall add 'urn:xmpp:tmp:sm:feature' to its registry of stream features.</p>
|
||||
<p>Upon approval of this specification, the XMPP Registrar shall add 'urn:xmpp:sm:0:feature' to its registry of stream features.</p>
|
||||
</section2>
|
||||
</section1>
|
||||
|
||||
@ -243,8 +246,8 @@ C: <sm:enable resume='true'/>
|
||||
|
||||
<xs:schema
|
||||
xmlns:xs='http://www.w3.org/2001/XMLSchema'
|
||||
targetNamespace='urn:xmpp:tmp:sm'
|
||||
xmlns='urn:xmpp:tmp:sm'
|
||||
targetNamespace='urn:xmpp:sm:0'
|
||||
xmlns='urn:xmpp:sm:0'
|
||||
elementFormDefault='qualified'>
|
||||
|
||||
<xs:element name='a' type='empty'/>
|
||||
@ -300,4 +303,8 @@ C: <sm:enable resume='true'/>
|
||||
]]></code>
|
||||
</section1>
|
||||
|
||||
<section1 topic='Acknowledgements' anchor='ack'>
|
||||
<p>Thanks to Dave Cridland for his feedback.</p>
|
||||
</section1>
|
||||
|
||||
</xep>
|
||||
|
Loading…
Reference in New Issue
Block a user