OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

mqtt-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Receive Maximum quota operation


Hi,

I'm implementing a MQTT client and broker library.
I have a question about quota increment/decrement operation for Flow Control.

The spec said that the quota increment/decrement timing is as follows:
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901251

Decrementing
> Each time the Client or Server sends a PUBLISH packet at QoS > 0, it decrements the send quota.

Incrementing
> The send quota is incremented by 1:
> - Each time a PUBACK or PUBCOMP packet is received, regardless of whether the PUBACK or PUBCOMP carried an error code.
> - Each time a PUBREC packet is received with a Return Code of 0x80 or greater.
>
> The send quota is not incremented if it is already equal to the initial send quota. The attempt to increment above the initial send quota might be caused by the re-transmission of a PUBREL packet after a new Network Connection is established.

What does "if it is already equal to the initial send quota" mean?

I guess that means as follows:

1. A client CONNECT to the broker.
2. The broker CONNACK (ReceiveMaximum 4) to the client. (Client quota is 4)

3. The client PUBLISH (QoS2, Packet Identifier 50) to the broker.
(Client quota is 3)
4. The broker PUBREC(Reason Code Success, Packet Identifier 50) to the client.
5. The client PUBREL (Reason Code Success, Packet Identifier 50) to the broker.

6. Disconnect.
7. The client CONNECT to the broker. (Session Exists)
8. The broker CONNACK (ReceiveMaximum 4) to the client. (Client quota
is reset to 4)

9. The client re-PUBREL (Reason Code Success, Packet Identifier 50) to
the broker.
10. The broker PUBCOMP(Reason Code Success, Packet Identifier 50) to the client.

At step 10, if the quota is incremented then it would become 5.
It is over the ReceiveMaximum value.
So I guess "if it is already equal to the initial send quota" means
CONNACK's Receive Maximum 4.
At step 10, the quota is already equal to 4 (initial send quota), so
the quota isn't incremented.

Am I understanding correctly ?

So far, so good

However, what happens in the following case ?

1. A client CONNECT to the broker.
2. The broker CONNACK (ReceiveMaximum 4) to the client. (Client quota is 4)

3. The client PUBLISH (QoS2, Packet Identifier 50) to the broker.
(Client quota is 3)
4. The client PUBLISH (QoS2, Packet Identifier 51) to the broker.
(Client quota is 2)
5. The client PUBLISH (QoS2, Packet Identifier 52) to the broker.
(Client quota is 1)
6. The client PUBLISH (QoS2, Packet Identifier 53) to the broker.
(Client quota is 0)

7. The broker PUBREC(Reason Code Success, Packet Identifier 50) to the client.
8. The broker PUBREC(Reason Code Success, Packet Identifier 51) to the client.

9. The client PUBREL (Reason Code Success, Packet Identifier 50) to the broker.
10. The client PUBREL (Reason Code Success, Packet Identifier 51) to the broker.

11. Disconnect.
12. The client CONNECT to the broker. (Session Exists)
13. The broker CONNACK (ReceiveMaximum 4) to the client. (Client quota
is reset to 4)

14. The client re-PUBLISH (QoS2, Packet Identifier 52) to the broker.
(Client quota is 3)
15. The client re-PUBLISH (QoS2, Packet Identifier 53) to the broker.
(Client quota is 2)
16. The client re-PUBREL (Reason Code Success, Packet Identifier 50)
to the broker.
17. The client re-PUBREL (Reason Code Success, Packet Identifier 51)
to the broker.

18. The broker PUBCOMP(Reason Code Success, Packet Identifier 50) to
the client. (Client quota is 3)
19. The broker PUBCOMP(Reason Code Success, Packet Identifier 51) to
the client. (Client quota is 4)

Now, the client can four more  PUBLISH (QoS1 or 2). But two PUBLISH
(step 14 and 15) are processing now.
If the client sends four PUBLISH packets, the broker needs to process
six PUBLISH packets.

The problem is caused by at step 18 and 19. The PUBCOMP is
corresponding to the re-sent PUBREL packets.
If the quota is not incremented when the client receives PUBCOMP
corresponding to the re-sent PUBREL, Receive Maximum works correctly.

In order to behave as that, the following description should be updated:

Before

> The send quota is incremented by 1:
> - Each time a PUBACK or PUBCOMP packet is received, regardless of whether the PUBACK or PUBCOMP carried an error code.
> - Each time a PUBREC packet is received with a Return Code of 0x80 or greater.
>
> The send quota is not incremented if it is already equal to the initial send quota. The attempt to increment above the initial send quota might be caused by the re-transmission of a PUBREL packet after a new Network Connection is established.

After (example)

> The send quota is incremented by 1:
> - Each time a PUBACK packet is received, regardless of the PUBACK carried an error code.
> - Each time a PUBCOMP packet is received except the PUBCOMP has the same Packet Identifier as the resent PUBREL packet, regardless the PUBCOMP carried an error code.
> - Each time a PUBREC packet is received with a Return Code of 0x80 or greater.

Any ideas?

---
Thanks,
Takatoshi


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]