Openthread Disconnect by Router / Parent Handling

Hello,

We use nrf-connect-sdk v1.9.1 (Zephyr v2.7 LTS)

We have a set of network devices. Both routers as sleepy-end-devices. 

The sleepy-end-devices connect to the network and stay in connected state as sleepy-end-devices.

However when we disconnect (remove power of) a (border)router, there is no notify in state change handler ( void ot_state_changed_handler(uint32_t flags, void *context) ).


With sending new messages, there is just no response, but no error code that the network connection is interrupted. And device stays in connected state. 

Can we enable disconnection handling?

Or it there a Openthread API function to check whether current connection state / link / parent is still valid? 

Thanks in advance!

Maurice

Parents
  • Further, I enabled 

    CONFIG_OPENTHREAD_PARENT_SEARCH=y
    CONFIG_OPENTHREAD_PARENT_SEARCH_BACKOFF_INTERVAL=60
    CONFIG_OPENTHREAD_PARENT_SEARCH_CHECK_INTERVAL=60
    So the end device is nicely switching between Routers. However when I force unpower the current parent router, it still sticks to this router as parent. And it never switches to another. Remaining in connected state to a non existing router. 
    There is no receiver parent response from the non-existing router but it has its rssi still in memory
    [01:26:48.826,934] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Backoff interval passed
    [01:26:48.827,026] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Parent RSS -70
    [01:26:48.827,117] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Parent RSS less than -65, searching for new parents
    [01:26:48.827,209] <inf> net_openthread: [INFO]-MLE-----: AttachState Idle -> Start
    [01:26:48.827,362] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: (Re)starting timer for backoff interval
    [01:26:48.828,399] <inf> net_openthread: [NOTE]-MLE-----: Attempt to attach - any-partition 
    [01:26:48.828,491] <inf> net_openthread: [INFO]-MLE-----: AttachState Start -> ParentReqRouters
    [01:26:48.829,833] <inf> net_openthread: [INFO]-MLE-----: Send Parent Request to routers (ff02:0:0:0:0:0:0:2)
    [01:26:48.834,014] <inf> net_openthread: [INFO]-MAC-----: Sent IPv6 UDP msg, len:84, chksum:f285, to:0xffff, sec:no, prio:net
    [01:26:48.834,259] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:48.834,472] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.288,299] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:8c4e, from:1ae86dd51a931d4f, sec:no, prio:net, rss:-80.0
    [01:26:49.288,543] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:18e8:6dd5:1a93:1d4f]:19788
    [01:26:49.288,757] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.289,825] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:18e8:6dd5:1a93:1d4f,0x1c00)
    [01:26:49.332,672] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:17ab, from:2e3bed05f5b5733c, sec:no, prio:net, rss:-76.0
    [01:26:49.332,885] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:2c3b:ed05:f5b5:733c]:19788
    [01:26:49.333,129] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.334,136] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:2c3b:ed05:f5b5:733c,0x5c00)
    [01:26:49.386,596] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:84, chksum:dfe3, from:9620d37e01240941, sec:no, prio:net, rss:-55.0
    [01:26:49.386,840] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:9420:d37e:124:941]:19788
    [01:26:49.387,054] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.580,017] <inf> net_openthread: [INFO]-MLE-----: AttachState ParentReqRouters -> ParentReqReeds
    [01:26:49.581,024] <inf> net_openthread: [INFO]-MLE-----: Send Parent Request to routers and REEDs (ff02:0:0:0:0:0:0:2)
    [01:26:49.586,151] <inf> net_openthread: [INFO]-MAC-----: Sent IPv6 UDP msg, len:84, chksum:4270, to:0xffff, sec:no, prio:net
    [01:26:49.586,395] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.586,608] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.959,503] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:c9c5, from:2e3bed05f5b5733c, sec:no, prio:net, rss:-76.0
    [01:26:49.959,716] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:2c3b:ed05:f5b5:733c]:19788
    [01:26:49.959,960] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.960,968] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:2c3b:ed05:f5b5:733c,0x5c00)
    [01:26:50.165,283] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:0136, from:1ae86dd51a931d4f, sec:no, prio:net, rss:-79.0
    [01:26:50.165,527] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:18e8:6dd5:1a93:1d4f]:19788
    [01:26:50.165,771] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:50.166,809] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:18e8:6dd5:1a93:1d4f,0x1c00)
    [01:26:50.831,237] <inf> net_openthread: [INFO]-MLE-----: AttachState ParentReqReeds -> Idle
Reply
  • Further, I enabled 

    CONFIG_OPENTHREAD_PARENT_SEARCH=y
    CONFIG_OPENTHREAD_PARENT_SEARCH_BACKOFF_INTERVAL=60
    CONFIG_OPENTHREAD_PARENT_SEARCH_CHECK_INTERVAL=60
    So the end device is nicely switching between Routers. However when I force unpower the current parent router, it still sticks to this router as parent. And it never switches to another. Remaining in connected state to a non existing router. 
    There is no receiver parent response from the non-existing router but it has its rssi still in memory
    [01:26:48.826,934] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Backoff interval passed
    [01:26:48.827,026] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Parent RSS -70
    [01:26:48.827,117] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: Parent RSS less than -65, searching for new parents
    [01:26:48.827,209] <inf> net_openthread: [INFO]-MLE-----: AttachState Idle -> Start
    [01:26:48.827,362] <inf> net_openthread: [INFO]-MLE-----: PeriodicParentSearch: (Re)starting timer for backoff interval
    [01:26:48.828,399] <inf> net_openthread: [NOTE]-MLE-----: Attempt to attach - any-partition 
    [01:26:48.828,491] <inf> net_openthread: [INFO]-MLE-----: AttachState Start -> ParentReqRouters
    [01:26:48.829,833] <inf> net_openthread: [INFO]-MLE-----: Send Parent Request to routers (ff02:0:0:0:0:0:0:2)
    [01:26:48.834,014] <inf> net_openthread: [INFO]-MAC-----: Sent IPv6 UDP msg, len:84, chksum:f285, to:0xffff, sec:no, prio:net
    [01:26:48.834,259] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:48.834,472] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.288,299] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:8c4e, from:1ae86dd51a931d4f, sec:no, prio:net, rss:-80.0
    [01:26:49.288,543] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:18e8:6dd5:1a93:1d4f]:19788
    [01:26:49.288,757] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.289,825] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:18e8:6dd5:1a93:1d4f,0x1c00)
    [01:26:49.332,672] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:17ab, from:2e3bed05f5b5733c, sec:no, prio:net, rss:-76.0
    [01:26:49.332,885] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:2c3b:ed05:f5b5:733c]:19788
    [01:26:49.333,129] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.334,136] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:2c3b:ed05:f5b5:733c,0x5c00)
    [01:26:49.386,596] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:84, chksum:dfe3, from:9620d37e01240941, sec:no, prio:net, rss:-55.0
    [01:26:49.386,840] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:9420:d37e:124:941]:19788
    [01:26:49.387,054] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.580,017] <inf> net_openthread: [INFO]-MLE-----: AttachState ParentReqRouters -> ParentReqReeds
    [01:26:49.581,024] <inf> net_openthread: [INFO]-MLE-----: Send Parent Request to routers and REEDs (ff02:0:0:0:0:0:0:2)
    [01:26:49.586,151] <inf> net_openthread: [INFO]-MAC-----: Sent IPv6 UDP msg, len:84, chksum:4270, to:0xffff, sec:no, prio:net
    [01:26:49.586,395] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.586,608] <inf> net_openthread: [INFO]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
    [01:26:49.959,503] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:c9c5, from:2e3bed05f5b5733c, sec:no, prio:net, rss:-76.0
    [01:26:49.959,716] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:2c3b:ed05:f5b5:733c]:19788
    [01:26:49.959,960] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:49.960,968] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:2c3b:ed05:f5b5:733c,0x5c00)
    [01:26:50.165,283] <inf> net_openthread: [INFO]-MAC-----: Received IPv6 UDP msg, len:129, chksum:0136, from:1ae86dd51a931d4f, sec:no, prio:net, rss:-79.0
    [01:26:50.165,527] <inf> net_openthread: [INFO]-MAC-----:     src:[fe80:0:0:0:18e8:6dd5:1a93:1d4f]:19788
    [01:26:50.165,771] <inf> net_openthread: [INFO]-MAC-----:     dst:[fe80:0:0:0:a442:8846:7c09:4b23]:19788
    [01:26:50.166,809] <inf> net_openthread: [INFO]-MLE-----: Receive Parent Response (fe80:0:0:0:18e8:6dd5:1a93:1d4f,0x1c00)
    [01:26:50.831,237] <inf> net_openthread: [INFO]-MLE-----: AttachState ParentReqReeds -> Idle
Children
  • Hi.

    I'm not sure if I fully understand the case, I've tried to reproduce the issue with our CLI sample on NCS v1.9.1.

    I've added a function in the main.c:

    static void on_thread_state_changed(uint32_t flags, void *context)
    {
      struct openthread_context *ot_context = context;
    
      if (flags & OT_CHANGED_THREAD_ROLE) {
        LOG_WRN("Thread state changed! new state: %d",otThreadGetDeviceRole(ot_context->instance));
      }
    
    }

    in main() I've added setting the callback:

    openthread_set_state_changed_cb(on_thread_state_changed);

    And built the sample with

    west build -p -b nrf52840dk_nrf52840 -- -DOVERLAY_CONFIG="overlay-logging.conf;overlay-rtt.conf"

    After flashing I've joined the network as SED (leader has been set up earlier with matching credentials):

    ot mode n
    
    ot channel 23
    
    ot panid 0xabcd
    
    ot networkkey  00112233445566778899aabbccddeeaa
    
    ot pollperiod 1000
    
    ot ifconfig up
    
    ot thread start

    And as expected, I get

    <wrn> cli_sample: Thread state changed! new state: 1

    when starting interface, and 

    <wrn> cli_sample: Thread state changed! new state: 2

    when device attaches as child.

    Later I switch power off on parent. Devicediscovers that it gets no ack for data requests, and changes state to detached:

    <wrn> cli_sample: Thread state changed! new state: 1

    Could you confirm this is the behavior you want to achieve?

Related