Applicable Versions | NetSim Standard | NetSim Pro |
Applicable Releases | v11.1 | v12 | v13 |
Each RPL node maintains a neighbor count and neighbor list. The neighbor_list and neighbor_count variables are defined as part of the stru_rpl_node structure in the RPL.h file.
These variables are used in Neighbor.c file in functions such as:
rpl_find_neighbor()
rpl_add_to_neighbor_list()
add_neighbor() etc
For Example, you may add the following lines of code (highlighted in red) to the function add_neighbor() to get the neighbor list printed to console each time an update happens.
static void add_neighbor(NETSIM_ID d, NETSIM_ID r)
{
PRPL_NODE rpl = GET_RPL_NODE(d);
if (rpl->neighbor_count)
rpl->neighbor_list = (PRPL_NEIGHBOR*)realloc(rpl->neighbor_list,(rpl->neighbor_count + 1)* (sizeof* rpl->neighbor_list));
else
rpl->neighbor_list = (PRPL_NEIGHBOR*)calloc(1, sizeof* rpl->neighbor_list);
PRPL_NEIGHBOR neighbor = (PRPL_NEIGHBOR)calloc(1, sizeof* neighbor);
neighbor->nodeId = r;
rpl->neighbor_list[rpl->neighbor_count] = neighbor;
rpl->neighbor_count++;
fprintf(stderr, "\nNeighbor list of Node %d: ", d);
for (int i = 0; i < rpl->neighbor_count; i++)
{
fprintf(stderr, "%d,", rpl->neighbor_list[i]->nodeId);
}
}
{
PRPL_NODE rpl = GET_RPL_NODE(d);
if (rpl->neighbor_count)
rpl->neighbor_list = (PRPL_NEIGHBOR*)realloc(rpl->neighbor_list,(rpl->neighbor_count + 1)* (sizeof* rpl->neighbor_list));
else
rpl->neighbor_list = (PRPL_NEIGHBOR*)calloc(1, sizeof* rpl->neighbor_list);
PRPL_NEIGHBOR neighbor = (PRPL_NEIGHBOR)calloc(1, sizeof* neighbor);
neighbor->nodeId = r;
rpl->neighbor_list[rpl->neighbor_count] = neighbor;
rpl->neighbor_count++;
fprintf(stderr, "\nNeighbor list of Node %d: ", d);
for (int i = 0; i < rpl->neighbor_count; i++)
{
fprintf(stderr, "%d,", rpl->neighbor_list[i]->nodeId);
}
}
After performing the above code changes and rebuilding RPL source codes, you will get the Neighbor updates printed to console as shown below:
Related articles:
how-ranks-are-distributed-in-rpl-implemented-on-netsim-
can-you-provide-more-information-about-the-objective-function-in-netsim-rpl-
how-to-implement-objective-function-zero-for-rpl-protocol-in-netsim-iot-
how-to-implement-objective-function-one-mrhof-for-rpl-protocol-in-netsim-iot-