1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

AODVv2: Broken & Expired routes to Invalid routes

This commit is contained in:
Lotte Steenbrink 2015-04-02 10:45:26 -07:00
parent 56f5a836a8
commit ccc33ec619
4 changed files with 23 additions and 22 deletions

View File

@ -338,7 +338,7 @@ ipv6_addr_t *aodv_get_next_hop(ipv6_addr_t *dest)
/* Case 2: Broken Link (detected by lower layer) */ /* Case 2: Broken Link (detected by lower layer) */
int link_broken = (ndp_nc_entry->state == NDP_NCE_STATUS_INCOMPLETE || int link_broken = (ndp_nc_entry->state == NDP_NCE_STATUS_INCOMPLETE ||
ndp_nc_entry->state == NDP_NCE_STATUS_PROBE) && ndp_nc_entry->state == NDP_NCE_STATUS_PROBE) &&
(rt_entry != NULL && rt_entry->state != ROUTE_STATE_BROKEN); (rt_entry != NULL && rt_entry->state != ROUTE_STATE_INVALID);
if (link_broken) { if (link_broken) {
DEBUG("\tNeighbor Cache entry found, but invalid (state: %i). Sending RERR.\n", DEBUG("\tNeighbor Cache entry found, but invalid (state: %i). Sending RERR.\n",
@ -360,8 +360,7 @@ ipv6_addr_t *aodv_get_next_hop(ipv6_addr_t *dest)
ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest)); ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest));
if (rt_entry) { if (rt_entry) {
/* Case 1: Undeliverable Packet */ /* Case 1: Undeliverable Packet */
int packet_indeliverable = rt_entry->state == ROUTE_STATE_BROKEN || int packet_indeliverable = rt_entry->state == ROUTE_STATE_INVALID;
rt_entry->state == ROUTE_STATE_EXPIRED;
if (packet_indeliverable) { if (packet_indeliverable) {
DEBUG("\tRouting table entry found, but invalid (state %i). Sending RERR.\n", DEBUG("\tRouting table entry found, but invalid (state %i). Sending RERR.\n",
rt_entry->state); rt_entry->state);

View File

@ -646,7 +646,7 @@ static enum rfc5444_result _cb_rerr_blocktlv_addresstlvs_okay(struct rfc5444_rea
/* check if route to unreachable node has to be marked as broken and RERR has to be forwarded */ /* check if route to unreachable node has to be marked as broken and RERR has to be forwarded */
if (netaddr_cmp(&unreachable_entry->nextHopAddr, &packet_data.sender) == 0 if (netaddr_cmp(&unreachable_entry->nextHopAddr, &packet_data.sender) == 0
&& (!tlv || seqnum_cmp(unreachable_entry->seqnum, packet_data.origNode.seqnum) == 0)) { && (!tlv || seqnum_cmp(unreachable_entry->seqnum, packet_data.origNode.seqnum) == 0)) {
unreachable_entry->state = ROUTE_STATE_BROKEN; unreachable_entry->state = ROUTE_STATE_INVALID;
unreachable_nodes[num_unreachable_nodes].addr = packet_data.origNode.addr; unreachable_nodes[num_unreachable_nodes].addr = packet_data.origNode.addr;
unreachable_nodes[num_unreachable_nodes].seqnum = packet_data.origNode.seqnum; unreachable_nodes[num_unreachable_nodes].seqnum = packet_data.origNode.seqnum;
num_unreachable_nodes++; num_unreachable_nodes++;

View File

@ -120,7 +120,7 @@ void routingtable_break_and_get_all_hopping_over(struct netaddr *hop,
(*len)++; (*len)++;
DEBUG("\t[routing] unreachable node found: %s\n", netaddr_to_string(&nbuf, &routing_table[i].nextHopAddr)); DEBUG("\t[routing] unreachable node found: %s\n", netaddr_to_string(&nbuf, &routing_table[i].nextHopAddr));
} }
routing_table[i].state = ROUTE_STATE_BROKEN; routing_table[i].state = ROUTE_STATE_INVALID;
DEBUG("\t[routing] number of unreachable nodes: %i\n", *len); DEBUG("\t[routing] number of unreachable nodes: %i\n", *len);
} }
} }
@ -159,30 +159,33 @@ static void _reset_entry_if_stale(uint8_t i)
routing_table[i].lastUsed = now; /* mark the time entry was set to Idle */ routing_table[i].lastUsed = now; /* mark the time entry was set to Idle */
} }
/* After an idle route remains Idle for MAX_IDLETIME, it becomes an Expired route. /* After an Idle route remains Idle for MAX_IDLETIME, it becomes an Invalid route. */
A route MUST be considered Expired if Current_Time >= Route.ExpirationTime
*/
/* if the node is younger than the expiration time, don't bother */ /* if the node is younger than the expiration time, don't bother */
if (timex_cmp(now, expirationTime) < 0) { if (timex_cmp(now, expirationTime) < 0) {
return; return;
} }
/* If Current_Time > Route.ExpirationTime, set Route.State := Invalid. */
if ((state == ROUTE_STATE_IDLE) && if ((state == ROUTE_STATE_IDLE) &&
(timex_cmp(expirationTime, now) < 1)) { (timex_cmp(now, expirationTime) > 0)) {
DEBUG("\t[routing] route towards %s Expired\n", DEBUG("\t[routing] route towards %s became Invalid\n",
netaddr_to_string(&nbuf, &routing_table[i].addr)); netaddr_to_string(&nbuf, &routing_table[i].addr));
DEBUG("\t expirationTime: %"PRIu32":%"PRIu32" , now: %"PRIu32":%"PRIu32"\n", routing_table[i].state = ROUTE_STATE_INVALID;
expirationTime.seconds, expirationTime.microseconds, routing_table[i].lastUsed = now; /* mark the time entry was set to Invalid */
now.seconds, now.microseconds); }
routing_table[i].state = ROUTE_STATE_EXPIRED;
routing_table[i].lastUsed = now; /* mark the time entry was set to Expired */ /* If (Current_Time - Route.LastUsed) > (ACTIVE_INTERVAL + MAX_IDLETIME),
* and if (Route.Timed == FALSE), set Route.State := Invalid. */
if ((timex_cmp(timex_sub(now, lastUsed), timex_add(active_interval, max_idletime)) > 0) &&
(state != ROUTE_STATE_TIMED)) {
routing_table[i].state = ROUTE_STATE_INVALID;
} }
/* After that time, old sequence number information is considered no longer /* After that time, old sequence number information is considered no longer
* valuable and the Expired route MUST BE expunged */ * valid and the Invalid route MUST BE expunged */
if (timex_cmp(timex_sub(now, lastUsed), max_seqnum_lifetime) >= 0) { if (timex_cmp(timex_sub(now, lastUsed), max_seqnum_lifetime) >= 0) {
DEBUG("\t[routing] reset routing table entry for %s at %i\n", DEBUG("\t[routing] Expunged routing table entry for %s at %i\n",
netaddr_to_string(&nbuf, &routing_table[i].addr), i); netaddr_to_string(&nbuf, &routing_table[i].addr), i);
memset(&routing_table[i], 0, sizeof(routing_table[i])); memset(&routing_table[i], 0, sizeof(routing_table[i]));
} }
@ -197,11 +200,11 @@ bool routingtable_offers_improvement(struct aodvv2_routing_entry_t *rt_entry,
} }
/* Check if new info is more costly */ /* Check if new info is more costly */
if ((node_data->metric >= rt_entry->metric) if ((node_data->metric >= rt_entry->metric)
&& !(rt_entry->state != ROUTE_STATE_BROKEN)) { && !(rt_entry->state != ROUTE_STATE_INVALID)) {
return false; return false;
} }
/* Check if new info repairs a broken route */ /* Check if new info repairs an invalid route */
if (!(rt_entry->state != ROUTE_STATE_BROKEN)) { if (!(rt_entry->state != ROUTE_STATE_INVALID)) {
return false; return false;
} }
return true; return true;

View File

@ -39,8 +39,7 @@ enum aodvv2_routing_states
{ {
ROUTE_STATE_ACTIVE, ROUTE_STATE_ACTIVE,
ROUTE_STATE_IDLE, ROUTE_STATE_IDLE,
ROUTE_STATE_EXPIRED, ROUTE_STATE_INVALID,
ROUTE_STATE_BROKEN,
ROUTE_STATE_TIMED ROUTE_STATE_TIMED
}; };