This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

LWM2M Local port setting doesn't have any effect. Random port doesn't work.(nRF9160)

Hi,

One of my customers is applying LWM2M to their target application.

And they are trying to fix LOCAL PORT of LWM2M.

I heard that when end equipment is registered on server, IP/Port of end equipment is also detected by server.

So, if Port of client is changed, The leshan server commands initialization.

They say that this makes an effect to end equipment operation. 

They checked how to change LOCAL PORT of LWM2M.

Zephyr version v1.14.1 had following definitions.

https://docs.zephyrproject.org/1.14.1/reference/kconfig/index.html

CONFIG_LWM2M_LOCAL_PORT

CONFIG_LWM2M_PEER_PORT

But in case of Zephyr version v2.3.0, Items Above couldn't be found.

https://docs.zephyrproject.org/2.3.0/reference/kconfig/index-all.html

It's found only CONFIG_LWM2M_PEER_PORT.

So To test this, they modified Kconfig file in folder in zephyr\subsys\net\lib\lwm2m.

The added texts below.

After above, Configurations of nRF connect SDK seems to be applied.

But Test result is not ok.

Could you check that CONFIG_LWM2M_LOCAL_PORT could be used on LWM2M project?

Best Regards

James Lee

Parents
  • Hi,

    First, when using NCS, you should use the NCS version of Zephyr's documentation, and not the upstream version.

    That way, you can be sure that you are seeing the correct version for the NCS version you are on. In addition, there might be some changes to the documentation to match the changes we have done downstream (though these should be minimal).

     

    So To test this, they modified Kconfig file in folder in zephyr\subsys\net\lib\lwm2m.

     

    After above, Configurations of nRF connect SDK seems to be applied.

    But Test result is not ok.

     The Kconfig options just end up as #defines. If the code doesn't use them, they don't do anything. If the option has been removed, the code that used the option has most likely also been removed, so simply adding the option back in will not do anything.

    But, you should be able to to add the functionality as well by finding the place where the socket is created, and bind()-ing it to a fixed port number.

    Best regards,

    Didrik

  • Hi, Didrick

    Thank you for your reply.

    You mentioned like this.

    "But, you should be able to to add the functionality as well by finding the place where the socket is created, and bind()-ing it to a fixed port number."

    Because i have poor experiences of LWM2M , Would you advise more how to binding it to fixed port number?

    or If it's not easy and possible fixing port number, Could you answer following questions?

    They changed updated time of LWM2M registration(CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME) to 34200 seconds.

    The default was 30 seconds.

    If CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is  30 seconds and when LWM2M client notify observer, Local port isn't changed. 

    But if CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is setup to 34200 seconds, Local port is changed.

    Could you inform how to setup 'time when binding port setting is released'?

    Thank you very much.

  • In NCS v1.4.0, the socket is created in the lwm2m_socket_start function in zephyr/subsys/net/lib/lwm2m/lwm2m_engine.c.

    Once socket has been created, and stored in client_ctx->sock_fd, you can bind it to an address using bind().

    You can find the documentation for bind() here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html

     

    James_Lee_K said:

    If CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is  30 seconds and when LWM2M client notify observer, Local port isn't changed. 

    But if CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is setup to 34200 seconds, Local port is changed.

     This sounds like a NAT timeout in the network. In the networks we have tested, the network will delete the entry in the translation table after ~1 minute of inactivity for UDP traffic.

    But, we have also seen both shorter and longer timeouts.

Reply
  • In NCS v1.4.0, the socket is created in the lwm2m_socket_start function in zephyr/subsys/net/lib/lwm2m/lwm2m_engine.c.

    Once socket has been created, and stored in client_ctx->sock_fd, you can bind it to an address using bind().

    You can find the documentation for bind() here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html

     

    James_Lee_K said:

    If CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is  30 seconds and when LWM2M client notify observer, Local port isn't changed. 

    But if CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME is setup to 34200 seconds, Local port is changed.

     This sounds like a NAT timeout in the network. In the networks we have tested, the network will delete the entry in the translation table after ~1 minute of inactivity for UDP traffic.

    But, we have also seen both shorter and longer timeouts.

Children
No Data
Related