Applicable Versions

NetSim Standard

NetSim Pro

Applicable Releases




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 the same DODAG as feasible successors, in which case this node acts as a leaf in the subsequent DODAG Version.

Objective Function 1 or Minimum Rank with HysteresisObjective Function (MRHOF), is an Objective Function for RPL, which uses hysteresis while selecting the path with the smallest metric value. The metric that MRHOF uses is determined by the metrics in the DIO Metric Container.

Follow the steps given below to Modify RPL source codes to implement Objective Function One (MRHOF):

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. Set the platform to Win32 or x64 according to the NetSim build that you are using.


4. The compute_candidate_rank() function which is part of the Neighbor.c file in the RPL project is modified to implement               Objective Function Zero as shown below:

static UINT16 compute_candidate_rank(NETSIM_ID d, PRPL_NEIGHBOR neighbor)

double send_link_quality = fn_NetSim_stack_get_link_quality(d, 1, neighbor->nodeId, 1);

double receive_link_quality = fn_NetSim_stack_get_link_quality(neighbor->nodeId, 1, d, 1);

 double link_quality = 1/(send_link_quality * receive_link_quality);

 RPL_RANK rank_increase = 0;

RPL_RANK new_rank = 0;


PRPL_DODAG p = rpl->joined_dodag;

PRPL_NEIGHBOR parent = p->parent_list;

PRPL_DIO_BASE base = neighbor->lastDIOMSG->Base;

if (parent == NULL) {

if (base->Rank == 0) {





else {

rank_increase = link_quality;

if (base->Rank == 0)


base->Rank = p->rank;



if (INFINITE_RANK - base->Rank < rank_increase)


new_rank = INFINITE_RANK;


else {

new_rank = base->Rank + rank_increase;


return new_rank;


5. The following lines of code are written inside the RPL.h file



6. After the source code is modified, right-click on the RPL project and select rebuild. After a 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 One 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 the RPL project can be rebuilt to obtain information about the device ranks, parents, etc in the RPL log file.

The RPL log file can be accessed under logs in the results dashboard as shown below:

Related articles: