From 41ec50a11c35fa66e0bd680eea1b4bb5c8d0ced8 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 27 Jun 2018 20:28:12 +0200 Subject: [PATCH 1/2] XEP-0198: Clarify the note about counters The note was only 50% correct (the counter the note talks get initialized and started when the entity receives , and not when it is sent) and partly misleading (there are typically four counters per stream). Most XEP-0198 Stream Management implementations I am aware of didn't get the counters right at the first time. The tricky part is to get the time right where the counters should be set to zero and get started. The new note's text tries to help implementers with this. As bonus, it is also shorter than the original note. --- xep-0198.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xep-0198.xml b/xep-0198.xml index 854f9689..9373bf05 100644 --- a/xep-0198.xml +++ b/xep-0198.xml @@ -28,6 +28,12 @@ &fabio; &dcridland; &mwild; + + 1.5.3 + 2017-06-27 + fs +

Improve the note about stream management counters in section 4.

+
1.5.2 2016-12-08 @@ -275,7 +281,7 @@

Definition: Acknowledging a previously-received ack element indicates that the stanza(s) sent since then have been "handled" by the server. By "handled" we mean that the server has accepted responsibility for a stanza or stanzas (e.g., to process the stanza(s) directly, deliver the stanza(s) to a local entity such as another connected client on the same server, or route the stanza(s) to a remote entity at a different server); until a stanza has been affirmed as handled by the server, that stanza is the responsibility of the sender (e.g., to resend it or generate an error if it is never affirmed as handled by the server).

Receipt of an <r/> element does not imply that new stanzas have been transmitted by the peer; receipt of an <a/> element only indicates that new stanzas have been processed if the 'h' attribute has been incremented.

The value of 'h' starts at zero at the point stream management is enabled or requested to be enabled (see note below). The value of 'h' is then incremented to one for the first stanza handled and incremented by one again with each subsequent stanza handled. In the unlikely case that the number of stanzas handled during a stream management session exceeds the number of digits that can be represented by the unsignedInt datatype as specified in &w3xmlschema2; (i.e., 232), the value of 'h' SHALL be reset from 232-1 back to zero (rather than being incremented to 232).

-

Note: There are two values of 'h' for any given stream: one maintained by the client to keep track of stanzas it has handled from the server, and one maintained by the server to keep track of stanzas it has handled from the client. The client initializes its value to zero when it sends <enable/> to the server, and the server initializes its value to zero when it sends <enabled/> to the client (it is expected that the server will respond immediately to <enable/> and set its counter to zero at that time). After this initialization, the client increments its value of 'h' for each stanza it handles from server, and the server increments its value of 'h' for each stanza it handles from the client.

+

Note: There are four stream management counters for any given stream: Every side of the stream maintains a counter of its own send stanzas and a counter of the received and handled stanzas ('h'). The counter for an entities own send stanzas is set to zero and started after sending either <enable/> or <enabled/>. The counter for the received stanzas ('h') is set to zero and started after receiving either <enable/> or <enabled/>.

The following annotated example shows a message sent by the client, a request for acknowledgement, and an ack of the stanza.

From a414185274e3d8d3c4c3fe75d1f4e157e00fca95 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 29 Jun 2018 13:47:55 +0100 Subject: [PATCH 2/2] XEP-0198: Clarify the note about counters Many implementations have failed to get this right on their first attempt, and so this text aims to clarify the logic required for an implementation to correctly maintain its counters for a stream. The text was 95% based on text originally proposed by Florian Schmaus, but I find it a bit clearer and fixed some grammar in the process. --- xep-0198.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xep-0198.xml b/xep-0198.xml index 9373bf05..38c8a4af 100644 --- a/xep-0198.xml +++ b/xep-0198.xml @@ -30,8 +30,8 @@ &mwild; 1.5.3 - 2017-06-27 - fs + 2017-06-29 + fs/mw

Improve the note about stream management counters in section 4.

@@ -281,7 +281,7 @@

Definition: Acknowledging a previously-received ack element indicates that the stanza(s) sent since then have been "handled" by the server. By "handled" we mean that the server has accepted responsibility for a stanza or stanzas (e.g., to process the stanza(s) directly, deliver the stanza(s) to a local entity such as another connected client on the same server, or route the stanza(s) to a remote entity at a different server); until a stanza has been affirmed as handled by the server, that stanza is the responsibility of the sender (e.g., to resend it or generate an error if it is never affirmed as handled by the server).

Receipt of an <r/> element does not imply that new stanzas have been transmitted by the peer; receipt of an <a/> element only indicates that new stanzas have been processed if the 'h' attribute has been incremented.

The value of 'h' starts at zero at the point stream management is enabled or requested to be enabled (see note below). The value of 'h' is then incremented to one for the first stanza handled and incremented by one again with each subsequent stanza handled. In the unlikely case that the number of stanzas handled during a stream management session exceeds the number of digits that can be represented by the unsignedInt datatype as specified in &w3xmlschema2; (i.e., 232), the value of 'h' SHALL be reset from 232-1 back to zero (rather than being incremented to 232).

-

Note: There are four stream management counters for any given stream: Every side of the stream maintains a counter of its own send stanzas and a counter of the received and handled stanzas ('h'). The counter for an entities own send stanzas is set to zero and started after sending either <enable/> or <enabled/>. The counter for the received stanzas ('h') is set to zero and started after receiving either <enable/> or <enabled/>.

+

Note: Each entity maintains two counters for any given stream: a counter of stanzas it has sent, and a counter of stanzas it has received and handled ('h'). The counter for an entity's own sent stanzas is set to zero and started after sending either <enable/> or <enabled/>. The counter for the received stanzas ('h') is set to zero and started after receiving either <enable/> or <enabled/>.

The following annotated example shows a message sent by the client, a request for acknowledgement, and an ack of the stanza.