Applicable Versions | NetSim Standard | NetSim Pro |
Applicable Releases | v12 | v13 |
Reference:
https://tools.ietf.org/html/rfc6552
The RPL specification describes constraints on how nodes select potential parents, called a parent set, from their neighbors. All parents are feasible successors for upward traffic (towards the root). Additionally, RPL allows the use of parents in a subsequent Version of a same DODAG as feasible successors, in which case this node acts as a leaf in the subsequent DODAG Version.
The Goal of the OF0 is for a node to join a DODAG Version that offers good enough connectivity to a specific set of nodes or to a larger routing infrastructure though there is no guarantee that the path will be optimized according to a specific metric. Thus, for the purpose of OF0, the term Grounded means that the DODAG root provides such connectivity. How that connectivity is asserted and maintained is out of scope.
Follow the steps given below to Modify RPL source codes to implement Objective Function Zero:
1. Open NetSim source code in Visual Studio 2019 by clicking on the Open Code button present in NetSim Home Screen via Open Simulation->Workspace Options->Open Code.
2. Go to the RPL Project in the solution explorer.
3. The compute_candidate_rank function which is part of the Neighbor.c file in RPL project is modified to implement Objective Function Zero as shown below:
static UINT16 compute_candidate_rank(NETSIM_ID d, PRPL_NEIGHBOR neighbor)
{
RPL_RANK increment = 0;
PRPL_NODE rpl = GET_RPL_NODE(d);
PRPL_DODAG p = rpl->joined_dodag;
PRPL_NEIGHBOR parent = p->parent_list;
PRPL_DIO_BASE base = neighbor->lastDIOMSG->Base;
if (base->Rank == 0) {
if (!parent) {
return INFINITE_RANK;
}
base->Rank = parent->rank;
}
increment = (UINT16)parent != NULL ? p->min_hop_rank_inc : DEFAULT_MIN_HOP_RANK_INCREASE;
if ((base->Rank + increment) < base->Rank) {
fnSystemError("RPL: OF0 rank %d incremented to infinite rank due to wrapping\n",
base->Rank);
return INFINITE_RANK;
}
return base->Rank + increment;
}
4. After the source code is modified, right click on the RPL project and select rebuild. After successful build, NetSim will automatically take care of linking the modified source code with simulations performed.
Simulation Results and Analysis:
Now upon running any RPL based simulations, Objective Function Zero will be used to calculate the ranks for the devices to form the DODAG.
The line #define DEBUG_RPL can be uncommented in the RPL.h file and RPL project can be rebuilt to obtain information about the device ranks, parents etc in the RPL log file, which can be accessed under logs in the results dashboard as shown below:
Related articles:
how-does-the-wireless-link-quality-impact-rpl-rank-calculations-in-iot-
how-to-implement-objective-function-one-mrhof-for-rpl-protocol-in-netsim-iot-