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

Question about RegistrationStore#getRegistrationByAdress #464

Closed
AlexITC opened this issue Feb 2, 2018 · 7 comments
Closed

Question about RegistrationStore#getRegistrationByAdress #464

AlexITC opened this issue Feb 2, 2018 · 7 comments
Labels
bug Dysfunctionnal behavior server Impact LWM2M server

Comments

@AlexITC
Copy link
Contributor

AlexITC commented Feb 2, 2018

As I understand, the Identity object was added to the Registration in order to differentiate clients that are connecting by the same IP address and port.

If this understanding is correct, shouldn't this method return a list instead of a single value?

Thanks.

@AlexITC AlexITC changed the title Question about RegistrationStore#getByAddress Question about RegistrationStore#getRegistrationByAdress Feb 2, 2018
@sbernard31
Copy link
Contributor

Good question!

RegistrationByAddress is used when LWM2M Server will try to initiate a handshake using PSK. This is the case where the LWM2M server act as DTLS Client => this is strange use case but this could happen.

What happen exactly, when you send data via DtlsConnector to a peer for which you have not DTLS session? The DtlsConnector will try to initiate an Handshake. If you are a LWM2M server and you are using PSK you should guess which PSK to use to establish a handshake with the device. To do that the API of DtlsConnector will ask for the psk to use for the peer with this address. (see LwM2mPskStore.getIdentity(InetSocketAddress))

Currently, Leshan server search in RegistrationStore to find which registration is used for this address and so find PSK to use.
But you're right, there are cases where you could have 2 registration with the same address. (Devices with dynamic IP e.g. in NAT environment + QueueMode).
This does not means that there is 2 devices with the same IP (this is a use case we don't want to support)
This means that 1 device uses the old IP to another device which are sleeping(QueueMode) .

Currently our default RegistrationStore implementation just take the first registration found. This is an issue.

I think about 3 way to solve this issue without Californium modification :

  1. When a device register itself or update its registration. If IP is already in use, remove peer address from old registration. (So we will have Registration without ip address :/ )
  2. RegistrationStore#getByAddress should return the more recent one. (using last update ?)
  3. RegistrationStore#getByAddress should return a list and this is LwM2mPskStore which is responsible to take the more recent one (still using last update).

I don't know what is the best solution 2. or 3. seems better to me.
2. can already be implemented (we should add some javadoc for implementers).
3. need API modifications (but maybe a more simple javadoc)
2. is maybe more easy to implement with index because we just need to keep and index to the last registration which use this IP.

I hope my comment is almost understandable.

@sbernard31 sbernard31 added bug Dysfunctionnal behavior server Impact LWM2M server labels Feb 2, 2018
@AlexITC
Copy link
Contributor Author

AlexITC commented Feb 2, 2018

Interesting, personally I would go with the 3rd point because that give the client (who uses the APi) to make the choice and we should not return too many results anyway. As you said 3 needs API modifications.

Thanks.

@sbernard31
Copy link
Contributor

What do you mean by "that give the client (who uses the APi) to make the choice" ?

@AlexITC
Copy link
Contributor Author

AlexITC commented Feb 2, 2018

I should have said the developer who uses the API, as you said, we could choose to use any suitable strategy if we have all the results.

@sbernard31
Copy link
Contributor

Not exactly as LwM2mPskstore is not really indented to be implemented by "developer who uses the API".

@sbernard31
Copy link
Contributor

I provide a PR #517 to fix this issue.

@sbernard31
Copy link
Contributor

This is fixed in master since #517 in integrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Dysfunctionnal behavior server Impact LWM2M server
Projects
None yet
Development

No branches or pull requests

2 participants