1

I am totally new to contiki and cooja, so your effort is highly appreciated. I think I have to detail my problem. So, I know that part of the neighbor set is the parent set and one of them is chosen to be the preferred parent based on the RPL specification, so how can I choose the worst one from that partial set in contiki? I tried to change the code in the src file rpl-dag.c and rpl-mrhof.c and I expected that every time a node adds a parent to the neighbor set, it compares the new with the current preferred parent and selects the bad one, but that didnt work as it supposed to be!! the node selects parent 0 i.e. it detaches from the DODAG. node 1 is the sink -UDP server- and the rest are UDP clients. Node 8 rpl-dag.c and rpl-mrhof.c codes have been changed. I thought node 8 will change its preferred parent from node 7 to node 6.

rpl-mrhof.c

static rpl_parent_t *
best_parent(rpl_parent_t *p1, rpl_parent_t *p2)
{
  rpl_dag_t *dag;
  rpl_path_metric_t min_diff;
  rpl_path_metric_t p1_metric;
  rpl_path_metric_t p2_metric;

  dag = p1->dag; /* Both parents are in the same DAG. */

  min_diff = RPL_DAG_MC_ETX_DIVISOR /
             PARENT_SWITCH_THRESHOLD_DIV;

  p1_metric = calculate_path_metric(p1);
  p2_metric = calculate_path_metric(p2);

  /* Maintain stability of the preferred parent in case of similar ranks. */
  if(p1 == dag->preferred_parent || p2 == dag->preferred_parent) {
    if(p1_metric < p2_metric + min_diff &&
       p1_metric > p2_metric - min_diff) {
      PRINTF("RPL: MRHOF hysteresis: %u <= %u <= %u\n",
             p2_metric - min_diff,
             p1_metric,
             p2_metric + min_diff);
      return dag->preferred_parent;
    }
  }
  return p1_metric > p2_metric ? p1 : p2;
}

rpl-dag.c

rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
  rpl_parent_t *p, *worse;

  best = NULL;

  //p = nbr_table_head(rpl_parents);
    p= nbr_table_head(ds6_neighbors);
  while(p != NULL) {
    if(p->rank == INFINITE_RANK) {
      /* ignore this neighbor */
    } else if(worse == NULL) {
      worse = p;
    } else {
      worse = dag->instance->of->best_parent(worse, p);
    }
    //p = nbr_table_next(rpl_parents, p);
    p = nbr_table_next(ds6_neighbors, p);
  }

  if(worse != NULL) {
    rpl_set_preferred_parent(dag, worse);
  }

  return worse;
}

enter image description here

enter image description here

4
  • What did you try to change, exactly? And are you sure that the MRHOF objective function is used in RPL?
    – kfx
    Nov 29, 2017 at 22:07
  • I played mainly around the condition if a parent has better metric then selects the other one. Yes the RPL DODAG is built using MRHOF Nov 30, 2017 at 0:08
  • Please, do post your code if you wan't an answer. SO needs an minimal reproducible example.
    – kfx
    Nov 30, 2017 at 12:36
  • Thanks for the update. Is this solved then?
    – kfx
    Dec 2, 2017 at 19:25

1 Answer 1

0

I totally forgot that if a node has 2 parents provide same rank/ routing metric then it has to select either of the 2 and I fixed the code accordingly!!

1
  • long story short, I spent time fixing errors however I didnt get what I was expected until now & I am very desperate and disappointed. What I want to simulate is that to make one of the nodes acts as follows: it selects the worst parent that provides the worst routing information as its preferred parent not like all other normal nodes i.e. Breaking the Objective Function and then updates its parent set and picks the worst parent again. How can I do that?! Will you describe to me exactly what functions or what src files that I need to use/modify to do that? please provide me with some hints Dec 28, 2017 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.