Skip to content

Commit b423c46

Browse files
author
Juha Heiskanen
committed
RPL parent select update
Path cost might be not much worse than alternate parents, but it might push us over our DAGMaxRankIncrease limit. In that case, makes sense to treat the path cost as "infinite", allowing immediate switch to an alternative, defeating hysteresis. Round up hard limit - DAGRank interpretation. Contrary to wording of RFC 6550 8.2.2.4.3, but needed to cope reasonably with Wi-SUN insisting on DAGMaxRankIncrease of 0. Interpret that as a request to not increase DAGRank, rather than Rank. Example, if DAGMaxRankIncrease is 0, MinHopRankIncrease is 0x80, and our advertised 0xC0, then we permit up to 0xFF, which doesn't increase DAGRank. If DAGMaxRankIncrease is 0x80, then we permit can go form 0xC0 to 0x17F, increasing DAGRank by 1, even though it's a Rank increase of 0xBF. Fractional parts of DAGMaxRankIncrease are ignored. Change-Id: I66bbc41363844634723b54a4670845024608821e
1 parent 7d2f967 commit b423c46

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

source/RPL/rpl_mrhof.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ static rpl_neighbour_t *rpl_mrhof_select_best_parent(rpl_instance_t *instance, c
198198
/* We can use this to simplify some logic */
199199
if (prev_preferred) {
200200
prev_preferred_path_cost = rpl_mrhof_path_cost_through_neighbour(prev_preferred);
201+
// Path cost might be not much worse than alternate parents, but it might push
202+
// us over our DAGMaxRankIncrease limit. In that case, makes sense to treat
203+
// the path cost as "infinite", allowing immediate switch to an alternative,
204+
// defeating hysteresis.
205+
if (prev_preferred_path_cost > prev_preferred->dodag_version->hard_rank_limit) {
206+
prev_preferred_path_cost = RPL_RANK_INFINITE;
207+
}
201208
}
202209

203210
ns_list_foreach(rpl_neighbour_t, c, &instance->candidate_neighbours) {

source/RPL/rpl_upward.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ uint16_t nrpl_dag_rank(const rpl_dodag_t *dodag, uint16_t rank)
8181
return rank == RPL_RANK_INFINITE ? rank : rank / dodag->config.min_hop_rank_increase;
8282
}
8383

84+
uint16_t nrpl_rank(const rpl_dodag_t *dodag, uint16_t dag_rank)
85+
{
86+
uint32_t rank = (uint32_t) dag_rank * dodag->config.min_hop_rank_increase;
87+
return rank < RPL_RANK_INFINITE ? rank : RPL_RANK_INFINITE;
88+
}
89+
8490
/* Silly function needed because RPL HbH option includes dagrank directly */
8591
rpl_cmp_t rpl_rank_compare_dagrank_rank(const rpl_dodag_t *dodag, uint16_t dag_rank_a, uint16_t b)
8692
{
@@ -1566,7 +1572,27 @@ void rpl_instance_dio_trigger(rpl_instance_t *instance, protocol_interface_info_
15661572
/* When we advertise a new lowest rank, need to re-evaluate our rank limits */
15671573
if (rank < dodag_version->lowest_advertised_rank) {
15681574
dodag_version->lowest_advertised_rank = rank;
1575+
#if 0
1576+
// Standard RFC 6550 behaviour
15691577
dodag_version->hard_rank_limit = rpl_rank_add(rank, dodag->config.dag_max_rank_increase);
1578+
#else
1579+
// Round up hard limit - DAGRank interpretation. Contrary to wording of RFC 6550 8.2.2.4.3,
1580+
// but needed to cope reasonably with Wi-SUN insisting on DAGMaxRankIncrease of 0.
1581+
// Interpret that as a request to not increase DAGRank, rather than Rank.
1582+
//
1583+
// Example, if DAGMaxRankIncrease is 0, MinHopRankIncrease is 0x80, and our advertised
1584+
// 0xC0, then we permit up to 0xFF, which doesn't increase DAGRank. If DAGMaxRankIncrease
1585+
// is 0x80, then we permit can go form 0xC0 to 0x17F, increasing DAGRank by 1, even though
1586+
// it's a Rank increase of 0xBF. Fractional parts of DAGMaxRankIncrease are ignored.
1587+
uint16_t dagrank = nrpl_dag_rank(dodag, rank);
1588+
uint16_t dagmaxinc = nrpl_dag_rank(dodag, dodag->config.dag_max_rank_increase);
1589+
uint16_t dagmax = rpl_rank_add(dagrank, dagmaxinc);
1590+
if (dagmax == RPL_RANK_INFINITE) {
1591+
dodag_version->hard_rank_limit = RPL_RANK_INFINITE;
1592+
} else {
1593+
dodag_version->hard_rank_limit = nrpl_rank(dodag, 1 + dagmax) - 1;
1594+
}
1595+
#endif
15701596
}
15711597
rpl_dodag_version_limit_greediness(dodag_version, rank);
15721598

0 commit comments

Comments
 (0)