Search code examples
parentpacketcontikicooja

How to forward data packets through an alternative path via an alternative parent?


For example, We have a RPL tree, and several data senders transmitting data packets to the sink. After a while, one of the senders stops sending or forwarding data to parent node because we assumed the parent node is suspicious. Instead of sending or forwarding the data packet via the suspicious node, it forwards the data packet through an alternative path via an alternative parent that is chosen from the parent list. What is an efficient and simple way to implement this scenario in Contiki?


Solution

  • What you want to do is to blacklist a specific parent (or multiple parents). To achieve that, you can add a new field uint8_t is_suspicious to the struct rpl_parent.

    I assume that you have the logic for setting this flags already in place. Then, when doing the parent selection in RPL (the best_parent function in rpl-dag.c) you can look at the flag and exclude parents that have it set.

    To the if condition in the existing code:

    /* Exclude parents from other DAGs or announcing an infinite rank */
    if(p->dag != dag || p->rank == INFINITE_RANK || p->rank < ROOT_RANK(dag->instance)) {
      if(p->rank < ROOT_RANK(dag->instance)) {
        PRINTF("RPL: Parent has invalid rank\n");
      }
      continue;
    }
    

    you would add another check: ... || p->is_suspicious).

    Finally, you need to re-trigger the parent selection algorithm every time the is_suspicious status changes of a parent. One way to do that is to call the function rpl_process_parent_event.