Applicable VersionsNetSim StandardNetSim Pro


Applicable Releasesv12
v13


The Parent selection routine in RPL protocol is part of the choose_parents_and_siblings() function present in the Neighbor.c file in the RPL project
When there are two or more neighbor nodes with the same rank, a child node selects its parent based on which neighbor node sent the DIO message first.

For Eg: Consider a case where Node 1 has a rank say 30 has two neighbor nodes Node 2 and Node 3 with that same rank of 15. If Node 1 initially receives a DIO message from Node Node 3, then it is selected as a parent node. 
 
Later when it receives a DIO message from Node 2, the ranks are compared and since the rank of Node 2 is not less than the rank of Node 3, Node 3 will remain the parent node.

The for loop for (i = 0; i < rpl->neighbor_count; i++) present in the function runs for all the neighbor nodes in the order in the current node list.  The list has the neighbor node id's in the order of DIO receipts. 

The following condition is used to select the neighbor with the lowest rank as the parent:


if (matching_ranks[i] < matching_ranks[best_rank_index])
        {
            best_rank_index = i;
        }

This can be further understood with the help of Packet Trace, Wireshark and RPL log file.

Related articles:
How to view a node’s Rank, Parent and Sibling in RPL based IOT simulations? 
How to access the neighbor list of RPL nodes in NetSim IoT?