eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
652 stars 407 forks source link

What is the best strategy for constrained networks? #444

Closed amq closed 6 years ago

amq commented 6 years ago

I have a device which has a very bandwidth of under 1MB per month and a small battery. Is LWM2M / Leshan a good fit? If so, how should I approach it?

My current understanding is that it is necessary to subscribe after each device registration. This brings a significant overhead when dealing with devices on constrained networks. Say, I would like to send a short message every 30 minutes, as a result, the whole registration and observation requests will take much more bandwidth than the payload + they will increase the transmission time.

Alternatively to observing, I could read, but compared to mqtt-style unsolicited messages, it will still consume more bandwidth.

Having to send requests to the device to read out data also fells fragile.

Is it possible for the device to send unsolicited messages or to start observation? Is it possible to make observation request part of the registration?

sbernard31 commented 6 years ago

Is LWM2M / Leshan a good fit?

You're talking about "Leshan Client" right ? If so, it's hard to say ... we mainly use Leshan client for testing or simulating device. But we would really appreciate feedback about this kind of use.

You say you want to send message each 30 minutes. This is not really the idea behind the LWM2M spec. Clients register to server, then server send requests to clients. Using an observe request is the closest approach to the use case you describe.

So this will look like this:

  1. the device register to the server.
  2. just after the registration, the server send 1 observe request for each resource to monitor.
  3. each time this resource changes the device will send a new notification. (no need to register and send observe request each time)

The other solution is to use polling (send read request every 30 minutes), I'm not sure to understand why you fells it fragile ? (hard to say without a more complete description of the use case)

In all case you should send registration update periodically to maintain the registration alive (up to you to define the filetime registration)

Is it possible for the device to send unsolicited messages or to start observation?

Unfortunately this is not allowed by the LWM2M spec... see https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues/171

Is it possible to make observation request part of the registration?

I'm not sure to understand what this could look like ?

amq commented 6 years ago

Thank you for the reply!

You're talking about "Leshan Client" right ?

Instead of leshan client I've rather meant wakaama or mbed-client.

You say you want to send message each 30 minutes. This is not really the idea behind the LWM2M spec.

To achieve the 30 minutes I was thinking to either limit when the resources are set on the device (ie instead of setting immediately, set all at a specific time), or use pmin.

no need to register and send observe request each time

The reason why I mentioned registering and observing each time is that I would like to disconnect the modem right after sending to save battery. Is it realistic to keep the registration in that case, even with a long lifetime?

I'm not sure to understand why you fells it fragile

I feel that server->device->server over cellular is more fragile than device->server, mainly because it involves the server contacting the device, which may not be ready to receive at that moment.

Is it possible to make observation request part of the registration?

I was thinking that the server could request observation together with the "registered" response to client, so that I don't have to monitor registrations and send requests externally. I was trying to send observation requests in EventServlet.java / registered(), but I couldn't make it work even with delays and retries.

sbernard31 commented 6 years ago

To achieve the 30 minutes I was thinking to either limit when the resources are set on the device or use pmin.

I didn't play with write attributes but this should work with pmin.

Is it realistic to keep the registration in that case, even with a long lifetime?

Queue mode is done for this kind of use case.

mainly because it involves the server contacting the device, which may not be ready to receive at that moment.

With Queue mode request will be send when device wake up. (server is aware of that when it receive an update request)

I was thinking that the server could request observation together with the "registered" response to client.

You can send a observe request when you receive a register request. But response and request will be not send in the same udp packet.

I was trying to send observation requests in EventServlet.java / registered(), but I couldn't make it work even with delays and retries.

This should works... It seems you are using Leshan Server Demo to test ? Does it work when you send request via the Web UI ?

sbernard31 commented 6 years ago

Is it clearer, Could I close this one?