Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify tid is not being re-used in a session #178

Merged
merged 1 commit into from
May 18, 2018

Conversation

mrdeep1
Copy link
Collaborator

@mrdeep1 mrdeep1 commented Apr 27, 2018

Check that the same tid is not getting re-used in violation of RFC7252
in coap_session_delay_pdu().

To prevent duplication issues highlighted in Issue #163 as per below

It looks like you are calling coap_send() for the same PDU 3 times - correct? (sent at 17:09:57, 17:09:59 and 17:10:01)

Check that the same tid is not getting re-used in violation of RFC7252
in coap_session_delay_pdu()
@hongnguyen-tma
Copy link

hongnguyen-tma commented May 2, 2018

Hi mrdeep1
Does this mean that libcoap will not allow higher layer to resend a message? Libcoap just retransmits confirmable message, so for those higher layers that use non-confirmable message, they would need to resend the message by themselves until receiving a response from server.

Hong

@mrdeep1
Copy link
Collaborator Author

mrdeep1 commented May 2, 2018

Hi Hong,

The TID is the same thing as the RFC7252 Message ID. If a client elects to send multiple non-confirmable with the same TID (subject to certain rules), it is the responsibility of the server to act only once for the same TID.

"RFC7252: 4.3. Messages Transmitted without Reliability" : A sender MAY choose to
transmit multiple copies of a Non-confirmable message within
MAX_TRANSMIT_SPAN (limited by the provisions of Section 4.7, in
particular, by PROBING_RATE if no response is received), or the
network may duplicate the message in transit. To enable the receiver
to act only once on the message, Non-confirmable messages specify a
Message ID as well.

So, yes, the client application can re-transmit non-confirmable messages with the same TID. However, all of this message layer is replaced when doing CoAP over TCP

"RFC8323: 3. CoAP over TCP" : The request/response interaction model of CoAP over TCP is the same
as CoAP over UDP. The primary differences are in the message layer.
The message layer of CoAP over UDP supports optional reliability by
defining four types of messages: Confirmable, Non-confirmable,
Acknowledgment, and Reset. In addition, messages include a
Message ID to relate Acknowledgments to Confirmable messages and to
detect duplicate messages.

The code change is in coap_session_delay_pdu(). It is there to make sure that there are not 2 nodes (which point to the PDUs) in the transmit queue that have the same TID which would then cause an assert() when the wrong node (but with the same TID) is removed from the queue. As far as I can tell from the code, the only time that a non-confirmable PDU is added to the transmit queue is when the logic is waiting for DTLS to come up, or there is a previous PDU that failed to get sent in coap_socket_write(). So, if you try to resend the same non-confirmable PDU using coap_send() when there is already one waiting to be sent with the same TID, it will get dropped (and the pdu deleted in coap_send() as bytes_written is < 0).

@obgm obgm merged commit 9f68329 into obgm:develop May 18, 2018
@mrdeep1 mrdeep1 deleted the tid-duplication branch May 18, 2018 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants