Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Generate random message id. #29

Closed
wants to merge 2 commits into from

Conversation

sbernard31
Copy link
Contributor

About message ID, the CoAP specification say :

"4.4. Message Correlation ...
... Several implementation strategies can be employed for generating Message IDs. ... ... It is strongly recommended that the initial value of the variable (e.g., on startup) be randomized, in order to make successful off-path attacks on the protocol less likely."

So, I propose to replace the predictible way to generate message ID by using srand() and rand() from stdlib.

@dnav
Copy link

dnav commented Apr 17, 2014

Hi,

Nice idea. However I can see two problems with your patch:

  • the message ID is 16-bits long. So the result of rand() will be truncated and we might have collisions.
  • Even if the rand() is limited to 16-bits, we will have collisions sooner than with a linear progression.

To be aligned with the CoAP specs, I would suggest to just initialize the lwm2m_contxt_t::nextMID with rand().

@sbernard31
Copy link
Contributor Author

You're right, I will fix that :)

@dnav
Copy link

dnav commented Mar 10, 2016

Project moved to http://github.com/eclipse/wakaama

@dnav dnav closed this Mar 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants